Merge 2.7.3 release into current main
This commit is contained in:
@@ -27,10 +27,11 @@ from PyQt6.QtGui import QAction, QFont, QFontDatabase, QKeyEvent
|
||||
from PyQt6.QtWidgets import QFileDialog, QFontDialog
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.config import DEF_GUI
|
||||
from novelwriter.config import DEF_GUI_DARK, DEF_GUI_LIGHT, DEF_TREECOL
|
||||
from novelwriter.constants import nwUnicode
|
||||
from novelwriter.dialogs.preferences import GuiPreferences
|
||||
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
||||
from novelwriter.gui.theme import ThemeEntry
|
||||
from novelwriter.types import QtDialogCancel, QtDialogSave, QtModNone
|
||||
|
||||
KEY_DELAY = 1
|
||||
@@ -55,15 +56,11 @@ def testDlgPreferences_Main(qtbot, monkeypatch, nwGUI, tstPaths):
|
||||
assert "en_GB" in languages
|
||||
|
||||
# Check GUI Themes
|
||||
themes = [prefs.guiTheme.itemData(i) for i in range(prefs.guiTheme.count())]
|
||||
assert len(themes) >= 5
|
||||
assert DEF_GUI in themes
|
||||
themes = [prefs.lightTheme.itemData(i) for i in range(prefs.lightTheme.count())]
|
||||
assert DEF_GUI_LIGHT in themes
|
||||
|
||||
# Check GUI Syntax
|
||||
syntax = [prefs.guiSyntax.itemData(i) for i in range(prefs.guiSyntax.count())]
|
||||
assert len(syntax) >= 10
|
||||
assert "default_dark" in syntax
|
||||
assert "default_light" in syntax
|
||||
themes = [prefs.darkTheme.itemData(i) for i in range(prefs.darkTheme.count())]
|
||||
assert DEF_GUI_DARK in themes
|
||||
|
||||
# Check Spell Checking
|
||||
spelling = [prefs.spellLanguage.itemData(i) for i in range(prefs.spellLanguage.count())]
|
||||
@@ -124,7 +121,7 @@ def testDlgPreferences_Actions(qtbot, monkeypatch, nwGUI):
|
||||
button = prefs.buttonBox.button(QtDialogSave)
|
||||
assert button is not None
|
||||
button.click()
|
||||
assert signal.args == [False, False, False, False]
|
||||
assert len(signal.args) == 4
|
||||
|
||||
# Check Close Button
|
||||
prefs.show()
|
||||
@@ -151,6 +148,12 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
||||
(fncPath / "nw_en_US.qm").touch()
|
||||
(fncPath / "project_en_US.json").touch()
|
||||
CONFIG._nwLangPath = fncPath
|
||||
SHARED.theme._allThemes = {
|
||||
"theme1": ThemeEntry(name="Theme 1", dark=False, path=fncPath),
|
||||
"theme2": ThemeEntry(name="Theme 2", dark=False, path=fncPath),
|
||||
"theme3": ThemeEntry(name="Theme 3", dark=True, path=fncPath),
|
||||
"theme4": ThemeEntry(name="Theme 4", dark=True, path=fncPath),
|
||||
}
|
||||
|
||||
prefs = GuiPreferences(nwGUI)
|
||||
with qtbot.waitExposed(prefs):
|
||||
@@ -158,7 +161,8 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
||||
|
||||
# Appearance
|
||||
prefs.guiLocale.setCurrentIndex(prefs.guiLocale.findData("en_US"))
|
||||
prefs.guiTheme.setCurrentIndex(prefs.guiTheme.findData("default_dark"))
|
||||
prefs.lightTheme.setCurrentIndex(prefs.lightTheme.findData("theme1"))
|
||||
prefs.darkTheme.setCurrentIndex(prefs.darkTheme.findData("theme3"))
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QFontDialog, "getFont", lambda *a, **k: (QFont(), True))
|
||||
prefs.nativeFont.setChecked(True) # Use OS font dialog
|
||||
@@ -169,14 +173,14 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
||||
prefs.useCharCount.setChecked(True)
|
||||
|
||||
assert CONFIG.guiLocale != "en_US"
|
||||
assert CONFIG.guiTheme != "default_dark"
|
||||
assert CONFIG.lightTheme == "default_light"
|
||||
assert CONFIG.darkTheme == "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"))
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QFontDialog, "getFont", lambda *a, **k: (QFont(), True))
|
||||
prefs.nativeFont.setChecked(False) # Use Qt font dialog
|
||||
@@ -185,7 +189,6 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
||||
prefs.showFullPath.setChecked(False)
|
||||
prefs.incNotesWCount.setChecked(False)
|
||||
|
||||
assert CONFIG.guiSyntax != "default_dark"
|
||||
assert CONFIG.textFont.family() != ""
|
||||
assert CONFIG.showFullPath is True
|
||||
assert CONFIG.incNotesWCount is True
|
||||
@@ -195,7 +198,7 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
||||
prefs.iconColDocs.setChecked(True)
|
||||
prefs.emphLabels.setChecked(False)
|
||||
|
||||
assert CONFIG.iconColTree == "theme"
|
||||
assert CONFIG.iconColTree == DEF_TREECOL
|
||||
assert CONFIG.iconColDocs is False
|
||||
assert CONFIG.emphLabels is True
|
||||
|
||||
@@ -247,22 +250,24 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
||||
prefs.spellLanguage.setCurrentIndex(prefs.spellLanguage.findData("de"))
|
||||
prefs.autoSelect.setChecked(False)
|
||||
prefs.cursorWidth.setValue(5)
|
||||
prefs.lineHighlight.setChecked(False)
|
||||
prefs.showTabsNSpaces.setChecked(True)
|
||||
prefs.showLineEndings.setChecked(True)
|
||||
|
||||
assert CONFIG.spellLanguage != "de"
|
||||
assert CONFIG.autoSelect is True
|
||||
assert CONFIG.cursorWidth == 1
|
||||
assert CONFIG.lineHighlight is True
|
||||
assert CONFIG.showTabsNSpaces is False
|
||||
assert CONFIG.showLineEndings is False
|
||||
|
||||
# Editor Scrolling
|
||||
prefs.scrollPastEnd.setChecked(False)
|
||||
prefs.autoScroll.setChecked(True)
|
||||
prefs.autoScroll.setChecked(False)
|
||||
prefs.autoScrollPos.stepUp()
|
||||
|
||||
assert CONFIG.scrollPastEnd is True
|
||||
assert CONFIG.autoScroll is False
|
||||
assert CONFIG.autoScroll is True
|
||||
assert CONFIG.autoScrollPos == 30
|
||||
|
||||
# Text Highlighting
|
||||
@@ -347,14 +352,14 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
||||
|
||||
# Appearance
|
||||
assert CONFIG.guiLocale == "en_US"
|
||||
assert CONFIG.guiTheme == "default_dark"
|
||||
assert CONFIG.lightTheme == "theme1"
|
||||
assert CONFIG.darkTheme == "theme3"
|
||||
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"
|
||||
assert CONFIG.textFont == QFont()
|
||||
assert CONFIG.showFullPath is False
|
||||
assert CONFIG.incNotesWCount is False
|
||||
@@ -390,12 +395,13 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
||||
assert CONFIG.spellLanguage == "de"
|
||||
assert CONFIG.autoSelect is False
|
||||
assert CONFIG.cursorWidth == 5
|
||||
assert CONFIG.lineHighlight is False
|
||||
assert CONFIG.showTabsNSpaces is True
|
||||
assert CONFIG.showLineEndings is True
|
||||
|
||||
# Editor Scrolling
|
||||
assert CONFIG.scrollPastEnd is False
|
||||
assert CONFIG.autoScroll is True
|
||||
assert CONFIG.autoScroll is False
|
||||
assert CONFIG.autoScrollPos == 31
|
||||
|
||||
# Text Highlighting
|
||||
|
||||
@@ -214,22 +214,22 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, projPath, mockRn
|
||||
|
||||
assert update[0][0] == C.sNew
|
||||
assert update[0][1].name == "New"
|
||||
assert update[0][1].color == QColor(120, 120, 120)
|
||||
assert update[0][1].color.getRgb() == (108, 108, 108, 255)
|
||||
assert update[0][1].shape == nwStatusShape.STAR
|
||||
|
||||
assert update[1][0] == C.sDraft
|
||||
assert update[1][1].name == "Draft"
|
||||
assert update[1][1].color == QColor(143, 240, 164)
|
||||
assert update[1][1].color.getRgb() == (163, 156, 52, 255)
|
||||
assert update[1][1].shape == nwStatusShape.CIRCLE_T
|
||||
|
||||
assert update[2][0] == C.sFinished
|
||||
assert update[2][1].name == "Finished"
|
||||
assert update[2][1].color == QColor(249, 240, 107)
|
||||
assert update[2][1].color.getRgb() == (41, 102, 41, 255)
|
||||
assert update[2][1].shape == nwStatusShape.STAR
|
||||
|
||||
assert update[3][0] is None
|
||||
assert update[3][1].name == "Final"
|
||||
assert update[3][1].color == QColor(20, 30, 40)
|
||||
assert update[3][1].color.getRgb() == (20, 30, 40, 255)
|
||||
assert update[3][1].shape == nwStatusShape.CIRCLE
|
||||
|
||||
# Move items, none selected -> no change
|
||||
@@ -289,22 +289,22 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, projPath, mockRn
|
||||
|
||||
assert update[0][0] == C.iNew
|
||||
assert update[0][1].name == "New"
|
||||
assert update[0][1].color == QColor(120, 120, 120)
|
||||
assert update[0][1].color.getRgb() == (179, 90, 179, 255)
|
||||
assert update[0][1].shape == nwStatusShape.SQUARE
|
||||
|
||||
assert update[1][0] == C.iMajor
|
||||
assert update[1][1].name == "Major"
|
||||
assert update[1][1].color == QColor(220, 138, 221)
|
||||
assert update[1][1].color.getRgb() == (179, 90, 179, 255)
|
||||
assert update[1][1].shape == nwStatusShape.BLOCK_3
|
||||
|
||||
assert update[2][0] == C.iMain
|
||||
assert update[2][1].name == "Main"
|
||||
assert update[2][1].color == QColor(220, 138, 221)
|
||||
assert update[2][1].color.getRgb() == (179, 90, 179, 255)
|
||||
assert update[2][1].shape == nwStatusShape.BLOCK_4
|
||||
|
||||
assert update[3][0] is None
|
||||
assert update[3][1].name == "Final"
|
||||
assert update[3][1].color == QColor(20, 30, 40)
|
||||
assert update[3][1].color.getRgb() == (20, 30, 40, 255)
|
||||
assert update[3][1].shape == nwStatusShape.TRIANGLE
|
||||
|
||||
# Check Project
|
||||
@@ -354,10 +354,10 @@ def testDlgProjSettings_StatusImportExport(qtbot, monkeypatch, nwGUI, projPath,
|
||||
|
||||
assert expFile.is_file() is True
|
||||
assert expFile.read_text().split() == [
|
||||
"STAR,#787878,New",
|
||||
"TRIANGLE,#cdab8f,Note",
|
||||
"CIRCLE_T,#8ff0a4,Draft",
|
||||
"STAR,#f9f06b,Finished",
|
||||
"STAR,#6c6c6c,New",
|
||||
"TRIANGLE,#a62a2d,Note",
|
||||
"CIRCLE_T,#a39c34,Draft",
|
||||
"STAR,#296629,Finished",
|
||||
]
|
||||
|
||||
# Import Error
|
||||
|
||||
Reference in New Issue
Block a user