Clean up warnings and deprecations in gui tools

This commit is contained in:
Veronica Berglyd Olsen
2025-01-13 02:53:55 +01:00
parent 5027b8df19
commit 7e280b2371
9 changed files with 236 additions and 322 deletions
-8
View File
@@ -399,14 +399,6 @@ class Config:
# Methods # Methods
## ##
def pxInt(self, value: int) -> int:
"""Deprecated. Do not use."""
return value
def rpxInt(self, value: int) -> int:
"""Deprecated. Do not use."""
return value
def homePath(self) -> Path: def homePath(self) -> Path:
"""The user's home folder.""" """The user's home folder."""
return self._homePath return self._homePath
+7 -10
View File
@@ -57,12 +57,9 @@ class GuiDictionaries(NNonBlockingDialog):
self._currDicts = set() self._currDicts = set()
iSz = SHARED.theme.baseIconSize iSz = SHARED.theme.baseIconSize
iPx = CONFIG.pxInt(4)
mPx = CONFIG.pxInt(8)
sPx = CONFIG.pxInt(16)
self.setMinimumWidth(CONFIG.pxInt(500)) self.setMinimumWidth(500)
self.setMinimumHeight(CONFIG.pxInt(300)) self.setMinimumHeight(300)
# Hunspell Dictionaries # Hunspell Dictionaries
foUrl = "https://www.freeoffice.com/en/download/dictionaries" foUrl = "https://www.freeoffice.com/en/download/dictionaries"
@@ -84,7 +81,7 @@ class GuiDictionaries(NNonBlockingDialog):
self.huPathBox = QHBoxLayout() self.huPathBox = QHBoxLayout()
self.huPathBox.addWidget(self.huInput) self.huPathBox.addWidget(self.huInput)
self.huPathBox.addWidget(self.huBrowse) self.huPathBox.addWidget(self.huBrowse)
self.huPathBox.setSpacing(iPx) self.huPathBox.setSpacing(4)
self.huAddBox = QHBoxLayout() self.huAddBox = QHBoxLayout()
self.huAddBox.addStretch(1) self.huAddBox.addStretch(1)
self.huAddBox.addWidget(self.huImport) self.huAddBox.addWidget(self.huImport)
@@ -99,7 +96,7 @@ class GuiDictionaries(NNonBlockingDialog):
self.inBox = QHBoxLayout() self.inBox = QHBoxLayout()
self.inBox.addWidget(self.inPath) self.inBox.addWidget(self.inPath)
self.inBox.addWidget(self.inBrowse) self.inBox.addWidget(self.inBrowse)
self.inBox.setSpacing(iPx) self.inBox.setSpacing(4)
# Info Box # Info Box
self.infoBox = QPlainTextEdit(self) self.infoBox = QPlainTextEdit(self)
@@ -116,17 +113,17 @@ class GuiDictionaries(NNonBlockingDialog):
self.innerBox.addWidget(self.huInfo) self.innerBox.addWidget(self.huInfo)
self.innerBox.addLayout(self.huPathBox) self.innerBox.addLayout(self.huPathBox)
self.innerBox.addLayout(self.huAddBox) self.innerBox.addLayout(self.huAddBox)
self.innerBox.addSpacing(mPx) self.innerBox.addSpacing(8)
self.innerBox.addWidget(self.inInfo) self.innerBox.addWidget(self.inInfo)
self.innerBox.addLayout(self.inBox) self.innerBox.addLayout(self.inBox)
self.innerBox.addWidget(self.infoBox) self.innerBox.addWidget(self.infoBox)
self.innerBox.setSpacing(iPx) self.innerBox.setSpacing(4)
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
self.outerBox.addLayout(self.innerBox, 0) self.outerBox.addLayout(self.innerBox, 0)
self.outerBox.addStretch(1) self.outerBox.addStretch(1)
self.outerBox.addWidget(self.buttonBox, 0) self.outerBox.addWidget(self.buttonBox, 0)
self.outerBox.setSpacing(sPx) self.outerBox.setSpacing(16)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
+10 -11
View File
@@ -52,18 +52,15 @@ class GuiLipsum(NDialog):
self._lipsumText = "" self._lipsumText = ""
vSp = CONFIG.pxInt(4)
nPx = CONFIG.pxInt(64)
self.innerBox = QHBoxLayout() self.innerBox = QHBoxLayout()
self.innerBox.setSpacing(CONFIG.pxInt(16)) self.innerBox.setSpacing(16)
# Icon # Icon
self.docIcon = QLabel(self) self.docIcon = QLabel(self)
self.docIcon.setPixmap(SHARED.theme.getPixmap("text", (nPx, nPx), "blue")) self.docIcon.setPixmap(SHARED.theme.getPixmap("text", (64, 64), "blue"))
self.leftBox = QVBoxLayout() self.leftBox = QVBoxLayout()
self.leftBox.setSpacing(vSp) self.leftBox.setSpacing(4)
self.leftBox.addWidget(self.docIcon) self.leftBox.addWidget(self.docIcon)
self.leftBox.addStretch(1) self.leftBox.addStretch(1)
self.innerBox.addLayout(self.leftBox) self.innerBox.addLayout(self.leftBox)
@@ -87,7 +84,7 @@ class GuiLipsum(NDialog):
self.formBox.addWidget(self.paraCount, 1, 1, 1, 1, QtAlignRight) self.formBox.addWidget(self.paraCount, 1, 1, 1, 1, QtAlignRight)
self.formBox.addWidget(self.randLabel, 2, 0, 1, 1, QtAlignLeft) self.formBox.addWidget(self.randLabel, 2, 0, 1, 1, QtAlignLeft)
self.formBox.addWidget(self.randSwitch, 2, 1, 1, 1, QtAlignRight) self.formBox.addWidget(self.randSwitch, 2, 1, 1, 1, QtAlignRight)
self.formBox.setVerticalSpacing(vSp) self.formBox.setVerticalSpacing(4)
self.formBox.setRowStretch(3, 1) self.formBox.setRowStretch(3, 1)
self.innerBox.addLayout(self.formBox) self.innerBox.addLayout(self.formBox)
@@ -96,17 +93,19 @@ class GuiLipsum(NDialog):
self.buttonBox.rejected.connect(self.reject) self.buttonBox.rejected.connect(self.reject)
self.btnClose = self.buttonBox.addButton(QtDialogClose) self.btnClose = self.buttonBox.addButton(QtDialogClose)
self.btnClose.setAutoDefault(False) if self.btnClose:
self.btnClose.setAutoDefault(False)
self.btnInsert = self.buttonBox.addButton(self.tr("Insert"), QtRoleAction) self.btnInsert = self.buttonBox.addButton(self.tr("Insert"), QtRoleAction)
self.btnInsert.clicked.connect(self._doInsert) if self.btnInsert:
self.btnInsert.setAutoDefault(False) self.btnInsert.clicked.connect(self._doInsert)
self.btnInsert.setAutoDefault(False)
# Assemble # Assemble
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
self.outerBox.addLayout(self.innerBox) self.outerBox.addLayout(self.innerBox)
self.outerBox.addWidget(self.buttonBox) self.outerBox.addWidget(self.buttonBox)
self.outerBox.setSpacing(CONFIG.pxInt(16)) self.outerBox.setSpacing(16)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
logger.debug("Ready: GuiLipsum") logger.debug("Ready: GuiLipsum")
+24 -35
View File
@@ -35,7 +35,7 @@ from PyQt6.QtWidgets import (
QPushButton, QSplitter, QVBoxLayout, QWidget QPushButton, QSplitter, QVBoxLayout, QWidget
) )
from novelwriter import CONFIG, SHARED from novelwriter import SHARED
from novelwriter.common import makeFileNameSafe, openExternalPath from novelwriter.common import makeFileNameSafe, openExternalPath
from novelwriter.constants import nwLabels from novelwriter.constants import nwLabels
from novelwriter.core.buildsettings import BuildSettings from novelwriter.core.buildsettings import BuildSettings
@@ -68,21 +68,16 @@ class GuiManuscriptBuild(NDialog):
self._build = build self._build = build
self.setWindowTitle(self.tr("Build Manuscript")) self.setWindowTitle(self.tr("Build Manuscript"))
self.setMinimumWidth(CONFIG.pxInt(500)) self.setMinimumWidth(500)
self.setMinimumHeight(CONFIG.pxInt(300)) self.setMinimumHeight(300)
iSz = SHARED.theme.baseIconSize iSz = SHARED.theme.baseIconSize
bSz = SHARED.theme.buttonIconSize bSz = SHARED.theme.buttonIconSize
sp4 = CONFIG.pxInt(4)
sp8 = CONFIG.pxInt(8)
sp16 = CONFIG.pxInt(16)
wWin = CONFIG.pxInt(620)
hWin = CONFIG.pxInt(360)
pOptions = SHARED.project.options pOptions = SHARED.project.options
self.resize( self.resize(
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "winWidth", wWin)), pOptions.getInt("GuiManuscriptBuild", "winWidth", 620),
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "winHeight", hWin)) pOptions.getInt("GuiManuscriptBuild", "winHeight", 360),
) )
# Output Format # Output Format
@@ -149,7 +144,7 @@ class GuiManuscriptBuild(NDialog):
self.pathBox = QHBoxLayout() self.pathBox = QHBoxLayout()
self.pathBox.addWidget(self.buildPath) self.pathBox.addWidget(self.buildPath)
self.pathBox.addWidget(self.btnBrowse) self.pathBox.addWidget(self.btnBrowse)
self.pathBox.setSpacing(sp8) self.pathBox.setSpacing(8)
# Build Name # Build Name
self.lblName = QLabel(self.tr("File Name"), self) self.lblName = QLabel(self.tr("File Name"), self)
@@ -160,14 +155,14 @@ class GuiManuscriptBuild(NDialog):
self.nameBox = QHBoxLayout() self.nameBox = QHBoxLayout()
self.nameBox.addWidget(self.buildName) self.nameBox.addWidget(self.buildName)
self.nameBox.addWidget(self.btnReset) self.nameBox.addWidget(self.btnReset)
self.nameBox.setSpacing(sp8) self.nameBox.setSpacing(8)
# Build Progress # Build Progress
self.buildProgress = NProgressSimple(self) self.buildProgress = NProgressSimple(self)
self.buildProgress.setMinimum(0) self.buildProgress.setMinimum(0)
self.buildProgress.setValue(0) self.buildProgress.setValue(0)
self.buildProgress.setTextVisible(False) self.buildProgress.setTextVisible(False)
self.buildProgress.setFixedHeight(sp8) self.buildProgress.setFixedHeight(8)
# Build Box # Build Box
self.buildBox = QGridLayout() self.buildBox = QGridLayout()
@@ -175,8 +170,8 @@ class GuiManuscriptBuild(NDialog):
self.buildBox.addLayout(self.pathBox, 0, 1) self.buildBox.addLayout(self.pathBox, 0, 1)
self.buildBox.addWidget(self.lblName, 1, 0) self.buildBox.addWidget(self.lblName, 1, 0)
self.buildBox.addLayout(self.nameBox, 1, 1) self.buildBox.addLayout(self.nameBox, 1, 1)
self.buildBox.setHorizontalSpacing(sp8) self.buildBox.setHorizontalSpacing(8)
self.buildBox.setVerticalSpacing(sp4) self.buildBox.setVerticalSpacing(4)
# Dialog Buttons # Dialog Buttons
self.buttonBox = QDialogButtonBox(self) self.buttonBox = QDialogButtonBox(self)
@@ -196,7 +191,8 @@ class GuiManuscriptBuild(NDialog):
self.buttonBox.addButton(self.btnBuild, QtRoleAction) self.buttonBox.addButton(self.btnBuild, QtRoleAction)
self.btnClose = self.buttonBox.addButton(QtDialogClose) self.btnClose = self.buttonBox.addButton(QtDialogClose)
self.btnClose.setAutoDefault(False) if self.btnClose:
self.btnClose.setAutoDefault(False)
# Assemble GUI # Assemble GUI
# ============ # ============
@@ -204,25 +200,25 @@ class GuiManuscriptBuild(NDialog):
self.mainSplit = QSplitter(self) self.mainSplit = QSplitter(self)
self.mainSplit.addWidget(self.formatWidget) self.mainSplit.addWidget(self.formatWidget)
self.mainSplit.addWidget(self.contentWidget) self.mainSplit.addWidget(self.contentWidget)
self.mainSplit.setHandleWidth(sp16) self.mainSplit.setHandleWidth(16)
self.mainSplit.setCollapsible(0, False) self.mainSplit.setCollapsible(0, False)
self.mainSplit.setCollapsible(1, False) self.mainSplit.setCollapsible(1, False)
self.mainSplit.setStretchFactor(0, 0) self.mainSplit.setStretchFactor(0, 0)
self.mainSplit.setStretchFactor(1, 1) self.mainSplit.setStretchFactor(1, 1)
self.mainSplit.setSizes([ self.mainSplit.setSizes([
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "fmtWidth", wWin//2)), pOptions.getInt("GuiManuscriptBuild", "fmtWidth", 360),
CONFIG.pxInt(pOptions.getInt("GuiManuscriptBuild", "sumWidth", wWin//2)), pOptions.getInt("GuiManuscriptBuild", "sumWidth", 360),
]) ])
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
self.outerBox.addWidget(self.lblMain, 0, QtAlignCenter) self.outerBox.addWidget(self.lblMain, 0, QtAlignCenter)
self.outerBox.addSpacing(sp16) self.outerBox.addSpacing(16)
self.outerBox.addWidget(self.mainSplit, 1) self.outerBox.addWidget(self.mainSplit, 1)
self.outerBox.addSpacing(sp4) self.outerBox.addSpacing(4)
self.outerBox.addWidget(self.buildProgress, 0) self.outerBox.addWidget(self.buildProgress, 0)
self.outerBox.addSpacing(sp4) self.outerBox.addSpacing(4)
self.outerBox.addLayout(self.buildBox, 0) self.outerBox.addLayout(self.buildBox, 0)
self.outerBox.addSpacing(sp16) self.outerBox.addSpacing(16)
self.outerBox.addWidget(self.buttonBox, 0) self.outerBox.addWidget(self.buttonBox, 0)
self.outerBox.setSpacing(0) self.outerBox.setSpacing(0)
@@ -363,21 +359,14 @@ class GuiManuscriptBuild(NDialog):
def _saveSettings(self) -> None: def _saveSettings(self) -> None:
"""Save the user GUI settings.""" """Save the user GUI settings."""
winWidth = CONFIG.rpxInt(self.width())
winHeight = CONFIG.rpxInt(self.height())
mainSplit = self.mainSplit.sizes()
fmtWidth = CONFIG.rpxInt(mainSplit[0])
sumWidth = CONFIG.rpxInt(mainSplit[1])
logger.debug("Saving State: GuiManuscriptBuild") logger.debug("Saving State: GuiManuscriptBuild")
mainSplit = self.mainSplit.sizes()
pOptions = SHARED.project.options pOptions = SHARED.project.options
pOptions.setValue("GuiManuscriptBuild", "winWidth", winWidth) pOptions.setValue("GuiManuscriptBuild", "winWidth", self.width())
pOptions.setValue("GuiManuscriptBuild", "winHeight", winHeight) pOptions.setValue("GuiManuscriptBuild", "winHeight", self.height())
pOptions.setValue("GuiManuscriptBuild", "fmtWidth", fmtWidth) pOptions.setValue("GuiManuscriptBuild", "fmtWidth", mainSplit[0])
pOptions.setValue("GuiManuscriptBuild", "sumWidth", sumWidth) pOptions.setValue("GuiManuscriptBuild", "sumWidth", mainSplit[1])
pOptions.saveSettings() pOptions.saveSettings()
return return
def _populateContentList(self) -> None: def _populateContentList(self) -> None:
+61 -74
View File
@@ -85,18 +85,16 @@ class GuiManuscript(NToolDialog):
self._buildMap: dict[str, QListWidgetItem] = {} self._buildMap: dict[str, QListWidgetItem] = {}
self.setWindowTitle(self.tr("Build Manuscript")) self.setWindowTitle(self.tr("Build Manuscript"))
self.setMinimumWidth(CONFIG.pxInt(600)) self.setMinimumWidth(600)
self.setMinimumHeight(CONFIG.pxInt(500)) self.setMinimumHeight(500)
iPx = SHARED.theme.baseIconHeight iPx = SHARED.theme.baseIconHeight
iSz = SHARED.theme.baseIconSize iSz = SHARED.theme.baseIconSize
wWin = CONFIG.pxInt(900)
hWin = CONFIG.pxInt(600)
pOptions = SHARED.project.options pOptions = SHARED.project.options
self.resize( self.resize(
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "winWidth", wWin)), pOptions.getInt("GuiManuscript", "winWidth", 900),
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "winHeight", hWin)) pOptions.getInt("GuiManuscript", "winHeight", 600),
) )
# Build Controls # Build Controls
@@ -153,9 +151,7 @@ class GuiManuscript(NToolDialog):
# ============ # ============
self.buildDetails = _DetailsWidget(self) self.buildDetails = _DetailsWidget(self)
self.buildDetails.setColumnWidth( self.buildDetails.setColumnWidth(pOptions.getInt("GuiManuscript", "detailsWidth", 100))
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "detailsWidth", 100)),
)
self.buildOutline = _OutlineWidget(self) self.buildOutline = _OutlineWidget(self)
@@ -168,8 +164,8 @@ class GuiManuscript(NToolDialog):
self.buildSplit.addWidget(self.buildList) self.buildSplit.addWidget(self.buildList)
self.buildSplit.addWidget(self.detailsTabs) self.buildSplit.addWidget(self.detailsTabs)
self.buildSplit.setSizes([ self.buildSplit.setSizes([
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "listHeight", 50)), pOptions.getInt("GuiManuscript", "listHeight", 50),
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "detailsHeight", 50)), pOptions.getInt("GuiManuscript", "detailsHeight", 50),
]) ])
# Process Controls # Process Controls
@@ -240,8 +236,8 @@ class GuiManuscript(NToolDialog):
self.mainSplit.setStretchFactor(0, 0) self.mainSplit.setStretchFactor(0, 0)
self.mainSplit.setStretchFactor(1, 1) self.mainSplit.setStretchFactor(1, 1)
self.mainSplit.setSizes([ self.mainSplit.setSizes([
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "optsWidth", wWin//4)), pOptions.getInt("GuiManuscript", "optsWidth", 225),
CONFIG.pxInt(pOptions.getInt("GuiManuscript", "viewWidth", 3*wWin//4)), pOptions.getInt("GuiManuscript", "viewWidth", 675),
]) ])
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
@@ -441,28 +437,20 @@ class GuiManuscript(NToolDialog):
self._builds.setBuildsState(lastBuild, buildOrder) self._builds.setBuildsState(lastBuild, buildOrder)
winWidth = CONFIG.rpxInt(self.width())
winHeight = CONFIG.rpxInt(self.height())
mainSplit = self.mainSplit.sizes() mainSplit = self.mainSplit.sizes()
optsWidth = CONFIG.rpxInt(mainSplit[0])
viewWidth = CONFIG.rpxInt(mainSplit[1])
buildSplit = self.buildSplit.sizes() buildSplit = self.buildSplit.sizes()
listHeight = CONFIG.rpxInt(buildSplit[0]) detailsWidth = self.buildDetails.getColumnWidth()
detailsHeight = CONFIG.rpxInt(buildSplit[1])
detailsWidth = CONFIG.rpxInt(self.buildDetails.getColumnWidth())
detailsExpanded = self.buildDetails.getExpandedState() detailsExpanded = self.buildDetails.getExpandedState()
showNewPage = self.swtNewPage.isChecked() showNewPage = self.swtNewPage.isChecked()
logger.debug("Saving State: GuiManuscript") logger.debug("Saving State: GuiManuscript")
pOptions = SHARED.project.options pOptions = SHARED.project.options
pOptions.setValue("GuiManuscript", "winWidth", winWidth) pOptions.setValue("GuiManuscript", "winWidth", self.width())
pOptions.setValue("GuiManuscript", "winHeight", winHeight) pOptions.setValue("GuiManuscript", "winHeight", self.height())
pOptions.setValue("GuiManuscript", "optsWidth", optsWidth) pOptions.setValue("GuiManuscript", "optsWidth", mainSplit[0])
pOptions.setValue("GuiManuscript", "viewWidth", viewWidth) pOptions.setValue("GuiManuscript", "viewWidth", mainSplit[1])
pOptions.setValue("GuiManuscript", "listHeight", listHeight) pOptions.setValue("GuiManuscript", "listHeight", buildSplit[0])
pOptions.setValue("GuiManuscript", "detailsHeight", detailsHeight) pOptions.setValue("GuiManuscript", "detailsHeight", buildSplit[1])
pOptions.setValue("GuiManuscript", "detailsWidth", detailsWidth) pOptions.setValue("GuiManuscript", "detailsWidth", detailsWidth)
pOptions.setValue("GuiManuscript", "detailsExpanded", detailsExpanded) pOptions.setValue("GuiManuscript", "detailsExpanded", detailsExpanded)
pOptions.setValue("GuiManuscript", "showNewPage", showNewPage) pOptions.setValue("GuiManuscript", "showNewPage", showNewPage)
@@ -693,33 +681,31 @@ class _OutlineWidget(QWidget):
hFont.setBold(True) hFont.setBold(True)
hFont.setUnderline(True) hFont.setUnderline(True)
root = self.listView.invisibleRootItem() if root := self.listView.invisibleRootItem():
parent = root parent = root
indent = False indent = False
for anchor, entry in data.items(): for anchor, entry in data.items():
prefix, _, text = entry.partition("|") prefix, _, text = entry.partition("|")
if prefix in ("TT", "PT", "CH", "SC", "H1", "H2"): if prefix in ("TT", "PT", "CH", "SC", "H1", "H2"):
item = QTreeWidgetItem([text]) item = QTreeWidgetItem([text])
item.setData(0, self.D_LINE, anchor) item.setData(0, self.D_LINE, anchor)
if prefix == "TT": if prefix == "TT":
item.setFont(0, tFont) item.setFont(0, tFont)
item.setForeground(0, tBrush) item.setForeground(0, tBrush)
root.addChild(item) root.addChild(item)
parent = root parent = root
elif prefix == "PT": elif prefix == "PT":
item.setFont(0, hFont) item.setFont(0, hFont)
root.addChild(item) root.addChild(item)
parent = root parent = root
elif prefix in ("CH", "H1"): elif prefix in ("CH", "H1"):
root.addChild(item) root.addChild(item)
parent = item parent = item
elif prefix in ("SC", "H2"): elif prefix in ("SC", "H2"):
parent.addChild(item) parent.addChild(item)
indent = True indent = True
self.listView.setIndentation( self.listView.setIndentation(SHARED.theme.baseIconHeight if indent else 4)
SHARED.theme.baseIconHeight if indent else CONFIG.pxInt(4)
)
self._outline = data self._outline = data
return return
@@ -754,7 +740,9 @@ class _PreviewWidget(QTextBrowser):
self.setOpenExternalLinks(False) self.setOpenExternalLinks(False)
self.setOpenLinks(False) self.setOpenLinks(False)
self.document().setDocumentMargin(CONFIG.textMargin) if document := self.document():
document.setDocumentMargin(CONFIG.textMargin)
self.setPlaceholderText(self.tr( self.setPlaceholderText(self.tr(
"Press the \"Preview\" button to generate ..." "Press the \"Preview\" button to generate ..."
)) ))
@@ -781,7 +769,7 @@ class _PreviewWidget(QTextBrowser):
self.ageLabel.setFixedHeight(int(2.1*SHARED.theme.fontPixelSize)) self.ageLabel.setFixedHeight(int(2.1*SHARED.theme.fontPixelSize))
# Progress # Progress
self.buildProgress = NProgressCircle(self, CONFIG.pxInt(160), CONFIG.pxInt(16)) self.buildProgress = NProgressCircle(self, 160, 16)
self.buildProgress.setVisible(False) self.buildProgress.setVisible(False)
self.buildProgress.setMaximum(1) self.buildProgress.setMaximum(1)
self.buildProgress.setValue(0) self.buildProgress.setValue(0)
@@ -834,7 +822,8 @@ class _PreviewWidget(QTextBrowser):
self.buildProgress.setValue(0) self.buildProgress.setValue(0)
self.buildProgress.setCentreText(None) self.buildProgress.setCentreText(None)
self.buildProgress.setVisible(True) self.buildProgress.setVisible(True)
self._scrollPos = self.verticalScrollBar().value() if vBar := self.verticalScrollBar():
self._scrollPos = vBar.value()
self.setPlaceholderText("") self.setPlaceholderText("")
self.clear() self.clear()
return return
@@ -883,10 +872,11 @@ class _PreviewWidget(QTextBrowser):
@pyqtSlot("QPrinter*") @pyqtSlot("QPrinter*")
def printPreview(self, printer: QPrinter) -> None: def printPreview(self, printer: QPrinter) -> None:
"""Connect the print preview painter to the document viewer.""" """Connect the print preview painter to the document viewer."""
QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor)) if document := self.document():
printer.setPageOrientation(QPageLayout.Orientation.Portrait) QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
self.document().print(printer) printer.setPageOrientation(QPageLayout.Orientation.Portrait)
QApplication.restoreOverrideCursor() document.print(printer)
QApplication.restoreOverrideCursor()
return return
@pyqtSlot(str) @pyqtSlot(str)
@@ -928,7 +918,8 @@ class _PreviewWidget(QTextBrowser):
def _postUpdate(self) -> None: def _postUpdate(self) -> None:
"""Run tasks after content update.""" """Run tasks after content update."""
self.buildProgress.setVisible(False) self.buildProgress.setVisible(False)
self.verticalScrollBar().setValue(self._scrollPos) if vBar := self.verticalScrollBar():
vBar.setValue(self._scrollPos)
return return
## ##
@@ -941,7 +932,7 @@ class _PreviewWidget(QTextBrowser):
""" """
vBar = self.verticalScrollBar() vBar = self.verticalScrollBar()
tB = self.frameWidth() tB = self.frameWidth()
vW = self.width() - 2*tB - vBar.width() vW = self.width() - 2*tB - (vBar.width() if vBar else 0)
vH = self.height() - 2*tB vH = self.height() - 2*tB
tH = self.ageLabel.height() tH = self.ageLabel.height()
pS = self.buildProgress.width() pS = self.buildProgress.width()
@@ -1033,10 +1024,6 @@ class _StatsWidget(QWidget):
def _buildBottomPanel(self) -> None: def _buildBottomPanel(self) -> None:
"""Build the bottom page.""" """Build the bottom page."""
mPx = CONFIG.pxInt(8)
hPx = CONFIG.pxInt(12)
vPx = CONFIG.pxInt(4)
trAllChars = trConst(nwLabels.STATS_NAME[nwStats.CHARS]) trAllChars = trConst(nwLabels.STATS_NAME[nwStats.CHARS])
trTextChars = trConst(nwLabels.STATS_NAME[nwStats.CHARS_TEXT]) trTextChars = trConst(nwLabels.STATS_NAME[nwStats.CHARS_TEXT])
trTitleChars = trConst(nwLabels.STATS_NAME[nwStats.CHARS_TITLE]) trTitleChars = trConst(nwLabels.STATS_NAME[nwStats.CHARS_TITLE])
@@ -1073,8 +1060,8 @@ class _StatsWidget(QWidget):
self.leftForm.addRow("", QLabel(self)) self.leftForm.addRow("", QLabel(self))
self.leftForm.addRow(trTitleCount, self.maxTitleCount) self.leftForm.addRow(trTitleCount, self.maxTitleCount)
self.leftForm.addRow(trParagraphCount, self.maxParCount) self.leftForm.addRow(trParagraphCount, self.maxParCount)
self.leftForm.setHorizontalSpacing(hPx) self.leftForm.setHorizontalSpacing(12)
self.leftForm.setVerticalSpacing(vPx) self.leftForm.setVerticalSpacing(4)
# Maximal Form, Right Column # Maximal Form, Right Column
self.maxTotalChars = QLabel(self) self.maxTotalChars = QLabel(self)
@@ -1098,25 +1085,25 @@ class _StatsWidget(QWidget):
self.rightForm.addRow(trAllWordChars, self.maxTotalWordChars) self.rightForm.addRow(trAllWordChars, self.maxTotalWordChars)
self.rightForm.addRow(trTitleWordChars, self.maxHeadWordChars) self.rightForm.addRow(trTitleWordChars, self.maxHeadWordChars)
self.rightForm.addRow(trTextWordChars, self.maxTextWordChars) self.rightForm.addRow(trTextWordChars, self.maxTextWordChars)
self.rightForm.setHorizontalSpacing(hPx) self.rightForm.setHorizontalSpacing(12)
self.rightForm.setVerticalSpacing(vPx) self.rightForm.setVerticalSpacing(4)
# Assemble # Assemble
self.minLayout = QHBoxLayout() self.minLayout = QHBoxLayout()
self.minLayout.addWidget(QLabel(trAllWords, self)) self.minLayout.addWidget(QLabel(trAllWords, self))
self.minLayout.addWidget(self.minWordCount) self.minLayout.addWidget(self.minWordCount)
self.minLayout.addSpacing(mPx) self.minLayout.addSpacing(8)
self.minLayout.addWidget(QLabel(trAllChars, self)) self.minLayout.addWidget(QLabel(trAllChars, self))
self.minLayout.addWidget(self.minCharCount) self.minLayout.addWidget(self.minCharCount)
self.minLayout.addStretch(1) self.minLayout.addStretch(1)
self.minLayout.setSpacing(mPx) self.minLayout.setSpacing(8)
self.minLayout.setContentsMargins(0, 0, 0, 0) self.minLayout.setContentsMargins(0, 0, 0, 0)
self.maxLayout = QHBoxLayout() self.maxLayout = QHBoxLayout()
self.maxLayout.addLayout(self.leftForm) self.maxLayout.addLayout(self.leftForm)
self.maxLayout.addLayout(self.rightForm) self.maxLayout.addLayout(self.rightForm)
self.maxLayout.addStretch(1) self.maxLayout.addStretch(1)
self.maxLayout.setSpacing(CONFIG.pxInt(32)) self.maxLayout.setSpacing(32)
self.maxLayout.setContentsMargins(0, 0, 0, 0) self.maxLayout.setContentsMargins(0, 0, 0, 0)
self.minWidget.setLayout(self.minLayout) self.minWidget.setLayout(self.minLayout)
+44 -54
View File
@@ -37,7 +37,7 @@ from PyQt6.QtWidgets import (
) )
from novelwriter import CONFIG, SHARED from novelwriter import CONFIG, SHARED
from novelwriter.common import describeFont, fontMatcher, qtLambda from novelwriter.common import describeFont, fontMatcher, qtAddAction, qtLambda
from novelwriter.constants import nwHeadFmt, nwKeyWords, nwLabels, nwStyles, trConst from novelwriter.constants import nwHeadFmt, nwKeyWords, nwLabels, nwStyles, trConst
from novelwriter.core.buildsettings import BuildSettings, FilterMode from novelwriter.core.buildsettings import BuildSettings, FilterMode
from novelwriter.extensions.configlayout import ( from novelwriter.extensions.configlayout import (
@@ -83,21 +83,18 @@ class GuiBuildSettings(NToolDialog):
self._build = build self._build = build
self.setWindowTitle(self.tr("Manuscript Build Settings")) self.setWindowTitle(self.tr("Manuscript Build Settings"))
self.setMinimumSize(CONFIG.pxInt(700), CONFIG.pxInt(400)) self.setMinimumSize(700, 400)
wWin = CONFIG.pxInt(750)
hWin = CONFIG.pxInt(550)
options = SHARED.project.options options = SHARED.project.options
self.resize( self.resize(
CONFIG.pxInt(options.getInt("GuiBuildSettings", "winWidth", wWin)), options.getInt("GuiBuildSettings", "winWidth", 750),
CONFIG.pxInt(options.getInt("GuiBuildSettings", "winHeight", hWin)) options.getInt("GuiBuildSettings", "winHeight", 550),
) )
# Title # Title
self.titleLabel = NColourLabel( self.titleLabel = NColourLabel(
self.tr("Manuscript Build Settings"), self, color=SHARED.theme.helpText, self.tr("Manuscript Build Settings"), self, color=SHARED.theme.helpText,
scale=NColourLabel.HEADER_SCALE, indent=CONFIG.pxInt(4) scale=NColourLabel.HEADER_SCALE, indent=4,
) )
# Settings Name # Settings Name
@@ -145,7 +142,7 @@ class GuiBuildSettings(NToolDialog):
self.outerBox.addLayout(self.topBox) self.outerBox.addLayout(self.topBox)
self.outerBox.addLayout(self.mainBox) self.outerBox.addLayout(self.mainBox)
self.outerBox.addWidget(self.buttonBox) self.outerBox.addWidget(self.buttonBox)
self.outerBox.setSpacing(CONFIG.pxInt(12)) self.outerBox.setSpacing(12)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
@@ -240,14 +237,11 @@ class GuiBuildSettings(NToolDialog):
def _saveSettings(self) -> None: def _saveSettings(self) -> None:
"""Save the various user settings.""" """Save the various user settings."""
winWidth = CONFIG.rpxInt(self.width())
winHeight = CONFIG.rpxInt(self.height())
treeWidth, filterWidth = self.optTabSelect.mainSplitSizes() treeWidth, filterWidth = self.optTabSelect.mainSplitSizes()
logger.debug("Saving State: GuiBuildSettings") logger.debug("Saving State: GuiBuildSettings")
pOptions = SHARED.project.options pOptions = SHARED.project.options
pOptions.setValue("GuiBuildSettings", "winWidth", winWidth) pOptions.setValue("GuiBuildSettings", "winWidth", self.width())
pOptions.setValue("GuiBuildSettings", "winHeight", winHeight) pOptions.setValue("GuiBuildSettings", "winHeight", self.height())
pOptions.setValue("GuiBuildSettings", "treeWidth", treeWidth) pOptions.setValue("GuiBuildSettings", "treeWidth", treeWidth)
pOptions.setValue("GuiBuildSettings", "filterWidth", filterWidth) pOptions.setValue("GuiBuildSettings", "filterWidth", filterWidth)
pOptions.saveSettings() pOptions.saveSettings()
@@ -300,7 +294,6 @@ class _FilterTab(NFixedPage):
iSz = SHARED.theme.baseIconSize iSz = SHARED.theme.baseIconSize
iPx = SHARED.theme.baseIconHeight iPx = SHARED.theme.baseIconHeight
cMg = CONFIG.pxInt(6)
# Tree Widget # Tree Widget
self.optTree = QTreeWidget(self) self.optTree = QTreeWidget(self)
@@ -311,14 +304,14 @@ class _FilterTab(NFixedPage):
self.optTree.setIndentation(iPx) self.optTree.setIndentation(iPx)
self.optTree.setColumnCount(3) self.optTree.setColumnCount(3)
treeHeader = self.optTree.header() if header := self.optTree.header():
treeHeader.setStretchLastSection(False) header.setStretchLastSection(False)
treeHeader.setMinimumSectionSize(iPx + cMg) # See Issue #1551 header.setMinimumSectionSize(iPx + 6) # See Issue #1551
treeHeader.setSectionResizeMode(self.C_NAME, QtHeaderStretch) header.setSectionResizeMode(self.C_NAME, QtHeaderStretch)
treeHeader.setSectionResizeMode(self.C_ACTIVE, QtHeaderFixed) header.setSectionResizeMode(self.C_ACTIVE, QtHeaderFixed)
treeHeader.setSectionResizeMode(self.C_STATUS, QtHeaderFixed) header.setSectionResizeMode(self.C_STATUS, QtHeaderFixed)
treeHeader.resizeSection(self.C_ACTIVE, iPx + cMg) header.resizeSection(self.C_ACTIVE, iPx + 6)
treeHeader.resizeSection(self.C_STATUS, iPx + cMg) header.resizeSection(self.C_STATUS, iPx + 6)
self.optTree.setDragDropMode(QAbstractItemView.DragDropMode.NoDragDrop) self.optTree.setDragDropMode(QAbstractItemView.DragDropMode.NoDragDrop)
self.optTree.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection) self.optTree.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
@@ -347,7 +340,7 @@ class _FilterTab(NFixedPage):
self.modeBox.addWidget(self.includedButton) self.modeBox.addWidget(self.includedButton)
self.modeBox.addWidget(self.excludedButton) self.modeBox.addWidget(self.excludedButton)
self.modeBox.addWidget(self.resetButton) self.modeBox.addWidget(self.resetButton)
self.modeBox.setSpacing(CONFIG.pxInt(4)) self.modeBox.setSpacing(4)
# Filer Options # Filer Options
self.filterOpt = NSwitchBox(self, iPx) self.filterOpt = NSwitchBox(self, iPx)
@@ -375,8 +368,8 @@ class _FilterTab(NFixedPage):
self.mainSplit.setStretchFactor(0, 1) self.mainSplit.setStretchFactor(0, 1)
self.mainSplit.setStretchFactor(1, 0) self.mainSplit.setStretchFactor(1, 0)
self.mainSplit.setSizes([ self.mainSplit.setSizes([
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "treeWidth", 300)), pOptions.getInt("GuiBuildSettings", "treeWidth", 300),
CONFIG.pxInt(pOptions.getInt("GuiBuildSettings", "filterWidth", 300)) pOptions.getInt("GuiBuildSettings", "filterWidth", 300),
]) ])
self.setCentralWidget(self.mainSplit) self.setCentralWidget(self.mainSplit)
@@ -393,7 +386,7 @@ class _FilterTab(NFixedPage):
"""Extract the sizes of the main splitter.""" """Extract the sizes of the main splitter."""
sizes = self.mainSplit.sizes() sizes = self.mainSplit.sizes()
m, n = (sizes[0], sizes[1]) if len(sizes) >= 2 else (0, 0) m, n = (sizes[0], sizes[1]) if len(sizes) >= 2 else (0, 0)
return CONFIG.rpxInt(m), CONFIG.rpxInt(n) return m, n
## ##
# Slots # Slots
@@ -558,15 +551,12 @@ class _HeadingsTab(NScrollablePage):
iPx = SHARED.theme.baseIconHeight iPx = SHARED.theme.baseIconHeight
iSz = SHARED.theme.baseIconSize iSz = SHARED.theme.baseIconSize
sSp = CONFIG.pxInt(16)
vSp = CONFIG.pxInt(12)
bSp = CONFIG.pxInt(6)
trHide = self.tr("Hide") trHide = self.tr("Hide")
# Format Boxes # Format Boxes
# ============ # ============
self.formatBox = QGridLayout() self.formatBox = QGridLayout()
self.formatBox.setHorizontalSpacing(bSp) self.formatBox.setHorizontalSpacing(6)
# Title Heading # Title Heading
self.lblPart = QLabel(self._build.getLabel("headings.fmtPart"), self) self.lblPart = QLabel(self._build.getLabel("headings.fmtPart"), self)
@@ -575,7 +565,7 @@ class _HeadingsTab(NScrollablePage):
self.btnPart = NIconToolButton(self, iSz, "edit", "green") self.btnPart = NIconToolButton(self, iSz, "edit", "green")
self.btnPart.clicked.connect(qtLambda(self._editHeading, self.EDIT_TITLE)) self.btnPart.clicked.connect(qtLambda(self._editHeading, self.EDIT_TITLE))
self.hdePart = QLabel(trHide, self) self.hdePart = QLabel(trHide, self)
self.hdePart.setIndent(bSp) self.hdePart.setIndent(6)
self.swtPart = NSwitch(self, height=iPx) self.swtPart = NSwitch(self, height=iPx)
self.formatBox.addWidget(self.lblPart, 0, 0) self.formatBox.addWidget(self.lblPart, 0, 0)
@@ -591,7 +581,7 @@ class _HeadingsTab(NScrollablePage):
self.btnChapter = NIconToolButton(self, iSz, "edit", "green") self.btnChapter = NIconToolButton(self, iSz, "edit", "green")
self.btnChapter.clicked.connect(qtLambda(self._editHeading, self.EDIT_CHAPTER)) self.btnChapter.clicked.connect(qtLambda(self._editHeading, self.EDIT_CHAPTER))
self.hdeChapter = QLabel(trHide, self) self.hdeChapter = QLabel(trHide, self)
self.hdeChapter.setIndent(bSp) self.hdeChapter.setIndent(6)
self.swtChapter = NSwitch(self, height=iPx) self.swtChapter = NSwitch(self, height=iPx)
self.formatBox.addWidget(self.lblChapter, 1, 0) self.formatBox.addWidget(self.lblChapter, 1, 0)
@@ -607,7 +597,7 @@ class _HeadingsTab(NScrollablePage):
self.btnUnnumbered = NIconToolButton(self, iSz, "edit", "green") self.btnUnnumbered = NIconToolButton(self, iSz, "edit", "green")
self.btnUnnumbered.clicked.connect(qtLambda(self._editHeading, self.EDIT_UNNUM)) self.btnUnnumbered.clicked.connect(qtLambda(self._editHeading, self.EDIT_UNNUM))
self.hdeUnnumbered = QLabel(trHide, self) self.hdeUnnumbered = QLabel(trHide, self)
self.hdeUnnumbered.setIndent(bSp) self.hdeUnnumbered.setIndent(6)
self.swtUnnumbered = NSwitch(self, height=iPx) self.swtUnnumbered = NSwitch(self, height=iPx)
self.formatBox.addWidget(self.lblUnnumbered, 2, 0) self.formatBox.addWidget(self.lblUnnumbered, 2, 0)
@@ -623,7 +613,7 @@ class _HeadingsTab(NScrollablePage):
self.btnScene = NIconToolButton(self, iSz, "edit", "green") self.btnScene = NIconToolButton(self, iSz, "edit", "green")
self.btnScene.clicked.connect(qtLambda(self._editHeading, self.EDIT_SCENE)) self.btnScene.clicked.connect(qtLambda(self._editHeading, self.EDIT_SCENE))
self.hdeScene = QLabel(trHide, self) self.hdeScene = QLabel(trHide, self)
self.hdeScene.setIndent(bSp) self.hdeScene.setIndent(6)
self.swtScene = NSwitch(self, height=iPx) self.swtScene = NSwitch(self, height=iPx)
self.formatBox.addWidget(self.lblScene, 3, 0) self.formatBox.addWidget(self.lblScene, 3, 0)
@@ -639,7 +629,7 @@ class _HeadingsTab(NScrollablePage):
self.btnAScene = NIconToolButton(self, iSz, "edit", "green") self.btnAScene = NIconToolButton(self, iSz, "edit", "green")
self.btnAScene.clicked.connect(qtLambda(self._editHeading, self.EDIT_HSCENE)) self.btnAScene.clicked.connect(qtLambda(self._editHeading, self.EDIT_HSCENE))
self.hdeAScene = QLabel(trHide, self) self.hdeAScene = QLabel(trHide, self)
self.hdeAScene.setIndent(bSp) self.hdeAScene.setIndent(6)
self.swtAScene = NSwitch(self, height=iPx) self.swtAScene = NSwitch(self, height=iPx)
self.formatBox.addWidget(self.lblAScene, 4, 0) self.formatBox.addWidget(self.lblAScene, 4, 0)
@@ -655,7 +645,7 @@ class _HeadingsTab(NScrollablePage):
self.btnSection = NIconToolButton(self, iSz, "edit", "green") self.btnSection = NIconToolButton(self, iSz, "edit", "green")
self.btnSection.clicked.connect(qtLambda(self._editHeading, self.EDIT_SECTION)) self.btnSection.clicked.connect(qtLambda(self._editHeading, self.EDIT_SECTION))
self.hdeSection = QLabel(trHide, self) self.hdeSection = QLabel(trHide, self)
self.hdeSection.setIndent(bSp) self.hdeSection.setIndent(6)
self.swtSection = NSwitch(self, height=iPx) self.swtSection = NSwitch(self, height=iPx)
self.formatBox.addWidget(self.lblSection, 5, 0) self.formatBox.addWidget(self.lblSection, 5, 0)
@@ -675,16 +665,16 @@ class _HeadingsTab(NScrollablePage):
self.formSyntax = _HeadingSyntaxHighlighter(self.editTextBox.document()) self.formSyntax = _HeadingSyntaxHighlighter(self.editTextBox.document())
self.menuInsert = QMenu(self) self.mInsert = QMenu(self)
self.aInsTitle = self.menuInsert.addAction(self.tr("Title")) self.aInsTitle = qtAddAction(self.mInsert, self.tr("Title"))
self.aInsChNum = self.menuInsert.addAction(self.tr("Chapter Number")) self.aInsChNum = qtAddAction(self.mInsert, self.tr("Chapter Number"))
self.aInsChWord = self.menuInsert.addAction(self.tr("Chapter Number (Word)")) self.aInsChWord = qtAddAction(self.mInsert, self.tr("Chapter Number (Word)"))
self.aInsChRomU = self.menuInsert.addAction(self.tr("Chapter Number (Upper Case Roman)")) self.aInsChRomU = qtAddAction(self.mInsert, self.tr("Chapter Number (Upper Case Roman)"))
self.aInsChRomL = self.menuInsert.addAction(self.tr("Chapter Number (Lower Case Roman)")) self.aInsChRomL = qtAddAction(self.mInsert, self.tr("Chapter Number (Lower Case Roman)"))
self.aInsScNum = self.menuInsert.addAction(self.tr("Scene Number (In Chapter)")) self.aInsScNum = qtAddAction(self.mInsert, self.tr("Scene Number (In Chapter)"))
self.aInsScAbs = self.menuInsert.addAction(self.tr("Scene Number (Absolute)")) self.aInsScAbs = qtAddAction(self.mInsert, self.tr("Scene Number (Absolute)"))
self.aInsCharPOV = self.menuInsert.addAction(self.tr("Point of View Character")) self.aInsCharPOV = qtAddAction(self.mInsert, self.tr("Point of View Character"))
self.aInsCharFocus = self.menuInsert.addAction(self.tr("Focus Character")) self.aInsCharFocus = qtAddAction(self.mInsert, self.tr("Focus Character"))
self.aInsTitle.triggered.connect(qtLambda(self._insertIntoForm, nwHeadFmt.TITLE)) self.aInsTitle.triggered.connect(qtLambda(self._insertIntoForm, nwHeadFmt.TITLE))
self.aInsChNum.triggered.connect(qtLambda(self._insertIntoForm, nwHeadFmt.CH_NUM)) self.aInsChNum.triggered.connect(qtLambda(self._insertIntoForm, nwHeadFmt.CH_NUM))
@@ -697,7 +687,7 @@ class _HeadingsTab(NScrollablePage):
self.aInsCharFocus.triggered.connect(qtLambda(self._insertIntoForm, nwHeadFmt.CHAR_FOCUS)) self.aInsCharFocus.triggered.connect(qtLambda(self._insertIntoForm, nwHeadFmt.CHAR_FOCUS))
self.btnInsert = QPushButton(self.tr("Insert"), self) self.btnInsert = QPushButton(self.tr("Insert"), self)
self.btnInsert.setMenu(self.menuInsert) self.btnInsert.setMenu(self.mInsert)
self.btnApply = QPushButton(self.tr("Apply"), self) self.btnApply = QPushButton(self.tr("Apply"), self)
self.btnApply.clicked.connect(self._saveFormat) self.btnApply.clicked.connect(self._saveFormat)
@@ -715,8 +705,8 @@ class _HeadingsTab(NScrollablePage):
# Layout Matrix # Layout Matrix
# ============= # =============
self.layoutMatrix = QGridLayout() self.layoutMatrix = QGridLayout()
self.layoutMatrix.setVerticalSpacing(vSp) self.layoutMatrix.setVerticalSpacing(12)
self.layoutMatrix.setHorizontalSpacing(vSp) self.layoutMatrix.setHorizontalSpacing(12)
self.layoutMatrix.addWidget(QLabel(self.tr("Centre"), self), 0, 1) self.layoutMatrix.addWidget(QLabel(self.tr("Centre"), self), 0, 1)
self.layoutMatrix.addWidget(QLabel(self.tr("Page Break"), self), 0, 2) self.layoutMatrix.addWidget(QLabel(self.tr("Page Break"), self), 0, 2)
@@ -764,9 +754,9 @@ class _HeadingsTab(NScrollablePage):
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
self.outerBox.addLayout(self.formatBox) self.outerBox.addLayout(self.formatBox)
self.outerBox.addSpacing(sSp) self.outerBox.addSpacing(16)
self.outerBox.addLayout(self.editFormBox) self.outerBox.addLayout(self.editFormBox)
self.outerBox.addSpacing(sSp) self.outerBox.addSpacing(16)
self.outerBox.addLayout(self.layoutMatrix) self.outerBox.addLayout(self.layoutMatrix)
self.outerBox.addStretch(1) self.outerBox.addStretch(1)
@@ -904,7 +894,7 @@ class _HeadingsTab(NScrollablePage):
class _HeadingSyntaxHighlighter(QSyntaxHighlighter): class _HeadingSyntaxHighlighter(QSyntaxHighlighter):
def __init__(self, document: QTextDocument) -> None: def __init__(self, document: QTextDocument | None) -> None:
super().__init__(document) super().__init__(document)
syntax = SHARED.theme.syntaxTheme syntax = SHARED.theme.syntaxTheme
self._fmtSymbol = QTextCharFormat() self._fmtSymbol = QTextCharFormat()
@@ -1223,7 +1213,7 @@ class _FormattingTab(NScrollableForm):
# Header # Header
self.odtPageHeader = QLineEdit(self) self.odtPageHeader = QLineEdit(self)
self.odtPageHeader.setMinimumWidth(CONFIG.pxInt(200)) self.odtPageHeader.setMinimumWidth(200)
self.btnPageHeader = NIconToolButton(self, iSz, "revert", "green") self.btnPageHeader = NIconToolButton(self, iSz, "revert", "green")
self.btnPageHeader.clicked.connect(self._resetPageHeader) self.btnPageHeader.clicked.connect(self._resetPageHeader)
self.addRow( self.addRow(
+32 -50
View File
@@ -34,7 +34,7 @@ from PyQt6.QtWidgets import (
QVBoxLayout, QWidget QVBoxLayout, QWidget
) )
from novelwriter import CONFIG, SHARED from novelwriter import SHARED
from novelwriter.common import formatTime, numberToRoman from novelwriter.common import formatTime, numberToRoman
from novelwriter.constants import nwUnicode from novelwriter.constants import nwUnicode
from novelwriter.extensions.configlayout import NColourLabel, NFixedPage, NScrollablePage from novelwriter.extensions.configlayout import NColourLabel, NFixedPage, NScrollablePage
@@ -60,16 +60,16 @@ class GuiNovelDetails(NNonBlockingDialog):
self.setWindowTitle(self.tr("Novel Details")) self.setWindowTitle(self.tr("Novel Details"))
options = SHARED.project.options options = SHARED.project.options
self.setMinimumSize(CONFIG.pxInt(500), CONFIG.pxInt(400)) self.setMinimumSize(500, 400)
self.resize( self.resize(
CONFIG.pxInt(options.getInt("GuiNovelDetails", "winWidth", CONFIG.pxInt(650))), options.getInt("GuiNovelDetails", "winWidth", 650),
CONFIG.pxInt(options.getInt("GuiNovelDetails", "winHeight", CONFIG.pxInt(500))) options.getInt("GuiNovelDetails", "winHeight", 500),
) )
# Title # Title
self.titleLabel = NColourLabel( self.titleLabel = NColourLabel(
self.tr("Novel Details"), self, color=SHARED.theme.helpText, self.tr("Novel Details"), self, color=SHARED.theme.helpText,
scale=NColourLabel.HEADER_SCALE, indent=CONFIG.pxInt(4) scale=NColourLabel.HEADER_SCALE, indent=4,
) )
# Novel Selector # Novel Selector
@@ -114,7 +114,7 @@ class GuiNovelDetails(NNonBlockingDialog):
self.outerBox.addLayout(self.topBox) self.outerBox.addLayout(self.topBox)
self.outerBox.addLayout(self.mainBox) self.outerBox.addLayout(self.mainBox)
self.outerBox.addWidget(self.buttonBox) self.outerBox.addWidget(self.buttonBox)
self.outerBox.setSpacing(CONFIG.pxInt(8)) self.outerBox.setSpacing(8)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
self.setSizeGripEnabled(True) self.setSizeGripEnabled(True)
@@ -172,18 +172,13 @@ class GuiNovelDetails(NNonBlockingDialog):
def _saveSettings(self) -> None: def _saveSettings(self) -> None:
"""Save the user GUI settings.""" """Save the user GUI settings."""
winWidth = CONFIG.rpxInt(self.width())
winHeight = CONFIG.rpxInt(self.height())
novelRoot = self.novelSelector.handle
logger.debug("Saving State: GuiNovelDetails") logger.debug("Saving State: GuiNovelDetails")
novelRoot = self.novelSelector.handle
options = SHARED.project.options options = SHARED.project.options
options.setValue("GuiNovelDetails", "winWidth", winWidth) options.setValue("GuiNovelDetails", "winWidth", self.width())
options.setValue("GuiNovelDetails", "winHeight", winHeight) options.setValue("GuiNovelDetails", "winHeight", self.height())
options.setValue("GuiNovelDetails", "novelRoot", novelRoot) options.setValue("GuiNovelDetails", "novelRoot", novelRoot)
self.contentsPage.saveSettings() self.contentsPage.saveSettings()
return return
@@ -192,11 +187,6 @@ class _OverviewPage(NScrollablePage):
def __init__(self, parent: QWidget) -> None: def __init__(self, parent: QWidget) -> None:
super().__init__(parent=parent) super().__init__(parent=parent)
mPx = CONFIG.pxInt(8)
sPx = CONFIG.pxInt(16)
hPx = CONFIG.pxInt(24)
vPx = CONFIG.pxInt(4)
# Project Info # Project Info
self.projLabel = NColourLabel( self.projLabel = NColourLabel(
self.tr("Project"), self, color=SHARED.theme.helpText, self.tr("Project"), self, color=SHARED.theme.helpText,
@@ -217,9 +207,9 @@ class _OverviewPage(NScrollablePage):
self.projForm.addRow("<b>{0}</b>".format(self.tr("Word Count")), self.projWords) self.projForm.addRow("<b>{0}</b>".format(self.tr("Word Count")), self.projWords)
self.projForm.addRow("<b>\u2026 {0}</b>".format(self.tr("In Novels")), self.projNovels) self.projForm.addRow("<b>\u2026 {0}</b>".format(self.tr("In Novels")), self.projNovels)
self.projForm.addRow("<b>\u2026 {0}</b>".format(self.tr("In Notes")), self.projNotes) self.projForm.addRow("<b>\u2026 {0}</b>".format(self.tr("In Notes")), self.projNotes)
self.projForm.setContentsMargins(mPx, 0, 0, 0) self.projForm.setContentsMargins(8, 0, 0, 0)
self.projForm.setHorizontalSpacing(hPx) self.projForm.setHorizontalSpacing(24)
self.projForm.setVerticalSpacing(vPx) self.projForm.setVerticalSpacing(4)
# Novel Info # Novel Info
self.novelLabel = NColourLabel( self.novelLabel = NColourLabel(
@@ -237,9 +227,9 @@ class _OverviewPage(NScrollablePage):
self.novelForm.addRow("<b>{0}</b>".format(self.tr("Word Count")), self.novelWords) self.novelForm.addRow("<b>{0}</b>".format(self.tr("Word Count")), self.novelWords)
self.novelForm.addRow("<b>{0}</b>".format(self.tr("Chapters")), self.novelChapters) self.novelForm.addRow("<b>{0}</b>".format(self.tr("Chapters")), self.novelChapters)
self.novelForm.addRow("<b>{0}</b>".format(self.tr("Scenes")), self.novelScenes) self.novelForm.addRow("<b>{0}</b>".format(self.tr("Scenes")), self.novelScenes)
self.novelForm.setContentsMargins(mPx, 0, 0, 0) self.novelForm.setContentsMargins(8, 0, 0, 0)
self.novelForm.setHorizontalSpacing(hPx) self.novelForm.setHorizontalSpacing(24)
self.novelForm.setVerticalSpacing(vPx) self.novelForm.setVerticalSpacing(4)
# Assemble # Assemble
self.outerBox = QVBoxLayout() self.outerBox = QVBoxLayout()
@@ -247,7 +237,7 @@ class _OverviewPage(NScrollablePage):
self.outerBox.addLayout(self.projForm) self.outerBox.addLayout(self.projForm)
self.outerBox.addWidget(self.novelLabel) self.outerBox.addWidget(self.novelLabel)
self.outerBox.addLayout(self.novelForm) self.outerBox.addLayout(self.novelForm)
self.outerBox.setSpacing(sPx) self.outerBox.setSpacing(16)
self.outerBox.addStretch(1) self.outerBox.addStretch(1)
self.setCentralLayout(self.outerBox) self.setCentralLayout(self.outerBox)
@@ -309,8 +299,6 @@ class _ContentsPage(NFixedPage):
iPx = SHARED.theme.baseIconHeight iPx = SHARED.theme.baseIconHeight
iSz = SHARED.theme.baseIconSize iSz = SHARED.theme.baseIconSize
hPx = CONFIG.pxInt(12)
vPx = CONFIG.pxInt(4)
options = SHARED.project.options options = SHARED.project.options
# Title # Title
@@ -341,22 +329,22 @@ class _ContentsPage(NFixedPage):
treeHeadItem.setTextAlignment(self.C_PAGE, QtAlignRight) treeHeadItem.setTextAlignment(self.C_PAGE, QtAlignRight)
treeHeadItem.setTextAlignment(self.C_PROG, QtAlignRight) treeHeadItem.setTextAlignment(self.C_PROG, QtAlignRight)
treeHeader = self.tocTree.header() if header := self.tocTree.header():
treeHeader.setStretchLastSection(True) header.setStretchLastSection(True)
treeHeader.setMinimumSectionSize(hPx) header.setMinimumSectionSize(12)
wCol0 = CONFIG.pxInt(options.getInt("GuiNovelDetails", "widthCol0", 200)) wCol0 = options.getInt("GuiNovelDetails", "widthCol0", 200)
wCol1 = CONFIG.pxInt(options.getInt("GuiNovelDetails", "widthCol1", 60)) wCol1 = options.getInt("GuiNovelDetails", "widthCol1", 60)
wCol2 = CONFIG.pxInt(options.getInt("GuiNovelDetails", "widthCol2", 60)) wCol2 = options.getInt("GuiNovelDetails", "widthCol2", 60)
wCol3 = CONFIG.pxInt(options.getInt("GuiNovelDetails", "widthCol3", 60)) wCol3 = options.getInt("GuiNovelDetails", "widthCol3", 60)
wCol4 = CONFIG.pxInt(options.getInt("GuiNovelDetails", "widthCol4", 90)) wCol4 = options.getInt("GuiNovelDetails", "widthCol4", 90)
self.tocTree.setColumnWidth(0, wCol0) self.tocTree.setColumnWidth(0, wCol0)
self.tocTree.setColumnWidth(1, wCol1) self.tocTree.setColumnWidth(1, wCol1)
self.tocTree.setColumnWidth(2, wCol2) self.tocTree.setColumnWidth(2, wCol2)
self.tocTree.setColumnWidth(3, wCol3) self.tocTree.setColumnWidth(3, wCol3)
self.tocTree.setColumnWidth(4, wCol4) self.tocTree.setColumnWidth(4, wCol4)
self.tocTree.setColumnWidth(5, hPx) self.tocTree.setColumnWidth(5, 12)
# Options # Options
wordsPerPage = options.getInt("GuiNovelDetails", "wordsPerPage", 350) wordsPerPage = options.getInt("GuiNovelDetails", "wordsPerPage", 350)
@@ -394,8 +382,8 @@ class _ContentsPage(NFixedPage):
self.optionsBox.addWidget(self.dblValue, 0, 4) self.optionsBox.addWidget(self.dblValue, 0, 4)
self.optionsBox.addWidget(self.poLabel, 1, 0) self.optionsBox.addWidget(self.poLabel, 1, 0)
self.optionsBox.addWidget(self.poValue, 1, 1) self.optionsBox.addWidget(self.poValue, 1, 1)
self.optionsBox.setHorizontalSpacing(hPx) self.optionsBox.setHorizontalSpacing(12)
self.optionsBox.setVerticalSpacing(vPx) self.optionsBox.setVerticalSpacing(4)
self.optionsBox.setColumnStretch(2, 1) self.optionsBox.setColumnStretch(2, 1)
# Assemble # Assemble
@@ -410,18 +398,12 @@ class _ContentsPage(NFixedPage):
def saveSettings(self) -> None: def saveSettings(self) -> None:
"""Save the user GUI settings.""" """Save the user GUI settings."""
widthCol0 = CONFIG.rpxInt(self.tocTree.columnWidth(0))
widthCol1 = CONFIG.rpxInt(self.tocTree.columnWidth(1))
widthCol2 = CONFIG.rpxInt(self.tocTree.columnWidth(2))
widthCol3 = CONFIG.rpxInt(self.tocTree.columnWidth(3))
widthCol4 = CONFIG.rpxInt(self.tocTree.columnWidth(4))
options = SHARED.project.options options = SHARED.project.options
options.setValue("GuiNovelDetails", "widthCol0", widthCol0) options.setValue("GuiNovelDetails", "widthCol0", self.tocTree.columnWidth(0))
options.setValue("GuiNovelDetails", "widthCol1", widthCol1) options.setValue("GuiNovelDetails", "widthCol1", self.tocTree.columnWidth(1))
options.setValue("GuiNovelDetails", "widthCol2", widthCol2) options.setValue("GuiNovelDetails", "widthCol2", self.tocTree.columnWidth(2))
options.setValue("GuiNovelDetails", "widthCol3", widthCol3) options.setValue("GuiNovelDetails", "widthCol3", self.tocTree.columnWidth(3))
options.setValue("GuiNovelDetails", "widthCol4", widthCol4) options.setValue("GuiNovelDetails", "widthCol4", self.tocTree.columnWidth(4))
options.setValue("GuiNovelDetails", "wordsPerPage", self.wpValue.value()) options.setValue("GuiNovelDetails", "wordsPerPage", self.wpValue.value())
options.setValue("GuiNovelDetails", "countFrom", self.poValue.value()) options.setValue("GuiNovelDetails", "countFrom", self.poValue.value())
options.setValue("GuiNovelDetails", "clearDouble", self.dblValue.isChecked()) options.setValue("GuiNovelDetails", "clearDouble", self.dblValue.isChecked())
+26 -37
View File
@@ -40,7 +40,7 @@ from PyQt6.QtWidgets import (
) )
from novelwriter import CONFIG, SHARED from novelwriter import CONFIG, SHARED
from novelwriter.common import cssCol, formatInt, makeFileNameSafe, qtLambda from novelwriter.common import cssCol, formatInt, makeFileNameSafe, qtAddAction, qtLambda
from novelwriter.constants import nwFiles from novelwriter.constants import nwFiles
from novelwriter.core.coretools import ProjectBuilder from novelwriter.core.coretools import ProjectBuilder
from novelwriter.enum import nwItemClass from novelwriter.enum import nwItemClass
@@ -66,29 +66,21 @@ class GuiWelcome(NDialog):
self.setObjectName("GuiWelcome") self.setObjectName("GuiWelcome")
self.setWindowTitle(self.tr("Welcome")) self.setWindowTitle(self.tr("Welcome"))
self.setMinimumWidth(CONFIG.pxInt(650)) self.setMinimumWidth(650)
self.setMinimumHeight(CONFIG.pxInt(450)) self.setMinimumHeight(450)
hA = CONFIG.pxInt(8)
hB = CONFIG.pxInt(16)
hC = CONFIG.pxInt(24)
hD = CONFIG.pxInt(36)
hE = CONFIG.pxInt(48)
hF = CONFIG.pxInt(128)
btnIconSize = SHARED.theme.buttonIconSize
self._hPx = CONFIG.pxInt(600)
self.resize(*CONFIG.welcomeWinSize) self.resize(*CONFIG.welcomeWinSize)
btnIconSize = SHARED.theme.buttonIconSize
# Elements # Elements
# ======== # ========
self.bgImage = SHARED.theme.loadDecoration("welcome") self.bgImage = SHARED.theme.loadDecoration("welcome")
self.nwImage = SHARED.theme.loadDecoration("nw-text", h=hD) self.nwImage = SHARED.theme.loadDecoration("nw-text", h=36)
self.bgColor = QColor(54, 54, 54) if SHARED.theme.isDarkTheme else QColor(255, 255, 255) self.bgColor = QColor(54, 54, 54) if SHARED.theme.isDarkTheme else QColor(255, 255, 255)
self.nwLogo = QLabel(self) self.nwLogo = QLabel(self)
self.nwLogo.setPixmap(SHARED.theme.getPixmap("novelwriter", (hF, hF))) self.nwLogo.setPixmap(SHARED.theme.getPixmap("novelwriter", (128, 128)))
self.nwLabel = QLabel(self) self.nwLabel = QLabel(self)
self.nwLabel.setPixmap(self.nwImage) self.nwLabel.setPixmap(self.nwImage)
@@ -152,18 +144,18 @@ class GuiWelcome(NDialog):
# ======== # ========
self.innerBox = QVBoxLayout() self.innerBox = QVBoxLayout()
self.innerBox.addSpacing(hB) self.innerBox.addSpacing(16)
self.innerBox.addWidget(self.nwLabel) self.innerBox.addWidget(self.nwLabel)
self.innerBox.addWidget(self.nwInfo) self.innerBox.addWidget(self.nwInfo)
self.innerBox.addSpacing(hA) self.innerBox.addSpacing(8)
self.innerBox.addWidget(self.mainStack) self.innerBox.addWidget(self.mainStack)
self.innerBox.addSpacing(hB) self.innerBox.addSpacing(16)
self.innerBox.addLayout(self.btnBox) self.innerBox.addLayout(self.btnBox)
self.outerBox = QHBoxLayout() self.outerBox = QHBoxLayout()
self.outerBox.addWidget(self.nwLogo, 3, QtAlignRightTop) self.outerBox.addWidget(self.nwLogo, 3, QtAlignRightTop)
self.outerBox.addLayout(self.innerBox, 9) self.outerBox.addLayout(self.innerBox, 9)
self.outerBox.setContentsMargins(hF, hE, hC, hE) self.outerBox.setContentsMargins(128, 48, 24, 48)
self.setLayout(self.outerBox) self.setLayout(self.outerBox)
self.setSizeGripEnabled(True) self.setSizeGripEnabled(True)
@@ -183,7 +175,7 @@ class GuiWelcome(NDialog):
def paintEvent(self, event: QPaintEvent) -> None: def paintEvent(self, event: QPaintEvent) -> None:
"""Overload the paint event to draw the background image.""" """Overload the paint event to draw the background image."""
hWin = self.height() hWin = self.height()
hPix = min(hWin, self._hPx) hPix = min(hWin, 600)
tMode = Qt.TransformationMode.SmoothTransformation tMode = Qt.TransformationMode.SmoothTransformation
painter = QPainter(self) painter = QPainter(self)
painter.fillRect(self.rect(), self.bgColor) painter.fillRect(self.rect(), self.bgColor)
@@ -309,11 +301,10 @@ class _OpenProjectPage(QWidget):
self._selectFirstItem() self._selectFirstItem()
mPx = CONFIG.pxInt(4)
baseCol = cssCol(self.palette().base().color(), PANEL_ALPHA) baseCol = cssCol(self.palette().base().color(), PANEL_ALPHA)
self.setStyleSheet( self.setStyleSheet(
f"QListView {{border: none; background: {baseCol};}} " f"QListView {{border: none; background: {baseCol};}} "
f"QLineEdit {{border: none; background: {baseCol}; padding: {mPx}px;}} " f"QLineEdit {{border: none; background: {baseCol}; padding: 4px;}} "
) )
return return
@@ -370,9 +361,9 @@ class _OpenProjectPage(QWidget):
"""Open the custom context menu.""" """Open the custom context menu."""
ctxMenu = QMenu(self) ctxMenu = QMenu(self)
ctxMenu.setObjectName("ContextMenu") # Used for testing ctxMenu.setObjectName("ContextMenu") # Used for testing
action = ctxMenu.addAction(self.tr("Open Project")) action = qtAddAction(ctxMenu, self.tr("Open Project"))
action.triggered.connect(self.openSelectedItem) action.triggered.connect(self.openSelectedItem)
action = ctxMenu.addAction(self.tr("Remove Project")) action = qtAddAction(ctxMenu, self.tr("Remove Project"))
action.triggered.connect(self._deleteSelectedItem) action.triggered.connect(self._deleteSelectedItem)
ctxMenu.exec(self.mapToGlobal(pos)) ctxMenu.exec(self.mapToGlobal(pos))
ctxMenu.deleteLater() ctxMenu.deleteLater()
@@ -400,11 +391,10 @@ class _ProjectListItem(QStyledItemDelegate):
fPx = SHARED.theme.fontPixelSize fPx = SHARED.theme.fontPixelSize
fPt = SHARED.theme.fontPointSize fPt = SHARED.theme.fontPointSize
tPx = round(1.2 * fPx) tPx = round(1.2 * fPx)
mPx = CONFIG.pxInt(4)
iPx = tPx + fPx iPx = tPx + fPx
self._pPx = (mPx//2, 3*mPx//2, iPx + mPx, mPx, mPx + tPx) # Painter coordinates self._pPx = (iPx + 4, tPx + 4) # Painter coordinates
self._hPx = 2*mPx + tPx + fPx # Fixed height self._hPx = 8 + tPx + fPx # Fixed height
self._tFont = QApplication.font() self._tFont = QApplication.font()
self._tFont.setPointSizeF(1.2*fPt) self._tFont.setPointSizeF(1.2*fPt)
@@ -423,7 +413,7 @@ class _ProjectListItem(QStyledItemDelegate):
rect = opt.rect rect = opt.rect
title, _, details = index.data() title, _, details = index.data()
tFlag = Qt.TextFlag.TextSingleLine tFlag = Qt.TextFlag.TextSingleLine
ix, iy, x, y1, y2 = self._pPx x, y = self._pPx
painter.save() painter.save()
if opt.state & QtSelected == QtSelected: if opt.state & QtSelected == QtSelected:
@@ -431,12 +421,12 @@ class _ProjectListItem(QStyledItemDelegate):
painter.fillRect(rect, QApplication.palette().highlight()) painter.fillRect(rect, QApplication.palette().highlight())
painter.setOpacity(1.0) painter.setOpacity(1.0)
painter.drawPixmap(ix, rect.top() + iy, self._icon) painter.drawPixmap(2, rect.top() + 6, self._icon)
painter.setFont(self._tFont) painter.setFont(self._tFont)
painter.drawText(rect.adjusted(x, y1, 0, 0), tFlag, title) painter.drawText(rect.adjusted(x, 4, 0, 0), tFlag, title)
painter.setFont(self._dFont) painter.setFont(self._dFont)
painter.setPen(self._dPen) painter.setPen(self._dPen)
painter.drawText(rect.adjusted(x, y2, 0, 0), tFlag, details) painter.drawText(rect.adjusted(x, y, 0, 0), tFlag, details)
painter.restore() painter.restore()
return return
@@ -557,7 +547,6 @@ class _NewProjectForm(QWidget):
iPx = SHARED.theme.baseIconHeight iPx = SHARED.theme.baseIconHeight
iSz = SHARED.theme.baseIconSize iSz = SHARED.theme.baseIconSize
sPx = CONFIG.pxInt(16)
# Project Settings # Project Settings
# ================ # ================
@@ -592,15 +581,15 @@ class _NewProjectForm(QWidget):
self.fillMenu = QMenu(self.browseFill) self.fillMenu = QMenu(self.browseFill)
self.fillBlank = self.fillMenu.addAction(self.tr("Create a fresh project")) self.fillBlank = qtAddAction(self.fillMenu, self.tr("Create a fresh project"))
self.fillBlank.setIcon(SHARED.theme.getIcon("document")) self.fillBlank.setIcon(SHARED.theme.getIcon("document"))
self.fillBlank.triggered.connect(self._setFillBlank) self.fillBlank.triggered.connect(self._setFillBlank)
self.fillSample = self.fillMenu.addAction(self.tr("Create an example project")) self.fillSample = qtAddAction(self.fillMenu, self.tr("Create an example project"))
self.fillSample.setIcon(SHARED.theme.getIcon("document_add", "blue")) self.fillSample.setIcon(SHARED.theme.getIcon("document_add", "blue"))
self.fillSample.triggered.connect(self._setFillSample) self.fillSample.triggered.connect(self._setFillSample)
self.fillCopy = self.fillMenu.addAction(self.tr("Copy an existing project")) self.fillCopy = qtAddAction(self.fillMenu, self.tr("Copy an existing project"))
self.fillCopy.setIcon(SHARED.theme.getIcon("project_copy", "green")) self.fillCopy.setIcon(SHARED.theme.getIcon("project_copy", "green"))
self.fillCopy.triggered.connect(self._setFillCopy) self.fillCopy.triggered.connect(self._setFillCopy)
@@ -675,7 +664,7 @@ class _NewProjectForm(QWidget):
self.extraBox = QVBoxLayout() self.extraBox = QVBoxLayout()
self.extraBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Chapters and Scenes")), self)) self.extraBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Chapters and Scenes")), self))
self.extraBox.addLayout(self.novelForm) self.extraBox.addLayout(self.novelForm)
self.extraBox.addSpacing(sPx) self.extraBox.addSpacing(16)
self.extraBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Project Notes")), self)) self.extraBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Project Notes")), self))
self.extraBox.addLayout(self.notesForm) self.extraBox.addLayout(self.notesForm)
self.extraBox.setContentsMargins(0, 0, 0, 0) self.extraBox.setContentsMargins(0, 0, 0, 0)
@@ -687,7 +676,7 @@ class _NewProjectForm(QWidget):
self.formBox = QVBoxLayout() self.formBox = QVBoxLayout()
self.formBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Create New Project")), self)) self.formBox.addWidget(QLabel("<b>{0}</b>".format(self.tr("Create New Project")), self))
self.formBox.addLayout(self.projectForm) self.formBox.addLayout(self.projectForm)
self.formBox.addSpacing(sPx) self.formBox.addSpacing(16)
self.formBox.addWidget(self.extraWidget) self.formBox.addWidget(self.extraWidget)
self.formBox.addStretch(1) self.formBox.addStretch(1)
+32 -43
View File
@@ -82,26 +82,18 @@ class GuiWritingStats(NToolDialog):
pOptions = SHARED.project.options pOptions = SHARED.project.options
self.setWindowTitle(self.tr("Writing Statistics")) self.setWindowTitle(self.tr("Writing Statistics"))
self.setMinimumWidth(CONFIG.pxInt(420)) self.setMinimumWidth(420)
self.setMinimumHeight(CONFIG.pxInt(400)) self.setMinimumHeight(400)
self.resize( self.resize(
CONFIG.pxInt(pOptions.getInt("GuiWritingStats", "winWidth", 550)), pOptions.getInt("GuiWritingStats", "winWidth", 550),
CONFIG.pxInt(pOptions.getInt("GuiWritingStats", "winHeight", 500)) pOptions.getInt("GuiWritingStats", "winHeight", 500),
) )
# List Box # List Box
wCol0 = CONFIG.pxInt( wCol0 = pOptions.getInt("GuiWritingStats", "widthCol0", 180)
pOptions.getInt("GuiWritingStats", "widthCol0", 180) wCol1 = pOptions.getInt("GuiWritingStats", "widthCol1", 80)
) wCol2 = pOptions.getInt("GuiWritingStats", "widthCol2", 80)
wCol1 = CONFIG.pxInt( wCol3 = pOptions.getInt("GuiWritingStats", "widthCol3", 80)
pOptions.getInt("GuiWritingStats", "widthCol1", 80)
)
wCol2 = CONFIG.pxInt(
pOptions.getInt("GuiWritingStats", "widthCol2", 80)
)
wCol3 = CONFIG.pxInt(
pOptions.getInt("GuiWritingStats", "widthCol3", 80)
)
self.listBox = QTreeWidget(self) self.listBox = QTreeWidget(self)
self.listBox.setHeaderLabels([ self.listBox.setHeaderLabels([
@@ -133,7 +125,6 @@ class GuiWritingStats(NToolDialog):
# Word Bar # Word Bar
self.barHeight = int(round(0.5*SHARED.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 = QPixmap(self.barHeight, self.barHeight)
self.barImage.fill(self.palette().highlight().color()) self.barImage.fill(self.palette().highlight().color())
@@ -262,25 +253,27 @@ class GuiWritingStats(NToolDialog):
self.optsBox.addWidget(self.histMax, 0) self.optsBox.addWidget(self.histMax, 0)
# Buttons # Buttons
self.saveJSON = QAction(self.tr("JSON Data File (.json)"), self)
self.saveJSON.triggered.connect(qtLambda(self._saveData, self.FMT_JSON))
self.saveCSV = QAction(self.tr("CSV Data File (.csv)"), self)
self.saveCSV.triggered.connect(qtLambda(self._saveData, self.FMT_CSV))
self.saveMenu = QMenu(self)
self.saveMenu.addAction(self.saveJSON)
self.saveMenu.addAction(self.saveCSV)
self.buttonBox = QDialogButtonBox(self) self.buttonBox = QDialogButtonBox(self)
self.buttonBox.rejected.connect(self._doClose) self.buttonBox.rejected.connect(self._doClose)
self.btnClose = self.buttonBox.addButton(QtDialogClose) self.btnClose = self.buttonBox.addButton(QtDialogClose)
self.btnClose.setAutoDefault(False) if self.btnClose:
self.btnClose.setAutoDefault(False)
self.btnSave = self.buttonBox.addButton(self.tr("Save As"), QtRoleAction) self.btnSave = self.buttonBox.addButton(self.tr("Save As"), QtRoleAction)
self.btnSave.setAutoDefault(False) if self.btnSave:
self.btnSave.setAutoDefault(False)
self.saveMenu = QMenu(self) self.btnSave.setMenu(self.saveMenu)
self.btnSave.setMenu(self.saveMenu)
self.saveJSON = QAction(self.tr("JSON Data File (.json)"), self)
self.saveJSON.triggered.connect(qtLambda(self._saveData, self.FMT_JSON))
self.saveMenu.addAction(self.saveJSON)
self.saveCSV = QAction(self.tr("CSV Data File (.csv)"), self)
self.saveCSV.triggered.connect(qtLambda(self._saveData, self.FMT_CSV))
self.saveMenu.addAction(self.saveCSV)
# Assemble # Assemble
self.outerBox = QGridLayout() self.outerBox = QGridLayout()
@@ -328,14 +321,10 @@ class GuiWritingStats(NToolDialog):
"""Save the state of the window, clear cache, end close.""" """Save the state of the window, clear cache, end close."""
self.logData = [] self.logData = []
winWidth = CONFIG.rpxInt(self.width()) header = self.listBox.header()
winHeight = CONFIG.rpxInt(self.height())
widthCol0 = CONFIG.rpxInt(self.listBox.columnWidth(0))
widthCol1 = CONFIG.rpxInt(self.listBox.columnWidth(1))
widthCol2 = CONFIG.rpxInt(self.listBox.columnWidth(2))
widthCol3 = CONFIG.rpxInt(self.listBox.columnWidth(3))
sortCol = self.listBox.sortColumn() sortCol = self.listBox.sortColumn()
sortOrder = self.listBox.header().sortIndicatorOrder() sortOrder = header.sortIndicatorOrder() if header else 0
incNovel = self.incNovel.isChecked() incNovel = self.incNovel.isChecked()
incNotes = self.incNotes.isChecked() incNotes = self.incNotes.isChecked()
hideZeros = self.hideZeros.isChecked() hideZeros = self.hideZeros.isChecked()
@@ -346,12 +335,12 @@ class GuiWritingStats(NToolDialog):
logger.debug("Saving State: GuiWritingStats") logger.debug("Saving State: GuiWritingStats")
pOptions = SHARED.project.options pOptions = SHARED.project.options
pOptions.setValue("GuiWritingStats", "winWidth", winWidth) pOptions.setValue("GuiWritingStats", "winWidth", self.width())
pOptions.setValue("GuiWritingStats", "winHeight", winHeight) pOptions.setValue("GuiWritingStats", "winHeight", self.height())
pOptions.setValue("GuiWritingStats", "widthCol0", widthCol0) pOptions.setValue("GuiWritingStats", "widthCol0", self.listBox.columnWidth(0))
pOptions.setValue("GuiWritingStats", "widthCol1", widthCol1) pOptions.setValue("GuiWritingStats", "widthCol1", self.listBox.columnWidth(1))
pOptions.setValue("GuiWritingStats", "widthCol2", widthCol2) pOptions.setValue("GuiWritingStats", "widthCol2", self.listBox.columnWidth(2))
pOptions.setValue("GuiWritingStats", "widthCol3", widthCol3) pOptions.setValue("GuiWritingStats", "widthCol3", self.listBox.columnWidth(3))
pOptions.setValue("GuiWritingStats", "sortCol", sortCol) pOptions.setValue("GuiWritingStats", "sortCol", sortCol)
pOptions.setValue("GuiWritingStats", "sortOrder", sortOrder) pOptions.setValue("GuiWritingStats", "sortOrder", sortOrder)
pOptions.setValue("GuiWritingStats", "incNovel", incNovel) pOptions.setValue("GuiWritingStats", "incNovel", incNovel)