Move theme and project instances to new shared data class

This commit is contained in:
Veronica Berglyd Olsen
2023-08-10 21:13:10 +02:00
parent a2f183f147
commit 863dcf8b37
30 changed files with 530 additions and 578 deletions
+2 -2
View File
@@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (
QSpinBox
)
from novelwriter import CONFIG
from novelwriter import CONFIG, SHARED
from novelwriter.common import readTextFile
from novelwriter.extensions.switch import NSwitch
@@ -60,7 +60,7 @@ class GuiLipsum(QDialog):
nPx = CONFIG.pxInt(64)
vSp = CONFIG.pxInt(4)
self.docIcon = QLabel()
self.docIcon.setPixmap(CONFIG.theme.getPixmap("proj_document", (nPx, nPx)))
self.docIcon.setPixmap(SHARED.theme.getPixmap("proj_document", (nPx, nPx)))
self.leftBox = QVBoxLayout()
self.leftBox.setSpacing(vSp)
+13 -13
View File
@@ -35,7 +35,7 @@ from PyQt5.QtWidgets import (
QPushButton, QSplitter, QVBoxLayout, QWidget
)
from novelwriter import CONFIG
from novelwriter import CONFIG, SHARED
from novelwriter.enum import nwAlert, nwBuildFmt
from novelwriter.common import makeFileNameSafe
from novelwriter.constants import nwLabels
@@ -74,14 +74,14 @@ class GuiManuscriptBuild(QDialog):
self.setMinimumWidth(CONFIG.pxInt(500))
self.setMinimumHeight(CONFIG.pxInt(300))
iPx = CONFIG.theme.baseIconSize
iPx = SHARED.theme.baseIconSize
sp4 = CONFIG.pxInt(4)
sp8 = CONFIG.pxInt(8)
sp16 = CONFIG.pxInt(16)
wWin = CONFIG.pxInt(620)
hWin = CONFIG.pxInt(360)
pOptions = self.mainGui.project.options
pOptions = SHARED.project.options
self.resize(
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "winWidth", wWin)),
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "winHeight", hWin))
@@ -146,7 +146,7 @@ class GuiManuscriptBuild(QDialog):
# Build Path
self.lblPath = QLabel(self.tr("Path"))
self.buildPath = QLineEdit(self)
self.btnBrowse = QPushButton(CONFIG.theme.getIcon("browse"), "")
self.btnBrowse = QPushButton(SHARED.theme.getIcon("browse"), "")
self.pathBox = QHBoxLayout()
self.pathBox.addWidget(self.buildPath)
@@ -156,7 +156,7 @@ class GuiManuscriptBuild(QDialog):
# Build Name
self.lblName = QLabel(self.tr("File Name"))
self.buildName = QLineEdit(self)
self.btnReset = QPushButton(CONFIG.theme.getIcon("revert"), "")
self.btnReset = QPushButton(SHARED.theme.getIcon("revert"), "")
self.btnReset.setToolTip(self.tr("Reset file name to default"))
self.nameBox = QHBoxLayout()
@@ -181,7 +181,7 @@ class GuiManuscriptBuild(QDialog):
self.buildBox.setVerticalSpacing(sp4)
# Dialog Buttons
self.btnBuild = QPushButton(CONFIG.theme.getIcon("export"), self.tr("&Build"))
self.btnBuild = QPushButton(SHARED.theme.getIcon("export"), self.tr("&Build"))
self.dlgButtons = QDialogButtonBox(QDialogButtonBox.Close)
self.dlgButtons.addButton(self.btnBuild, QDialogButtonBox.ActionRole)
@@ -279,7 +279,7 @@ class GuiManuscriptBuild(QDialog):
@pyqtSlot()
def _doResetBuildName(self):
"""Generate a default build name."""
bName = f"{self.mainGui.project.data.name} - {self._build.name}"
bName = f"{SHARED.project.data.name} - {self._build.name}"
self.buildName.setText(bName)
self._build.setLastBuildName(bName)
return
@@ -320,7 +320,7 @@ class GuiManuscriptBuild(QDialog):
):
return False
docBuild = NWBuildDocument(self.mainGui.project, self._build)
docBuild = NWBuildDocument(SHARED.project, self._build)
docBuild.queueAll()
self.buildProgress.setMaximum(len(docBuild))
@@ -353,7 +353,7 @@ class GuiManuscriptBuild(QDialog):
fmtWidth = CONFIG.rpxInt(mainSplit[0])
sumWidth = CONFIG.rpxInt(mainSplit[1])
pOptions = self.mainGui.project.options
pOptions = SHARED.project.options
pOptions.setValue("GuiManuscriptBuild", "winWidth", winWidth)
pOptions.setValue("GuiManuscriptBuild", "winHeight", winHeight)
pOptions.setValue("GuiManuscriptBuild", "fmtWidth", fmtWidth)
@@ -365,9 +365,9 @@ class GuiManuscriptBuild(QDialog):
def _populateContentList(self):
"""Build the content list."""
rootMap = {}
filtered = self._build.buildItemFilter(self.mainGui.project)
filtered = self._build.buildItemFilter(SHARED.project)
self.listContent.clear()
for nwItem in self.mainGui.project.tree:
for nwItem in SHARED.project.tree:
tHandle = nwItem.itemHandle
rHandle = nwItem.itemRoot
@@ -376,11 +376,11 @@ class GuiManuscriptBuild(QDialog):
if filtered.get(tHandle, (False, 0))[0]:
if rHandle not in rootMap:
rItem = self.mainGui.project.tree[rHandle]
rItem = SHARED.project.tree[rHandle]
if isinstance(rItem, NWItem):
rootMap[rHandle] = rItem.itemName
itemIcon = CONFIG.theme.getItemIcon(
itemIcon = SHARED.theme.getItemIcon(
nwItem.itemType, nwItem.itemClass,
nwItem.itemLayout, nwItem.mainHeading
)
+18 -20
View File
@@ -38,7 +38,7 @@ from PyQt5.QtWidgets import (
)
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
from novelwriter import CONFIG
from novelwriter import CONFIG, SHARED
from novelwriter.error import logException
from novelwriter.common import checkInt, fuzzyTime
from novelwriter.core.tohtml import ToHtml
@@ -74,18 +74,18 @@ class GuiManuscript(QDialog):
self.mainGui = mainGui
self._builds = BuildCollection(self.mainGui.project)
self._builds = BuildCollection(SHARED.project)
self._buildMap: dict[str, QListWidgetItem] = {}
self.setWindowTitle(self.tr("Build Manuscript"))
self.setMinimumWidth(CONFIG.pxInt(600))
self.setMinimumHeight(CONFIG.pxInt(500))
iPx = CONFIG.theme.baseIconSize
iPx = SHARED.theme.baseIconSize
wWin = CONFIG.pxInt(900)
hWin = CONFIG.pxInt(600)
pOptions = self.mainGui.project.options
pOptions = SHARED.project.options
self.resize(
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "winWidth", wWin)),
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "winHeight", hWin))
@@ -105,21 +105,21 @@ class GuiManuscript(QDialog):
).format(CONFIG.pxInt(2), fadeCol.red(), fadeCol.green(), fadeCol.blue())
self.tbAdd = QToolButton(self)
self.tbAdd.setIcon(CONFIG.theme.getIcon("add"))
self.tbAdd.setIcon(SHARED.theme.getIcon("add"))
self.tbAdd.setIconSize(QSize(iPx, iPx))
self.tbAdd.setToolTip(self.tr("Add New Build"))
self.tbAdd.setStyleSheet(buttonStyle)
self.tbAdd.clicked.connect(self._createNewBuild)
self.tbDel = QToolButton(self)
self.tbDel.setIcon(CONFIG.theme.getIcon("remove"))
self.tbDel.setIcon(SHARED.theme.getIcon("remove"))
self.tbDel.setIconSize(QSize(iPx, iPx))
self.tbDel.setToolTip(self.tr("Delete Selected Build"))
self.tbDel.setStyleSheet(buttonStyle)
self.tbDel.clicked.connect(self._deleteSelectedBuild)
self.tbEdit = QToolButton(self)
self.tbEdit.setIcon(CONFIG.theme.getIcon("edit"))
self.tbEdit.setIcon(SHARED.theme.getIcon("edit"))
self.tbEdit.setIconSize(QSize(iPx, iPx))
self.tbEdit.setToolTip(self.tr("Edit Selected Build"))
self.tbEdit.setStyleSheet(buttonStyle)
@@ -163,7 +163,7 @@ class GuiManuscript(QDialog):
# Assemble GUI
# ============
self.docPreview = _PreviewWidget(self.mainGui)
self.docPreview = _PreviewWidget(self)
self.controlBox = QVBoxLayout()
self.controlBox.addLayout(self.listToolBox, 0)
@@ -210,7 +210,7 @@ class GuiManuscript(QDialog):
self._updateBuildsList()
logger.debug("Loading build cache")
cache = CONFIG.dataPath("cache") / f"build_{self.mainGui.project.data.uuid}.json"
cache = CONFIG.dataPath("cache") / f"build_{SHARED.project.data.uuid}.json"
if cache.is_file():
try:
with open(cache, mode="r", encoding="utf-8") as fObj:
@@ -289,7 +289,7 @@ class GuiManuscript(QDialog):
if build is None:
return
docBuild = NWBuildDocument(self.mainGui.project, build)
docBuild = NWBuildDocument(SHARED.project, build)
docBuild.queueAll()
self.docPreview.beginNewBuild(len(docBuild))
@@ -309,7 +309,7 @@ class GuiManuscript(QDialog):
self._updatePreview(result, build)
logger.debug("Saving build cache")
cache = CONFIG.dataPath("cache") / f"build_{self.mainGui.project.data.uuid}.json"
cache = CONFIG.dataPath("cache") / f"build_{SHARED.project.data.uuid}.json"
try:
with open(cache, mode="w+", encoding="utf-8") as outFile:
outFile.write(json.dumps(result, indent=2))
@@ -390,7 +390,7 @@ class GuiManuscript(QDialog):
optsWidth = CONFIG.rpxInt(mainSplit[0])
viewWidth = CONFIG.rpxInt(mainSplit[1])
pOptions = self.mainGui.project.options
pOptions = SHARED.project.options
pOptions.setValue("GuiManuscript", "winWidth", winWidth)
pOptions.setValue("GuiManuscript", "winHeight", winHeight)
pOptions.setValue("GuiManuscript", "optsWidth", optsWidth)
@@ -426,7 +426,7 @@ class GuiManuscript(QDialog):
for key, name in self._builds.builds():
bItem = QListWidgetItem()
bItem.setText(name)
bItem.setIcon(CONFIG.theme.getIcon("export"))
bItem.setIcon(SHARED.theme.getIcon("export"))
bItem.setData(self.D_KEY, key)
self.buildList.addItem(bItem)
self._buildMap[key] = bItem
@@ -446,10 +446,8 @@ class GuiManuscript(QDialog):
class _PreviewWidget(QTextBrowser):
def __init__(self, mainGui: GuiMain):
super().__init__(parent=mainGui)
self.mainGui = mainGui
def __init__(self, parent: QWidget):
super().__init__(parent=parent)
self._docTime = 0
self._buildName = ""
@@ -460,7 +458,7 @@ class _PreviewWidget(QTextBrowser):
dPalette.setColor(QPalette.Text, QColor(0, 0, 0))
self.setPalette(dPalette)
self.setMinimumWidth(40*CONFIG.theme.textNWidth)
self.setMinimumWidth(40*SHARED.theme.textNWidth)
self.setTextFont(CONFIG.textFont, CONFIG.textSize)
self.setTabStopDistance(CONFIG.getTabWidth())
self.setOpenExternalLinks(False)
@@ -478,7 +476,7 @@ class _PreviewWidget(QTextBrowser):
aPalette.setColor(QPalette.Foreground, aPalette.toolTipText().color())
aFont = self.font()
aFont.setPointSizeF(0.9*CONFIG.theme.fontPointSize)
aFont.setPointSizeF(0.9*SHARED.theme.fontPointSize)
self.ageLabel = QLabel("", self)
self.ageLabel.setIndent(0)
@@ -486,7 +484,7 @@ class _PreviewWidget(QTextBrowser):
self.ageLabel.setPalette(aPalette)
self.ageLabel.setAutoFillBackground(True)
self.ageLabel.setAlignment(Qt.AlignCenter)
self.ageLabel.setFixedHeight(int(2.1*CONFIG.theme.fontPixelSize))
self.ageLabel.setFixedHeight(int(2.1*SHARED.theme.fontPixelSize))
# Progress
self.buildProgress = NProgressCircle(self, CONFIG.pxInt(160), CONFIG.pxInt(16))
+33 -38
View File
@@ -39,7 +39,7 @@ from PyQt5.QtWidgets import (
QWidget
)
from novelwriter import CONFIG
from novelwriter import CONFIG, SHARED
from novelwriter.constants import nwHeadFmt, nwLabels, trConst
from novelwriter.core.buildsettings import BuildSettings, FilterMode
from novelwriter.extensions.switch import NSwitch
@@ -88,7 +88,7 @@ class GuiBuildSettings(QDialog):
wWin = CONFIG.pxInt(750)
hWin = CONFIG.pxInt(550)
pOptions = self.mainGui.project.options
pOptions = SHARED.project.options
self.resize(
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winWidth", wWin)),
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "winHeight", hWin))
@@ -100,7 +100,7 @@ class GuiBuildSettings(QDialog):
self.optSideBar = NPagedSideBar(self)
self.optSideBar.setMinimumWidth(mPx)
self.optSideBar.setMaximumWidth(mPx)
self.optSideBar.setLabelColor(CONFIG.theme.helpText)
self.optSideBar.setLabelColor(SHARED.theme.helpText)
self.optSideBar.addLabel(self.tr("Options"))
self.optSideBar.addButton(self.tr("Selection"), self.OPT_FILTERS)
@@ -262,7 +262,7 @@ class GuiBuildSettings(QDialog):
treeWidth, filterWidth = self.optTabSelect.mainSplitSizes()
pOptions = self.mainGui.project.options
pOptions = SHARED.project.options
pOptions.setValue("GuiBuildSettings", "winWidth", winWidth)
pOptions.setValue("GuiBuildSettings", "winHeight", winHeight)
pOptions.setValue("GuiBuildSettings", "treeWidth", treeWidth)
@@ -303,16 +303,14 @@ class _FilterTab(QWidget):
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
super().__init__(parent=buildMain)
self.mainGui = buildMain.mainGui
self._treeMap: dict[str, QTreeWidgetItem] = {}
self._build = build
self._statusFlags: dict[int, QIcon] = {
self.F_NONE: QIcon(),
self.F_FILTERED: CONFIG.theme.getIcon("build_filtered"),
self.F_INCLUDED: CONFIG.theme.getIcon("build_included"),
self.F_EXCLUDED: CONFIG.theme.getIcon("build_excluded"),
self.F_FILTERED: SHARED.theme.getIcon("build_filtered"),
self.F_INCLUDED: SHARED.theme.getIcon("build_included"),
self.F_EXCLUDED: SHARED.theme.getIcon("build_excluded"),
}
self._trIncluded = self.tr("Included in manuscript")
@@ -322,7 +320,7 @@ class _FilterTab(QWidget):
# ============
# Tree Settings
iPx = CONFIG.theme.baseIconSize
iPx = SHARED.theme.baseIconSize
cMg = CONFIG.pxInt(6)
# Tree Widget
@@ -360,7 +358,7 @@ class _FilterTab(QWidget):
self.resetButton = QToolButton(self)
self.resetButton.setToolTip(self.tr("Reset to default"))
self.resetButton.setIcon(CONFIG.theme.getIcon("revert"))
self.resetButton.setIcon(SHARED.theme.getIcon("revert"))
self.resetButton.clicked.connect(lambda: self._setSelectedMode(self.F_FILTERED))
self.modeBox = QHBoxLayout()
@@ -379,7 +377,7 @@ class _FilterTab(QWidget):
# Assemble GUI
# ============
pOptions = self.mainGui.project.options
pOptions = SHARED.project.options
self.selectionBox = QVBoxLayout()
self.selectionBox.addWidget(self.optTree)
@@ -445,7 +443,7 @@ class _FilterTab(QWidget):
logger.debug("Building project tree")
self._treeMap = {}
self.optTree.clear()
for nwItem in self.mainGui.project.getProjectItems():
for nwItem in SHARED.project.getProjectItems():
tHandle = nwItem.itemHandle
pHandle = nwItem.itemParent
@@ -461,7 +459,7 @@ class _FilterTab(QWidget):
continue
hLevel = nwItem.mainHeading
itemIcon = CONFIG.theme.getItemIcon(
itemIcon = SHARED.theme.getItemIcon(
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout, hLevel
)
@@ -475,7 +473,7 @@ class _FilterTab(QWidget):
trItem.setText(self.C_NAME, nwItem.itemName)
trItem.setData(self.C_DATA, self.D_HANDLE, tHandle)
trItem.setData(self.C_DATA, self.D_FILE, isFile)
trItem.setIcon(self.C_ACTIVE, CONFIG.theme.getIcon(iconName))
trItem.setIcon(self.C_ACTIVE, SHARED.theme.getIcon(iconName))
trItem.setTextAlignment(self.C_NAME, Qt.AlignLeft)
@@ -499,19 +497,19 @@ class _FilterTab(QWidget):
self.filterOpt.clear()
self.filterOpt.addLabel(self._build.getLabel("filter"))
self.filterOpt.addItem(
CONFIG.theme.getIcon("proj_scene"),
SHARED.theme.getIcon("proj_scene"),
self._build.getLabel("filter.includeNovel"),
"doc:filter.includeNovel",
default=self._build.getBool("filter.includeNovel")
)
self.filterOpt.addItem(
CONFIG.theme.getIcon("proj_note"),
SHARED.theme.getIcon("proj_note"),
self._build.getLabel("filter.includeNotes"),
"doc:filter.includeNotes",
default=self._build.getBool("filter.includeNotes")
)
self.filterOpt.addItem(
CONFIG.theme.getIcon("unchecked"),
SHARED.theme.getIcon("unchecked"),
self._build.getLabel("filter.includeInactive"),
"doc:filter.includeInactive",
default=self._build.getBool("filter.includeInactive")
@@ -521,9 +519,9 @@ class _FilterTab(QWidget):
# Root Classes
self.filterOpt.addLabel(self.tr("Select Root Folders"))
for tHandle, nwItem in self.mainGui.project.tree.iterRoots(None):
for tHandle, nwItem in SHARED.project.tree.iterRoots(None):
if not nwItem.isInactiveClass():
itemIcon = CONFIG.theme.getItemIcon(
itemIcon = SHARED.theme.getItemIcon(
nwItem.itemType, nwItem.itemClass, nwItem.itemLayout
)
self.filterOpt.addItem(
@@ -557,7 +555,7 @@ class _FilterTab(QWidget):
def _setTreeItemMode(self) -> None:
"""Update the filtered mode icon on all items."""
filtered = self._build.buildItemFilter(self.mainGui.project)
filtered = self._build.buildItemFilter(SHARED.project)
for tHandle, item in self._treeMap.items():
allow, mode = filtered.get(tHandle, (False, FilterMode.UNKNOWN))
if mode == FilterMode.INCLUDED:
@@ -597,12 +595,10 @@ class _HeadingsTab(QWidget):
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
super().__init__(parent=buildMain)
self.mainGui = buildMain.mainGui
self._build = build
self._editing = 0
iPx = CONFIG.theme.baseIconSize
iPx = SHARED.theme.baseIconSize
vSp = CONFIG.pxInt(12)
bSp = CONFIG.pxInt(6)
@@ -616,7 +612,7 @@ class _HeadingsTab(QWidget):
self.fmtTitle = QLineEdit("")
self.fmtTitle.setReadOnly(True)
self.btnTitle = QToolButton()
self.btnTitle.setIcon(CONFIG.theme.getIcon("edit"))
self.btnTitle.setIcon(SHARED.theme.getIcon("edit"))
self.btnTitle.clicked.connect(lambda: self._editHeading(self.EDIT_TITLE))
wrapTitle = QHBoxLayout()
@@ -632,7 +628,7 @@ class _HeadingsTab(QWidget):
self.fmtChapter = QLineEdit("")
self.fmtChapter.setReadOnly(True)
self.btnChapter = QToolButton()
self.btnChapter.setIcon(CONFIG.theme.getIcon("edit"))
self.btnChapter.setIcon(SHARED.theme.getIcon("edit"))
self.btnChapter.clicked.connect(lambda: self._editHeading(self.EDIT_CHAPTER))
wrapChapter = QHBoxLayout()
@@ -648,7 +644,7 @@ class _HeadingsTab(QWidget):
self.fmtUnnumbered = QLineEdit("")
self.fmtUnnumbered.setReadOnly(True)
self.btnUnnumbered = QToolButton()
self.btnUnnumbered.setIcon(CONFIG.theme.getIcon("edit"))
self.btnUnnumbered.setIcon(SHARED.theme.getIcon("edit"))
self.btnUnnumbered.clicked.connect(lambda: self._editHeading(self.EDIT_UNNUM))
wrapUnnumbered = QHBoxLayout()
@@ -665,7 +661,7 @@ class _HeadingsTab(QWidget):
self.fmtScene = QLineEdit("")
self.fmtScene.setReadOnly(True)
self.btnScene = QToolButton()
self.btnScene.setIcon(CONFIG.theme.getIcon("edit"))
self.btnScene.setIcon(SHARED.theme.getIcon("edit"))
self.btnScene.clicked.connect(lambda: self._editHeading(self.EDIT_SCENE))
self.hdeScene = QLabel(self.tr("Hide"))
self.hdeScene.setToolTip(sceneHideTip)
@@ -692,7 +688,7 @@ class _HeadingsTab(QWidget):
self.fmtSection = QLineEdit("")
self.fmtSection.setReadOnly(True)
self.btnSection = QToolButton()
self.btnSection.setIcon(CONFIG.theme.getIcon("edit"))
self.btnSection.setIcon(SHARED.theme.getIcon("edit"))
self.btnSection.clicked.connect(lambda: self._editHeading(self.EDIT_SECTION))
self.hdeSection = QLabel(self.tr("Hide"))
self.hdeSection.setToolTip(sectionHideTip)
@@ -868,9 +864,9 @@ class _HeadingSyntaxHighlighter(QSyntaxHighlighter):
def __init__(self, document: QTextDocument) -> None:
super().__init__(document)
self._fmtSymbol = QTextCharFormat()
self._fmtSymbol.setForeground(QColor(*CONFIG.theme.colHead))
self._fmtSymbol.setForeground(QColor(*SHARED.theme.colHead))
self._fmtFormat = QTextCharFormat()
self._fmtFormat.setForeground(QColor(*CONFIG.theme.colEmph))
self._fmtFormat.setForeground(QColor(*SHARED.theme.colEmph))
return
def highlightBlock(self, text: str) -> None:
@@ -896,7 +892,7 @@ class _ContentTab(QWidget):
self._build = build
iPx = CONFIG.theme.baseIconSize
iPx = SHARED.theme.baseIconSize
# Left Form
# =========
@@ -964,14 +960,13 @@ class _FormatTab(QWidget):
super().__init__(parent=buildMain)
self.buildMain = buildMain
self.mainGui = buildMain.mainGui
self._build = build
self._unitScale = 1.0
iPx = CONFIG.theme.baseIconSize
spW = 6*CONFIG.theme.textNWidth
dbW = 8*CONFIG.theme.textNWidth
iPx = SHARED.theme.baseIconSize
spW = 6*SHARED.theme.textNWidth
dbW = 8*SHARED.theme.textNWidth
# Text Format Form
# ================
@@ -992,7 +987,7 @@ class _FormatTab(QWidget):
self.textFont = QLineEdit()
self.textFont.setReadOnly(True)
self.btnTextFont = QPushButton("...")
self.btnTextFont.setMaximumWidth(int(2.5*CONFIG.theme.getTextWidth("...")))
self.btnTextFont.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
self.btnTextFont.clicked.connect(self._selectFont)
self.formFormat.addRow(
self._build.getLabel("format.textFont"), self.textFont, button=self.btnTextFont
@@ -1278,7 +1273,7 @@ class _OutputTab(QWidget):
self._build = build
iPx = CONFIG.theme.baseIconSize
iPx = SHARED.theme.baseIconSize
# Left Form
# =========
+4 -4
View File
@@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (
QPushButton, QRadioButton, QSpinBox, QVBoxLayout, QWizard, QWizardPage
)
from novelwriter import CONFIG
from novelwriter import CONFIG, SHARED
from novelwriter.common import makeFileNameSafe
from novelwriter.extensions.switch import NSwitch
@@ -55,7 +55,7 @@ class GuiProjectWizard(QWizard):
self.mainGui = mainGui
self.sideImage = CONFIG.theme.loadDecoration(
self.sideImage = SHARED.theme.loadDecoration(
"wiz-back", None, CONFIG.pxInt(370)
)
self.setWizardStyle(QWizard.ModernStyle)
@@ -104,7 +104,7 @@ class ProjWizardIntroPage(QWizardPage):
"Peter Mitterhofer", "CC BY-SA 4.0"
))
lblFont = self.imgCredit.font()
lblFont.setPointSizeF(0.6*CONFIG.theme.fontPointSize)
lblFont.setPointSizeF(0.6*SHARED.theme.fontPointSize)
self.imgCredit.setFont(lblFont)
xW = CONFIG.pxInt(300)
@@ -172,7 +172,7 @@ class ProjWizardFolderPage(QWizardPage):
self.projPath.setPlaceholderText(self.tr("Required"))
self.browseButton = QPushButton("...")
self.browseButton.setMaximumWidth(int(2.5*CONFIG.theme.getTextWidth("...")))
self.browseButton.setMaximumWidth(int(2.5*SHARED.theme.getTextWidth("...")))
self.browseButton.clicked.connect(self._doBrowse)
self.errLabel = QLabel("")
+17 -17
View File
@@ -36,7 +36,7 @@ from PyQt5.QtWidgets import (
QLabel, QGroupBox, QMenu, QAction, QFileDialog, QSpinBox, QHBoxLayout
)
from novelwriter import CONFIG
from novelwriter import CONFIG, SHARED
from novelwriter.enum import nwAlert
from novelwriter.error import formatException
from novelwriter.common import formatTime, checkInt, checkIntTuple, minmax
@@ -79,7 +79,7 @@ class GuiWritingStats(QDialog):
self.timeFilter = 0.0
self.wordOffset = 0
pOptions = self.mainGui.project.options
pOptions = SHARED.project.options
self.setWindowTitle(self.tr("Writing Statistics"))
self.setMinimumWidth(CONFIG.pxInt(420))
@@ -132,7 +132,7 @@ class GuiWritingStats(QDialog):
self.listBox.setSortingEnabled(True)
# Word Bar
self.barHeight = int(round(0.5*CONFIG.theme.fontPixelSize))
self.barHeight = int(round(0.5*SHARED.theme.fontPixelSize))
self.barWidth = CONFIG.pxInt(200)
self.barImage = QPixmap(self.barHeight, self.barHeight)
self.barImage.fill(self.palette().highlight().color())
@@ -143,27 +143,27 @@ class GuiWritingStats(QDialog):
self.infoBox.setLayout(self.infoForm)
self.labelTotal = QLabel(formatTime(0))
self.labelTotal.setFont(CONFIG.theme.guiFontFixed)
self.labelTotal.setFont(SHARED.theme.guiFontFixed)
self.labelTotal.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.labelIdleT = QLabel(formatTime(0))
self.labelIdleT.setFont(CONFIG.theme.guiFontFixed)
self.labelIdleT.setFont(SHARED.theme.guiFontFixed)
self.labelIdleT.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.labelFilter = QLabel(formatTime(0))
self.labelFilter.setFont(CONFIG.theme.guiFontFixed)
self.labelFilter.setFont(SHARED.theme.guiFontFixed)
self.labelFilter.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.novelWords = QLabel("0")
self.novelWords.setFont(CONFIG.theme.guiFontFixed)
self.novelWords.setFont(SHARED.theme.guiFontFixed)
self.novelWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.notesWords = QLabel("0")
self.notesWords.setFont(CONFIG.theme.guiFontFixed)
self.notesWords.setFont(SHARED.theme.guiFontFixed)
self.notesWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self.totalWords = QLabel("0")
self.totalWords.setFont(CONFIG.theme.guiFontFixed)
self.totalWords.setFont(SHARED.theme.guiFontFixed)
self.totalWords.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
lblTTime = QLabel(self.tr("Total Time:"))
@@ -190,7 +190,7 @@ class GuiWritingStats(QDialog):
self.infoForm.setRowStretch(6, 1)
# Filter Options
sPx = CONFIG.theme.baseIconSize
sPx = SHARED.theme.baseIconSize
self.filterBox = QGroupBox(self.tr("Filters"), self)
self.filterForm = QGridLayout(self)
@@ -333,7 +333,7 @@ class GuiWritingStats(QDialog):
showIdleTime = self.showIdleTime.isChecked()
histMax = self.histMax.value()
pOptions = self.mainGui.project.options
pOptions = SHARED.project.options
pOptions.setValue("GuiWritingStats", "winWidth", winWidth)
pOptions.setValue("GuiWritingStats", "winHeight", winHeight)
pOptions.setValue("GuiWritingStats", "widthCol0", widthCol0)
@@ -441,7 +441,7 @@ class GuiWritingStats(QDialog):
ttTime = 0
ttIdle = 0
for record in self.mainGui.project.session.iterRecords():
for record in SHARED.project.session.iterRecords():
rType = record.get("type")
if rType == "initial":
self.wordOffset = checkInt(record.get("offset"), 0)
@@ -587,13 +587,13 @@ class GuiWritingStats(QDialog):
newItem.setTextAlignment(self.C_COUNT, Qt.AlignRight)
newItem.setTextAlignment(self.C_BAR, Qt.AlignLeft | Qt.AlignVCenter)
newItem.setFont(self.C_TIME, CONFIG.theme.guiFontFixed)
newItem.setFont(self.C_LENGTH, CONFIG.theme.guiFontFixed)
newItem.setFont(self.C_COUNT, CONFIG.theme.guiFontFixed)
newItem.setFont(self.C_TIME, SHARED.theme.guiFontFixed)
newItem.setFont(self.C_LENGTH, SHARED.theme.guiFontFixed)
newItem.setFont(self.C_COUNT, SHARED.theme.guiFontFixed)
if showIdleTime:
newItem.setFont(self.C_IDLE, CONFIG.theme.guiFontFixed)
newItem.setFont(self.C_IDLE, SHARED.theme.guiFontFixed)
else:
newItem.setFont(self.C_IDLE, CONFIG.theme.guiFont)
newItem.setFont(self.C_IDLE, SHARED.theme.guiFont)
self.listBox.addTopLevelItem(newItem)
self.timeFilter += sDiff