diff --git a/novelwriter/core/status.py b/novelwriter/core/status.py index bcee828c..c3e58b76 100644 --- a/novelwriter/core/status.py +++ b/novelwriter/core/status.py @@ -192,10 +192,7 @@ class NWStatus: def refreshIcons(self) -> None: """Refresh all icons.""" for entry in self._store.values(): - if entry.theme != CUSTOM_COL: - print("<", entry.color.name(QColor.NameFormat.HexRgb)) - entry.color = SHARED.theme.parseColor(entry.theme) - print(">", entry.color.name(QColor.NameFormat.HexRgb)) + entry.color = SHARED.theme.parseColor(entry.theme) entry.icon = NWStatus.createIcon(self._height, entry.color, entry.shape) return diff --git a/tests/conftest.py b/tests/conftest.py index bd66447b..4017bb9f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,6 +34,8 @@ from PyQt6.QtWidgets import QMessageBox sys.path.insert(1, str(Path(__file__).parent.parent.absolute())) from novelwriter import CONFIG, SHARED +from novelwriter.config import DEF_GUI_DARK, DEF_GUI_LIGHT +from novelwriter.enum import nwTheme from tests.mocked import MockGuiMain from tests.tools import cleanProject @@ -60,6 +62,10 @@ def resetConfigVars(): CONFIG._dLocale = QLocale("en_GB") CONFIG._manuals = {"manual": _TMP_ROOT / "manual.pdf"} CONFIG.guiLocale = "en_GB" + CONFIG.darkTheme = DEF_GUI_DARK + CONFIG.lightTheme = DEF_GUI_LIGHT + CONFIG.themeMode = nwTheme.LIGHT + CONFIG.emphLabels = True # Ensures better coverage, off by default return @@ -157,13 +163,21 @@ def mockGUI(qtbot, monkeypatch): monkeypatch.setattr(QMessageBox, "result", lambda *a: QMessageBox.StandardButton.Yes) gui = MockGuiMain() theme = GuiTheme() - theme.loadTheme() monkeypatch.setattr(SHARED, "_gui", gui) monkeypatch.setattr(SHARED, "_theme", theme) return gui +@pytest.fixture(scope="function") +def mockGUIwithTheme(mockGUI): + """Create a mock instance of novelWriter's main GUI class with the + theme instance initialised. + """ + SHARED.theme.initThemes() + return mockGUI + + @pytest.fixture(scope="function") def nwGUI(qtbot, monkeypatch, functionFixture): """Create an instance of the novelWriter GUI.""" diff --git a/tests/test_core/test_core_status.py b/tests/test_core/test_core_status.py index 3b5e80b8..1ea0c09e 100644 --- a/tests/test_core/test_core_status.py +++ b/tests/test_core/test_core_status.py @@ -324,13 +324,32 @@ def testCoreStatus_Entries(mockGUI, mockRnd): @pytest.mark.core -def testCoreStatus_Pack(mockGUI, mockRnd): +def testCoreStatus_RefreshIcons(mockGUIwithTheme, mockRnd): + """Test refreshing the icons of the NWStatus class.""" + nStatus = NWStatus(NWStatus.STATUS) + nStatus.add(None, "New", "default", "SQUARE", 0) + nStatus.add(None, "Note", "red", "CIRCLE", 0) + nStatus.add(None, "Draft", "yellow", "SQUARE", 0) + nStatus.add(None, "Finished", "green", "SQUARE", 0) + + beforeIcons = [nStatus[statusKeys[i]].icon for i in range(4)] + + # Refreshing the icons should generate new ones + nStatus.refreshIcons() + afterIcons = [nStatus[statusKeys[i]].icon for i in range(4)] + + for before, after in zip(beforeIcons, afterIcons, strict=False): + assert before is not after + + +@pytest.mark.core +def testCoreStatus_Pack(mockGUIwithTheme, mockRnd): """Test data packing of the NWStatus class.""" nStatus = NWStatus(NWStatus.STATUS) nStatus.add(None, "New", "#646464", "SQUARE", 0) nStatus.add(None, "Note", "#c83200", "CIRCLE", 0) nStatus.add(None, "Draft", "#c89600", "SQUARE", 0) - nStatus.add(None, "Finished", "#32c800", "SQUARE", 0) + nStatus.add(None, "Finished", "default", "SQUARE", 0) countTo = [3, 5, 7, 9] for i, n in enumerate(countTo): @@ -360,7 +379,7 @@ def testCoreStatus_Pack(mockGUI, mockRnd): ("Finished", { "key": statusKeys[3], "count": "9", - "color": "#32c800", + "color": "default", "shape": "SQUARE", }), ] diff --git a/tests/test_dialogs/test_dlg_preferences.py b/tests/test_dialogs/test_dlg_preferences.py index a017585f..66d6183e 100644 --- a/tests/test_dialogs/test_dlg_preferences.py +++ b/tests/test_dialogs/test_dlg_preferences.py @@ -196,11 +196,11 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths): # Project View prefs.iconColTree.setCurrentData("faded", "default") prefs.iconColDocs.setChecked(True) - prefs.emphLabels.setChecked(True) + prefs.emphLabels.setChecked(False) assert CONFIG.iconColTree == DEF_TREECOL assert CONFIG.iconColDocs is False - assert CONFIG.emphLabels is False + assert CONFIG.emphLabels is True # Behaviour prefs.autoSaveDoc.stepUp() @@ -362,7 +362,7 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths): # Project View assert CONFIG.iconColTree == "faded" assert CONFIG.iconColDocs is True - assert CONFIG.emphLabels is True + assert CONFIG.emphLabels is False # Behaviour assert CONFIG.autoSaveDoc == 31 diff --git a/tests/test_gui/test_gui_guimain.py b/tests/test_gui/test_gui_guimain.py index 5010094d..3940cbba 100644 --- a/tests/test_gui/test_gui_guimain.py +++ b/tests/test_gui/test_gui_guimain.py @@ -267,8 +267,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd): # Change some settings CONFIG.hideHScroll = True CONFIG.hideVScroll = True - CONFIG.autoScrollPos = 80 - CONFIG.autoScroll = True + CONFIG.autoScroll = False # Add a Character File nwGUI._changeView(nwView.PROJECT)