From aa84d998a0f93d8b00194323ddd2845630635311 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Thu, 6 Feb 2025 17:24:31 +0100 Subject: [PATCH] Move project tree preferences to their own section --- novelwriter/constants.py | 2 +- novelwriter/dialogs/preferences.py | 90 ++++++++++++---------- tests/test_dialogs/test_dlg_preferences.py | 17 +++- 3 files changed, 66 insertions(+), 43 deletions(-) diff --git a/novelwriter/constants.py b/novelwriter/constants.py index 9beea412..e8340137 100644 --- a/novelwriter/constants.py +++ b/novelwriter/constants.py @@ -432,7 +432,7 @@ class nwLabels: } THEME_COLORS = { "theme": QT_TRANSLATE_NOOP("Color", "Theme Colours"), - "default": QT_TRANSLATE_NOOP("Color", "No Colours"), + "default": QT_TRANSLATE_NOOP("Color", "Foreground Colour"), "faded": QT_TRANSLATE_NOOP("Color", "Faded Colour"), "red": QT_TRANSLATE_NOOP("Color", "Red"), "orange": QT_TRANSLATE_NOOP("Color", "Orange"), diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py index 1ba75b4c..3afff4b3 100644 --- a/novelwriter/dialogs/preferences.py +++ b/novelwriter/dialogs/preferences.py @@ -187,26 +187,6 @@ class GuiPreferences(NDialog): self.tr("User interface icon theme."), stretch=(3, 2) ) - # Tree Icon Colours - self.iconColTree = NComboBox(self) - self.iconColTree.setMinimumWidth(200) - for key, label in nwLabels.THEME_COLORS.items(): - self.iconColTree.addItem(trConst(label), key) - self.iconColTree.setCurrentData(CONFIG.iconColTree, DEF_TREECOL) - - self.mainForm.addRow( - self.tr("Project tree icon colours"), self.iconColTree, - self.tr("Override colours for project icons."), stretch=(3, 2) - ) - - # Keep Theme Colours on Documents - self.iconColDocs = NSwitch(self) - self.iconColDocs.setChecked(CONFIG.iconColDocs) - self.mainForm.addRow( - self.tr("Keep theme colours on documents"), self.iconColDocs, - self.tr("Only override icon colours for folders.") - ) - # Application Font Family self.guiFont = QLineEdit(self) self.guiFont.setReadOnly(True) @@ -279,14 +259,6 @@ class GuiPreferences(NDialog): button=self.textFontButton ) - # Emphasise Labels - self.emphLabels = NSwitch(self) - self.emphLabels.setChecked(CONFIG.emphLabels) - self.mainForm.addRow( - self.tr("Emphasise partition and chapter labels"), self.emphLabels, - self.tr("Makes them stand out in the project tree."), - ) - # Document Path self.showFullPath = NSwitch(self) self.showFullPath.setChecked(CONFIG.showFullPath) @@ -302,6 +274,42 @@ class GuiPreferences(NDialog): self.tr("Include project notes in status bar word count"), self.incNotesWCount ) + # Project View + # ============ + + title = self.tr("Project View") + section += 1 + self.sidebar.addButton(title, section) + self.mainForm.addGroupLabel(title, section) + + # Tree Icon Colours + self.iconColTree = NComboBox(self) + self.iconColTree.setMinimumWidth(200) + for key, label in nwLabels.THEME_COLORS.items(): + self.iconColTree.addItem(trConst(label), key) + self.iconColTree.setCurrentData(CONFIG.iconColTree, DEF_TREECOL) + + self.mainForm.addRow( + self.tr("Project tree icon colours"), self.iconColTree, + self.tr("Override colours for project icons."), stretch=(3, 2) + ) + + # Keep Theme Colours on Documents + self.iconColDocs = NSwitch(self) + self.iconColDocs.setChecked(CONFIG.iconColDocs) + self.mainForm.addRow( + self.tr("Keep theme colours on documents"), self.iconColDocs, + self.tr("Only override icon colours for folders.") + ) + + # Emphasise Labels + self.emphLabels = NSwitch(self) + self.emphLabels.setChecked(CONFIG.emphLabels) + self.mainForm.addRow( + self.tr("Emphasise partition and chapter labels"), self.emphLabels, + self.tr("Makes them stand out in the project tree."), + ) + # Behaviour # ========= @@ -540,7 +548,7 @@ class GuiPreferences(NDialog): self.scrollPastEnd = NSwitch(self) self.scrollPastEnd.setChecked(CONFIG.scrollPastEnd) self.mainForm.addRow( - self.tr("Scroll past end of the document"), self.scrollPastEnd, + self.tr("Scroll past the end of the document"), self.scrollPastEnd, self.tr("Also centres the cursor when scrolling.") ) @@ -940,39 +948,43 @@ class GuiPreferences(NDialog): guiLocale = self.guiLocale.currentData() guiTheme = self.guiTheme.currentData() iconTheme = self.iconTheme.currentData() - iconColTree = self.iconColTree.currentData() - iconColDocs = self.iconColDocs.isChecked() updateTheme |= CONFIG.guiTheme != guiTheme updateTheme |= CONFIG.iconTheme != iconTheme - updateTheme |= CONFIG.iconColTree != iconColTree - updateTheme |= CONFIG.iconColDocs != iconColDocs needsRestart |= CONFIG.guiLocale != guiLocale needsRestart |= CONFIG.guiFont != self._guiFont CONFIG.guiLocale = guiLocale CONFIG.guiTheme = guiTheme CONFIG.iconTheme = iconTheme - CONFIG.iconColTree = iconColTree - CONFIG.iconColDocs = iconColDocs CONFIG.hideVScroll = self.hideVScroll.isChecked() CONFIG.hideHScroll = self.hideHScroll.isChecked() CONFIG.nativeFont = self.nativeFont.isChecked() CONFIG.setGuiFont(self._guiFont) # Document Style - guiSyntax = self.guiSyntax.currentData() - emphLabels = self.emphLabels.isChecked() + guiSyntax = self.guiSyntax.currentData() updateSyntax |= CONFIG.guiSyntax != guiSyntax - refreshTree |= CONFIG.emphLabels != emphLabels CONFIG.guiSyntax = guiSyntax - CONFIG.emphLabels = emphLabels CONFIG.showFullPath = self.showFullPath.isChecked() CONFIG.incNotesWCount = self.incNotesWCount.isChecked() CONFIG.setTextFont(self._textFont) + # Project View + iconColTree = self.iconColTree.currentData() + iconColDocs = self.iconColDocs.isChecked() + emphLabels = self.emphLabels.isChecked() + + updateTheme |= CONFIG.iconColTree != iconColTree + updateTheme |= CONFIG.iconColDocs != iconColDocs + refreshTree |= CONFIG.emphLabels != emphLabels + + CONFIG.iconColTree = iconColTree + CONFIG.iconColDocs = iconColDocs + CONFIG.emphLabels = emphLabels + # Behaviour CONFIG.autoSaveDoc = self.autoSaveDoc.value() CONFIG.autoSaveProj = self.autoSaveProj.value() diff --git a/tests/test_dialogs/test_dlg_preferences.py b/tests/test_dialogs/test_dlg_preferences.py index 8d177299..cd1cdf8e 100644 --- a/tests/test_dialogs/test_dlg_preferences.py +++ b/tests/test_dialogs/test_dlg_preferences.py @@ -178,16 +178,23 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths): mp.setattr(QFontDialog, "getFont", lambda *a, **k: (QFont(), True)) prefs.nativeFont.setChecked(False) # Use Qt font dialog prefs.textFontButton.click() - prefs.emphLabels.setChecked(False) prefs.showFullPath.setChecked(False) prefs.incNotesWCount.setChecked(False) assert CONFIG.guiSyntax != "default_dark" assert CONFIG.textFont.family() != "" - assert CONFIG.emphLabels is True assert CONFIG.showFullPath is True assert CONFIG.incNotesWCount is True + # Project View + prefs.iconColTree.setCurrentData("faded", "default") + prefs.iconColDocs.setChecked(True) + prefs.emphLabels.setChecked(False) + + assert CONFIG.iconColTree == "theme" + assert CONFIG.iconColDocs is False + assert CONFIG.emphLabels is True + # Behaviour prefs.autoSaveDoc.stepUp() prefs.autoSaveProj.stepUp() @@ -339,10 +346,14 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths): # Document Style assert CONFIG.guiSyntax == "default_dark" assert CONFIG.textFont == QFont() - assert CONFIG.emphLabels is False assert CONFIG.showFullPath is False assert CONFIG.incNotesWCount is False + # Project View + assert CONFIG.iconColTree == "faded" + assert CONFIG.iconColDocs is True + assert CONFIG.emphLabels is False + # Behaviour assert CONFIG.autoSaveDoc == 31 assert CONFIG.autoSaveProj == 61