Improve section headings on filter tab

This commit is contained in:
Veronica Berglyd Olsen
2023-08-06 15:39:30 +02:00
parent c480db898c
commit 7a74165221
2 changed files with 38 additions and 38 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ SETTINGS_TEMPLATE = {
} }
SETTINGS_LABELS = { SETTINGS_LABELS = {
"filter": QT_TRANSLATE_NOOP("Builds", "Document Types"), "filter": QT_TRANSLATE_NOOP("Builds", "Document Filters"),
"filter.includeNovel": QT_TRANSLATE_NOOP("Builds", "Novel Documents"), "filter.includeNovel": QT_TRANSLATE_NOOP("Builds", "Novel Documents"),
"filter.includeNotes": QT_TRANSLATE_NOOP("Builds", "Project Notes"), "filter.includeNotes": QT_TRANSLATE_NOOP("Builds", "Project Notes"),
"filter.includeInactive": QT_TRANSLATE_NOOP("Builds", "Inactive Documents"), "filter.includeInactive": QT_TRANSLATE_NOOP("Builds", "Inactive Documents"),
+37 -37
View File
@@ -69,7 +69,7 @@ class GuiBuildSettings(QDialog):
newSettingsReady = pyqtSignal(BuildSettings) newSettingsReady = pyqtSignal(BuildSettings)
def __init__(self, parent: QWidget, mainGui: GuiMain, build: BuildSettings): def __init__(self, parent: QWidget, mainGui: GuiMain, build: BuildSettings) -> None:
super().__init__(parent=parent) super().__init__(parent=parent)
logger.debug("Create: GuiBuildSettings") logger.debug("Create: GuiBuildSettings")
@@ -169,10 +169,10 @@ class GuiBuildSettings(QDialog):
return return
def __del__(self): # pragma: no cover def __del__(self) -> None: # pragma: no cover
logger.debug("Delete: GuiBuildSettings") logger.debug("Delete: GuiBuildSettings")
def loadContent(self): def loadContent(self) -> None:
"""Populate the child widgets.""" """Populate the child widgets."""
self.editBuildName.setText(self._build.name) self.editBuildName.setText(self._build.name)
self.optTabSelect.loadContent() self.optTabSelect.loadContent()
@@ -187,7 +187,7 @@ class GuiBuildSettings(QDialog):
## ##
@pyqtSlot(int) @pyqtSlot(int)
def _stackPageSelected(self, pageId: int): def _stackPageSelected(self, pageId: int) -> None:
"""Process a user request to switch page.""" """Process a user request to switch page."""
if pageId == self.OPT_FILTERS: if pageId == self.OPT_FILTERS:
self.toolStack.setCurrentWidget(self.optTabSelect) self.toolStack.setCurrentWidget(self.optTabSelect)
@@ -202,7 +202,7 @@ class GuiBuildSettings(QDialog):
return return
@pyqtSlot("QAbstractButton*") @pyqtSlot("QAbstractButton*")
def _dialogButtonClicked(self, button: QAbstractButton): def _dialogButtonClicked(self, button: QAbstractButton) -> None:
"""Handle button clicks from the dialog button box.""" """Handle button clicks from the dialog button box."""
role = self.dlgButtons.buttonRole(button) role = self.dlgButtons.buttonRole(button)
if role == QDialogButtonBox.ApplyRole: if role == QDialogButtonBox.ApplyRole:
@@ -218,7 +218,7 @@ class GuiBuildSettings(QDialog):
# Events # Events
## ##
def closeEvent(self, event: QEvent): def closeEvent(self, event: QEvent) -> None:
"""Capture the user closing the window so we can save """Capture the user closing the window so we can save
settings. settings.
""" """
@@ -233,7 +233,7 @@ class GuiBuildSettings(QDialog):
# Internal Functions # Internal Functions
## ##
def _askToSaveBuild(self): def _askToSaveBuild(self) -> None:
"""Check if there are unsaved changes, and if there are, ask if """Check if there are unsaved changes, and if there are, ask if
it's ok to reject them. it's ok to reject them.
""" """
@@ -247,7 +247,7 @@ class GuiBuildSettings(QDialog):
self._build.resetChangedState() self._build.resetChangedState()
return return
def _saveSettings(self): def _saveSettings(self) -> None:
"""Save the various user settings.""" """Save the various user settings."""
logger.debug("Saving GuiBuildSettings settings") logger.debug("Saving GuiBuildSettings settings")
@@ -265,7 +265,7 @@ class GuiBuildSettings(QDialog):
return return
def _emitBuildData(self): def _emitBuildData(self) -> None:
"""Assemble the build data and emit the signal.""" """Assemble the build data and emit the signal."""
self._build.setName(self.editBuildName.text()) self._build.setName(self.editBuildName.text())
self.optTabHeadings.saveContent() self.optTabHeadings.saveContent()
@@ -294,7 +294,7 @@ class _FilterTab(QWidget):
F_INCLUDED = 2 F_INCLUDED = 2
F_EXCLUDED = 3 F_EXCLUDED = 3
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings): def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
super().__init__(parent=buildMain) super().__init__(parent=buildMain)
self.mainGui = buildMain.mainGui self.mainGui = buildMain.mainGui
@@ -401,7 +401,7 @@ class _FilterTab(QWidget):
return return
def loadContent(self): def loadContent(self) -> None:
"""Populate the widgets.""" """Populate the widgets."""
self._populateTree() self._populateTree()
self._populateFilters() self._populateFilters()
@@ -418,7 +418,7 @@ class _FilterTab(QWidget):
## ##
@pyqtSlot(str, bool) @pyqtSlot(str, bool)
def _applyFilterSwitch(self, key: str, state: bool): def _applyFilterSwitch(self, key: str, state: bool) -> None:
"""Apply filter switch and update the settings.""" """Apply filter switch and update the settings."""
if key.startswith("doc:"): if key.startswith("doc:"):
self._build.setValue(key[4:], state) self._build.setValue(key[4:], state)
@@ -432,7 +432,7 @@ class _FilterTab(QWidget):
# Internal Functions # Internal Functions
## ##
def _populateTree(self): def _populateTree(self) -> None:
"""Build the tree of project items.""" """Build the tree of project items."""
logger.debug("Building project tree") logger.debug("Building project tree")
self._treeMap = {} self._treeMap = {}
@@ -486,7 +486,7 @@ class _FilterTab(QWidget):
return return
def _populateFilters(self): def _populateFilters(self) -> None:
"""Populate the filter options switches.""" """Populate the filter options switches."""
self.filterOpt.clear() self.filterOpt.clear()
self.filterOpt.addLabel(self._build.getLabel("filter")) self.filterOpt.addLabel(self._build.getLabel("filter"))
@@ -512,7 +512,7 @@ class _FilterTab(QWidget):
self.filterOpt.addSeparator() self.filterOpt.addSeparator()
# Root Classes # Root Classes
self.filterOpt.addLabel(self.tr("Root Folders")) self.filterOpt.addLabel(self.tr("Select Root Folders"))
for tHandle, nwItem in self.theProject.tree.iterRoots(None): for tHandle, nwItem in self.theProject.tree.iterRoots(None):
if not nwItem.isInactiveClass(): if not nwItem.isInactiveClass():
itemIcon = self.mainTheme.getItemIcon( itemIcon = self.mainTheme.getItemIcon(
@@ -525,7 +525,7 @@ class _FilterTab(QWidget):
return return
def _setSelectedMode(self, mode: int): def _setSelectedMode(self, mode: int) -> None:
"""Set the mode for the selected items.""" """Set the mode for the selected items."""
for item in self.optTree.selectedItems(): for item in self.optTree.selectedItems():
if isinstance(item, QTreeWidgetItem): if isinstance(item, QTreeWidgetItem):
@@ -543,7 +543,7 @@ class _FilterTab(QWidget):
return return
def _setTreeItemMode(self): def _setTreeItemMode(self) -> None:
"""Update the filtered mode icon on all items.""" """Update the filtered mode icon on all items."""
filtered = self._build.buildItemFilter(self.theProject) filtered = self._build.buildItemFilter(self.theProject)
for tHandle, item in self._treeMap.items(): for tHandle, item in self._treeMap.items():
@@ -569,7 +569,7 @@ class _HeadingsTab(QWidget):
EDIT_SCENE = 4 EDIT_SCENE = 4
EDIT_SECTION = 5 EDIT_SECTION = 5
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings): def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
super().__init__(parent=buildMain) super().__init__(parent=buildMain)
self.mainGui = buildMain.mainGui self.mainGui = buildMain.mainGui
@@ -747,7 +747,7 @@ class _HeadingsTab(QWidget):
return return
def loadContent(self): def loadContent(self) -> None:
"""Populate the widgets.""" """Populate the widgets."""
self.fmtTitle.setText(self._build.getStr("headings.fmtTitle")) self.fmtTitle.setText(self._build.getStr("headings.fmtTitle"))
self.fmtChapter.setText(self._build.getStr("headings.fmtChapter")) self.fmtChapter.setText(self._build.getStr("headings.fmtChapter"))
@@ -758,7 +758,7 @@ class _HeadingsTab(QWidget):
self.swtSection.setChecked(self._build.getBool("headings.hideSection")) self.swtSection.setChecked(self._build.getBool("headings.hideSection"))
return return
def saveContent(self): def saveContent(self) -> None:
"""Save choices back into build object.""" """Save choices back into build object."""
self._build.setValue("headings.hideScene", self.swtScene.isChecked()) self._build.setValue("headings.hideScene", self.swtScene.isChecked())
self._build.setValue("headings.hideSection", self.swtSection.isChecked()) self._build.setValue("headings.hideSection", self.swtSection.isChecked())
@@ -768,7 +768,7 @@ class _HeadingsTab(QWidget):
# Internal Functions # Internal Functions
## ##
def _insertIntoForm(self, text: str): def _insertIntoForm(self, text: str) -> None:
"""Insert formatting text from the dropdown menu.""" """Insert formatting text from the dropdown menu."""
if self._editing > 0: if self._editing > 0:
cursor = self.editTextBox.textCursor() cursor = self.editTextBox.textCursor()
@@ -776,7 +776,7 @@ class _HeadingsTab(QWidget):
self.editTextBox.setFocus() self.editTextBox.setFocus()
return return
def _editHeading(self, heading: int): def _editHeading(self, heading: int) -> None:
"""Populate the form with a specific heading format.""" """Populate the form with a specific heading format."""
self._editing = heading self._editing = heading
self.editTextBox.setEnabled(True) self.editTextBox.setEnabled(True)
@@ -810,7 +810,7 @@ class _HeadingsTab(QWidget):
# Private Slots # Private Slots
## ##
def _saveFormat(self): def _saveFormat(self) -> None:
"""Save the format from the edit text box.""" """Save the format from the edit text box."""
heading = self._editing heading = self._editing
text = self.editTextBox.toPlainText().strip().replace("\n", "//") text = self.editTextBox.toPlainText().strip().replace("\n", "//")
@@ -842,7 +842,7 @@ class _HeadingsTab(QWidget):
class _HeadingSyntaxHighlighter(QSyntaxHighlighter): class _HeadingSyntaxHighlighter(QSyntaxHighlighter):
def __init__(self, document: QTextDocument, mainTheme: GuiTheme): def __init__(self, document: QTextDocument, mainTheme: GuiTheme) -> None:
super().__init__(document) super().__init__(document)
self._fmtSymbol = QTextCharFormat() self._fmtSymbol = QTextCharFormat()
self._fmtSymbol.setForeground(QColor(*mainTheme.colHead)) self._fmtSymbol.setForeground(QColor(*mainTheme.colHead))
@@ -850,7 +850,7 @@ class _HeadingSyntaxHighlighter(QSyntaxHighlighter):
self._fmtFormat.setForeground(QColor(*mainTheme.colEmph)) self._fmtFormat.setForeground(QColor(*mainTheme.colEmph))
return return
def highlightBlock(self, text: str): def highlightBlock(self, text: str) -> None:
"""Add syntax highlighting to the text block.""" """Add syntax highlighting to the text block."""
for heading in nwHeadFmt.ALL: for heading in nwHeadFmt.ALL:
pos = text.find(heading) pos = text.find(heading)
@@ -868,7 +868,7 @@ class _HeadingSyntaxHighlighter(QSyntaxHighlighter):
class _ContentTab(QWidget): class _ContentTab(QWidget):
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings): def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
super().__init__(parent=buildMain) super().__init__(parent=buildMain)
self.mainGui = buildMain.mainGui self.mainGui = buildMain.mainGui
@@ -917,7 +917,7 @@ class _ContentTab(QWidget):
return return
def loadContent(self): def loadContent(self) -> None:
"""Populate the widgets.""" """Populate the widgets."""
self.incSynopsis.setChecked(self._build.getBool("text.includeSynopsis")) self.incSynopsis.setChecked(self._build.getBool("text.includeSynopsis"))
self.incComments.setChecked(self._build.getBool("text.includeComments")) self.incComments.setChecked(self._build.getBool("text.includeComments"))
@@ -926,7 +926,7 @@ class _ContentTab(QWidget):
self.addNoteHead.setChecked(self._build.getBool("text.addNoteHeadings")) self.addNoteHead.setChecked(self._build.getBool("text.addNoteHeadings"))
return return
def saveContent(self): def saveContent(self) -> None:
"""Save choices back into build object.""" """Save choices back into build object."""
self._build.setValue("text.includeSynopsis", self.incSynopsis.isChecked()) self._build.setValue("text.includeSynopsis", self.incSynopsis.isChecked())
self._build.setValue("text.includeComments", self.incComments.isChecked()) self._build.setValue("text.includeComments", self.incComments.isChecked())
@@ -940,7 +940,7 @@ class _ContentTab(QWidget):
class _FormatTab(QWidget): class _FormatTab(QWidget):
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings): def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
super().__init__(parent=buildMain) super().__init__(parent=buildMain)
self.buildMain = buildMain self.buildMain = buildMain
@@ -1085,7 +1085,7 @@ class _FormatTab(QWidget):
return return
def loadContent(self): def loadContent(self) -> None:
"""Populate the widgets.""" """Populate the widgets."""
langIdx = self.buildLang.findData(self._build.getStr("format.buildLang")) langIdx = self.buildLang.findData(self._build.getStr("format.buildLang"))
if langIdx != -1: if langIdx != -1:
@@ -1128,7 +1128,7 @@ class _FormatTab(QWidget):
return return
def saveContent(self): def saveContent(self) -> None:
"""Save choices back into build object.""" """Save choices back into build object."""
self._build.setValue("format.buildLang", str(self.buildLang.currentData())) self._build.setValue("format.buildLang", str(self.buildLang.currentData()))
self._build.setValue("format.textFont", self.textFont.text()) self._build.setValue("format.textFont", self.textFont.text())
@@ -1154,7 +1154,7 @@ class _FormatTab(QWidget):
## ##
@pyqtSlot() @pyqtSlot()
def _selectFont(self): def _selectFont(self) -> None:
"""Open the QFontDialog and set a font for the font style.""" """Open the QFontDialog and set a font for the font style."""
currFont = QFont() currFont = QFont()
currFont.setFamily(self.textFont.text()) currFont.setFamily(self.textFont.text())
@@ -1166,7 +1166,7 @@ class _FormatTab(QWidget):
return return
@pyqtSlot(int) @pyqtSlot(int)
def _changeUnit(self, index: int): def _changeUnit(self, index: int) -> None:
"""The current unit change, so recalculate sizes.""" """The current unit change, so recalculate sizes."""
newUnit = self.pageUnit.itemData(index) newUnit = self.pageUnit.itemData(index)
newScale = nwLabels.UNIT_SCALE.get(newUnit, 1.0) newScale = nwLabels.UNIT_SCALE.get(newUnit, 1.0)
@@ -1220,7 +1220,7 @@ class _FormatTab(QWidget):
return return
@pyqtSlot(int) @pyqtSlot(int)
def _changePageSize(self, index: int): def _changePageSize(self, index: int) -> None:
"""The page size has changed.""" """The page size has changed."""
self.pageWidth.setEnabled(True) self.pageWidth.setEnabled(True)
self.pageHeight.setEnabled(True) self.pageHeight.setEnabled(True)
@@ -1239,7 +1239,7 @@ class _FormatTab(QWidget):
class _OutputTab(QWidget): class _OutputTab(QWidget):
def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings): def __init__(self, buildMain: GuiBuildSettings, build: BuildSettings) -> None:
super().__init__(parent=buildMain) super().__init__(parent=buildMain)
self.mainGui = buildMain.mainGui self.mainGui = buildMain.mainGui
@@ -1282,13 +1282,13 @@ class _OutputTab(QWidget):
return return
def loadContent(self): def loadContent(self) -> None:
"""Populate the widgets.""" """Populate the widgets."""
self.odtAddColours.setChecked(self._build.getBool("odt.addColours")) self.odtAddColours.setChecked(self._build.getBool("odt.addColours"))
self.htmlAddStyles.setChecked(self._build.getBool("html.addStyles")) self.htmlAddStyles.setChecked(self._build.getBool("html.addStyles"))
return return
def saveContent(self): def saveContent(self) -> None:
"""Save choices back into build object.""" """Save choices back into build object."""
self._build.setValue("odt.addColours", self.odtAddColours.isChecked()) self._build.setValue("odt.addColours", self.odtAddColours.isChecked())
self._build.setValue("html.addStyles", self.htmlAddStyles.isChecked()) self._build.setValue("html.addStyles", self.htmlAddStyles.isChecked())