Move theme and project instances to new shared data class
This commit is contained in:
@@ -29,7 +29,7 @@ from PyQt5.QtCore import Qt, pyqtSlot
|
||||
from PyQt5.QtGui import QFont, QPixmap
|
||||
from PyQt5.QtWidgets import QWidget, QGridLayout, QLabel
|
||||
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.constants import trConst, nwLabels
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -42,8 +42,6 @@ class GuiItemDetails(QWidget):
|
||||
|
||||
logger.debug("Create: GuiItemDetails")
|
||||
|
||||
self.mainGui = mainGui
|
||||
|
||||
# Internal Variables
|
||||
self._itemHandle = None
|
||||
|
||||
@@ -51,7 +49,7 @@ class GuiItemDetails(QWidget):
|
||||
hSp = CONFIG.pxInt(6)
|
||||
vSp = CONFIG.pxInt(1)
|
||||
mPx = CONFIG.pxInt(6)
|
||||
fPt = CONFIG.theme.fontPointSize
|
||||
fPt = SHARED.theme.fontPointSize
|
||||
|
||||
fntLabel = QFont()
|
||||
fntLabel.setBold(True)
|
||||
@@ -176,8 +174,8 @@ class GuiItemDetails(QWidget):
|
||||
self.updateTheme()
|
||||
|
||||
# Make sure the columns for flags and counts don't resize too often
|
||||
flagWidth = CONFIG.theme.getTextWidth("Mm", fntValue)
|
||||
countWidth = CONFIG.theme.getTextWidth("99,999", fntValue)
|
||||
flagWidth = SHARED.theme.getTextWidth("Mm", fntValue)
|
||||
countWidth = SHARED.theme.getTextWidth("99,999", fntValue)
|
||||
self.mainBox.setColumnMinimumWidth(1, flagWidth)
|
||||
self.mainBox.setColumnMinimumWidth(4, countWidth)
|
||||
|
||||
@@ -233,13 +231,13 @@ class GuiItemDetails(QWidget):
|
||||
self.clearDetails()
|
||||
return
|
||||
|
||||
nwItem = self.mainGui.project.tree[tHandle]
|
||||
nwItem = SHARED.project.tree[tHandle]
|
||||
if nwItem is None:
|
||||
self.clearDetails()
|
||||
return
|
||||
|
||||
self._itemHandle = tHandle
|
||||
iPx = int(round(0.8*CONFIG.theme.baseIconSize))
|
||||
iPx = int(round(0.8*SHARED.theme.baseIconSize))
|
||||
|
||||
# Label
|
||||
# =====
|
||||
@@ -250,11 +248,11 @@ class GuiItemDetails(QWidget):
|
||||
|
||||
if nwItem.isFileType():
|
||||
if nwItem.isActive:
|
||||
self.labelIcon.setPixmap(CONFIG.theme.getPixmap("checked", (iPx, iPx)))
|
||||
self.labelIcon.setPixmap(SHARED.theme.getPixmap("checked", (iPx, iPx)))
|
||||
else:
|
||||
self.labelIcon.setPixmap(CONFIG.theme.getPixmap("unchecked", (iPx, iPx)))
|
||||
self.labelIcon.setPixmap(SHARED.theme.getPixmap("unchecked", (iPx, iPx)))
|
||||
else:
|
||||
self.labelIcon.setPixmap(CONFIG.theme.getPixmap("noncheckable", (iPx, iPx)))
|
||||
self.labelIcon.setPixmap(SHARED.theme.getPixmap("noncheckable", (iPx, iPx)))
|
||||
|
||||
self.labelData.setText(theLabel)
|
||||
|
||||
@@ -268,14 +266,14 @@ class GuiItemDetails(QWidget):
|
||||
# Class
|
||||
# =====
|
||||
|
||||
classIcon = CONFIG.theme.getIcon(nwLabels.CLASS_ICON[nwItem.itemClass])
|
||||
classIcon = SHARED.theme.getIcon(nwLabels.CLASS_ICON[nwItem.itemClass])
|
||||
self.classIcon.setPixmap(classIcon.pixmap(iPx, iPx))
|
||||
self.classData.setText(trConst(nwLabels.CLASS_NAME[nwItem.itemClass]))
|
||||
|
||||
# Layout
|
||||
# ======
|
||||
|
||||
usageIcon = CONFIG.theme.getItemIcon(
|
||||
usageIcon = SHARED.theme.getItemIcon(
|
||||
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, nwItem.mainHeading
|
||||
)
|
||||
self.usageIcon.setPixmap(usageIcon.pixmap(iPx, iPx))
|
||||
|
||||
Reference in New Issue
Block a user