Add native font dialog option and fix tests

This commit is contained in:
Veronica Berglyd Olsen
2024-05-23 18:44:45 +02:00
parent 1fe7ca3db8
commit 69b362b9d2
6 changed files with 30 additions and 30 deletions
+2 -9
View File
@@ -160,20 +160,12 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, tstPaths):
prefs = GuiPreferences(nwGUI)
prefs.show()
# Mock Font
class MockFont:
def family(self):
return "TestFont"
def pointSize(self):
return 42
# Appearance
prefs.guiLocale.setCurrentIndex(prefs.guiLocale.findData("en_US"))
prefs.guiTheme.setCurrentIndex(prefs.guiTheme.findData("default_dark"))
with monkeypatch.context() as mp:
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)
@@ -188,6 +180,7 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, tstPaths):
prefs.guiSyntax.setCurrentIndex(prefs.guiSyntax.findData("default_dark"))
with monkeypatch.context() as mp:
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)
+1 -2
View File
@@ -26,7 +26,7 @@ from PyQt5.QtCore import pyqtSlot
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QFontDialog
from novelwriter import CONFIG, SHARED
from novelwriter import SHARED
from novelwriter.common import describeFont
from novelwriter.constants import nwHeadFmt
from novelwriter.core.buildsettings import BuildSettings, FilterMode
@@ -575,7 +575,6 @@ def testBuildSettings_Format(monkeypatch, qtbot, nwGUI):
assert bSettings.toolStack.currentWidget() is fmtTab
# Check initial values
assert fmtTab._textFont == CONFIG.textFont
assert fmtTab.lineHeight.value() == 1.2
assert fmtTab.justifyText.isChecked() is False