Add character count setting to Preferences

This commit is contained in:
Veronica Berglyd Olsen
2025-04-29 21:36:04 +02:00
parent ba7fdb314b
commit 8de6fd25e2
2 changed files with 25 additions and 9 deletions
+20 -9
View File
@@ -225,6 +225,14 @@ class GuiPreferences(NDialog):
self.tr("Turn off to use the Qt font dialog, which may have more options.")
)
# Use Character Count
self.useCharCount = NSwitch(self)
self.useCharCount.setChecked(CONFIG.useCharCount)
self.mainForm.addRow(
self.tr("Prefer character count over word count"), self.useCharCount,
self.tr("Display character count instead where available.")
)
# Document Style
# ==============
@@ -957,21 +965,24 @@ class GuiPreferences(NDialog):
refreshTree = False
# Appearance
guiLocale = self.guiLocale.currentData()
guiTheme = self.guiTheme.currentData()
iconTheme = self.iconTheme.currentData()
guiLocale = self.guiLocale.currentData()
guiTheme = self.guiTheme.currentData()
iconTheme = self.iconTheme.currentData()
useCharCount = self.useCharCount.isChecked()
updateTheme |= CONFIG.guiTheme != guiTheme
updateTheme |= CONFIG.iconTheme != iconTheme
needsRestart |= CONFIG.guiLocale != guiLocale
needsRestart |= CONFIG.guiFont != self._guiFont
refreshTree |= CONFIG.useCharCount != useCharCount
CONFIG.guiLocale = guiLocale
CONFIG.guiTheme = guiTheme
CONFIG.iconTheme = iconTheme
CONFIG.hideVScroll = self.hideVScroll.isChecked()
CONFIG.hideHScroll = self.hideHScroll.isChecked()
CONFIG.nativeFont = self.nativeFont.isChecked()
CONFIG.guiLocale = guiLocale
CONFIG.guiTheme = guiTheme
CONFIG.iconTheme = iconTheme
CONFIG.hideVScroll = self.hideVScroll.isChecked()
CONFIG.hideHScroll = self.hideHScroll.isChecked()
CONFIG.nativeFont = self.nativeFont.isChecked()
CONFIG.useCharCount = useCharCount
CONFIG.setGuiFont(self._guiFont)
# Document Style
@@ -163,14 +163,17 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
mp.setattr(QFontDialog, "getFont", lambda *a, **k: (QFont(), True))
prefs.nativeFont.setChecked(True) # Use OS font dialog
prefs.guiFontButton.click()
prefs.hideVScroll.setChecked(True)
prefs.hideHScroll.setChecked(True)
prefs.useCharCount.setChecked(True)
assert CONFIG.guiLocale != "en_US"
assert CONFIG.guiTheme != "default_dark"
assert CONFIG.guiFont.family() != ""
assert CONFIG.hideVScroll is False
assert CONFIG.hideHScroll is False
assert CONFIG.useCharCount is False
# Document Style
prefs.guiSyntax.setCurrentIndex(prefs.guiSyntax.findData("default_dark"))
@@ -178,6 +181,7 @@ 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.showFullPath.setChecked(False)
prefs.incNotesWCount.setChecked(False)
@@ -344,6 +348,7 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
assert CONFIG.guiFont == QFont()
assert CONFIG.hideVScroll is True
assert CONFIG.hideHScroll is True
assert CONFIG.useCharCount is True
# Document Style
assert CONFIG.guiSyntax == "default_dark"