Update tests and add more debug output

This commit is contained in:
Veronica Berglyd Olsen
2025-10-26 02:40:50 +01:00
parent e0bd7d82fb
commit a703e0bb7d
14 changed files with 67 additions and 11 deletions
+2
View File
@@ -552,6 +552,8 @@ class NWProject:
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: NWProject")
self._data.itemStatus.refreshIcons()
self._data.itemImport.refreshIcons()
+10 -2
View File
@@ -292,6 +292,8 @@ class GuiDocEditor(QPlainTextEdit):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiDocEditor")
self.docSearch.updateTheme()
self.docHeader.updateTheme()
self.docFooter.updateTheme()
@@ -2478,8 +2480,9 @@ class GuiDocToolBar(QWidget):
def updateTheme(self) -> None:
"""Initialise GUI elements that depend on specific settings."""
syntax = SHARED.theme.syntaxTheme
logger.debug("Theme Update: GuiDocToolBar")
syntax = SHARED.theme.syntaxTheme
palette = self.palette()
palette.setColor(QPalette.ColorRole.Window, syntax.back)
palette.setColor(QPalette.ColorRole.WindowText, syntax.text)
@@ -2716,8 +2719,9 @@ class GuiDocEditSearch(QFrame):
def updateTheme(self) -> None:
"""Update theme elements."""
palette = QApplication.palette()
logger.debug("Theme Update: GuiDocEditSearch")
palette = QApplication.palette()
self.setPalette(palette)
self.searchBox.setPalette(palette)
self.replaceBox.setPalette(palette)
@@ -2961,6 +2965,8 @@ class GuiDocEditHeader(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiDocEditHeader")
self.tbButton.setThemeIcon("fmt_toolbar", "blue")
self.outlineButton.setThemeIcon("list", "blue")
self.searchButton.setThemeIcon("search", "blue")
@@ -3150,6 +3156,8 @@ class GuiDocEditFooter(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiDocEditFooter")
iPx = round(0.9*SHARED.theme.baseIconHeight)
self.linesIcon.setPixmap(SHARED.theme.getPixmap("lines", (iPx, iPx)))
self.wordsIcon.setPixmap(SHARED.theme.getPixmap("stats", (iPx, iPx)))
+5 -1
View File
@@ -141,6 +141,7 @@ class GuiDocViewer(QTextBrowser):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiDocViewer")
self.docHeader.updateTheme()
self.docFooter.updateTheme()
@@ -724,6 +725,8 @@ class GuiDocViewHeader(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiDocViewHeader")
self.outlineButton.setThemeIcon("list", "blue")
self.backButton.setThemeIcon("chevron_left", "blue")
self.forwardButton.setThemeIcon("chevron_right", "blue")
@@ -910,7 +913,8 @@ class GuiDocViewFooter(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
# Icons
logger.debug("Theme Update: GuiDocViewFooter")
fPx = int(0.9*SHARED.theme.fontPixelSize)
bulletIcon = SHARED.theme.getToggleIcon("bullet", (fPx, fPx), "blue")
+6
View File
@@ -106,6 +106,8 @@ class GuiDocViewerPanel(QWidget):
def updateTheme(self, updateTabs: bool = True) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiDocViewerPanel")
self.optsButton.setThemeIcon("more_vertical")
self.optsButton.setStyleSheet(SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON))
self.mainTabs.setStyleSheet(SHARED.theme.getStyleSheet(STYLES_FLAT_TABS))
@@ -270,6 +272,8 @@ class _ViewPanelBackRefs(QTreeWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: _ViewPanelBackRefs")
self._editIcon = SHARED.theme.getIcon("edit", "green")
self._viewIcon = SHARED.theme.getIcon("view", "blue")
for i in range(self.topLevelItemCount()):
@@ -400,6 +404,8 @@ class _ViewPanelKeyWords(QTreeWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: _ViewPanelKeyWords")
self._classIcon = SHARED.theme.getIcon(nwLabels.CLASS_ICON[self._class], "root")
self._editIcon = SHARED.theme.getIcon("edit", "green")
self._viewIcon = SHARED.theme.getIcon("view", "blue")
+1
View File
@@ -216,6 +216,7 @@ class GuiItemDetails(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiItemDetails")
self.updateViewBox(self._handle)
def updateViewBox(self, tHandle: str | None) -> None:
+3 -2
View File
@@ -89,6 +89,7 @@ class GuiNovelView(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiNovelView")
self.novelBar.updateTheme()
def initSettings(self) -> None:
@@ -244,12 +245,12 @@ class GuiNovelToolBar(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
# Icons
logger.debug("Theme Update: GuiNovelToolBar")
self.tbNovel.setThemeIcon("cls_novel", "red")
self.tbRefresh.setThemeIcon("refresh", "green")
self.tbMore.setThemeIcon("more_vertical")
# StyleSheets
buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON)
self.tbNovel.setStyleSheet(buttonStyle)
self.tbRefresh.setStyleSheet(buttonStyle)
+6
View File
@@ -103,6 +103,8 @@ class GuiOutlineView(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiOutlineView")
self.outlineBar.updateTheme()
self.outlineTree.updateTheme()
self.outlineTree.refreshTree(
@@ -258,6 +260,8 @@ class GuiOutlineToolBar(QToolBar):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiOutlineToolBar")
self.setStyleSheet("QToolBar {border: 0px;}")
self.novelValue.refreshNovelList()
self.aRefresh.setIcon(SHARED.theme.getIcon("refresh", "green"))
@@ -454,6 +458,8 @@ class GuiOutlineTree(QTreeWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiOutlineTree")
iType = nwItemType.FILE
iClass = nwItemClass.NO_CLASS
iLayout = nwItemLayout.DOCUMENT
+3
View File
@@ -138,6 +138,7 @@ class GuiProjectView(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiProjectView")
self.projBar.updateTheme()
def initSettings(self) -> None:
@@ -346,6 +347,8 @@ class GuiProjectToolBar(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiProjectToolBar")
buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON)
self.tbQuick.setStyleSheet(buttonStyle)
self.tbMoveU.setStyleSheet(buttonStyle)
+2
View File
@@ -158,6 +158,8 @@ class GuiProjectSearch(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiProjectSearch")
palette = QApplication.palette()
colBase = palette.base().color().name(QtHexArgb)
colFocus = palette.highlight().color().name(QtHexArgb)
+2 -1
View File
@@ -129,8 +129,9 @@ class GuiSideBar(QWidget):
def updateTheme(self) -> None:
"""Initialise GUI elements that depend on specific settings."""
buttonStyle = SHARED.theme.getStyleSheet(STYLES_BIG_TOOLBUTTON)
logger.debug("Theme Update: GuiSideBar")
buttonStyle = SHARED.theme.getStyleSheet(STYLES_BIG_TOOLBUTTON)
self.tbProject.setStyleSheet(buttonStyle)
self.tbNovel.setStyleSheet(buttonStyle)
self.tbSearch.setStyleSheet(buttonStyle)
+2
View File
@@ -133,6 +133,8 @@ class GuiMainStatus(QStatusBar):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiMainStatus")
iPx = SHARED.theme.baseIconHeight
self.langIcon.setPixmap(SHARED.theme.getPixmap("language", (iPx, iPx)))
self.statsIcon.setPixmap(SHARED.theme.getPixmap("stats", (iPx, iPx)))
+11 -4
View File
@@ -263,10 +263,7 @@ class GuiManuscript(NToolDialog):
def updateTheme(self, *, init: bool = False) -> None:
"""Update theme elements."""
self.tbAdd.setThemeIcon("add", "green")
self.tbDel.setThemeIcon("remove", "red")
self.tbCopy.setThemeIcon("copy", "blue")
self.tbEdit.setThemeIcon("edit", "green")
logger.debug("Theme Update: GuiManuscript, init=%s", init)
if not init:
self.btnPreview.updateIcon()
@@ -274,6 +271,11 @@ class GuiManuscript(NToolDialog):
self.btnBuild.updateIcon()
self.btnClose.updateIcon()
self.tbAdd.setThemeIcon("add", "green")
self.tbDel.setThemeIcon("remove", "red")
self.tbCopy.setThemeIcon("copy", "blue")
self.tbEdit.setThemeIcon("edit", "green")
buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON)
self.tbAdd.setStyleSheet(buttonStyle)
self.tbDel.setStyleSheet(buttonStyle)
@@ -641,6 +643,7 @@ class _DetailsWidget(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
if self._build:
logger.debug("Theme Update: _DetailsWidget")
self.updateInfo(self._build)
@@ -709,6 +712,7 @@ class _OutlineWidget(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: _OutlineWidget")
self.updateOutline(self._outline, force=True)
##
@@ -845,6 +849,8 @@ class _PreviewWidget(QTextBrowser):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: _PreviewWidget")
palette = QApplication.palette()
palette.setColor(QPalette.ColorRole.Window, palette.toolTipBase().color())
palette.setColor(QPalette.ColorRole.WindowText, palette.toolTipText().color())
@@ -984,6 +990,7 @@ class _StatsWidget(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: _StatsWidget")
self.toggleButton.setThemeIcon("unfold")
##
+8 -1
View File
@@ -173,6 +173,8 @@ class GuiBuildSettings(NToolDialog):
def updateTheme(self, *, init: bool = False) -> None:
"""Update theme elements."""
logger.debug("Theme Update: GuiBuildSettings, init=%s", init)
if not init:
self.btnApply.updateIcon()
self.btnSave.updateIcon()
@@ -405,6 +407,8 @@ class _FilterTab(NFixedPage):
def updateTheme(self, *, init: bool = False) -> None:
"""Update theme elements."""
logger.debug("Theme Update: _FilterTab, init=%s", init)
if not init:
self._statusFlags[self.F_FILTERED] = SHARED.theme.getIcon("filter", "orange")
self._statusFlags[self.F_INCLUDED] = SHARED.theme.getIcon("pin", "blue")
@@ -805,6 +809,8 @@ class _HeadingsTab(NScrollablePage):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: _HeadingsTab")
self.btnPart.setThemeIcon("edit", "green")
self.btnChapter.setThemeIcon("edit", "green")
self.btnUnnumbered.setThemeIcon("edit", "green")
@@ -1310,12 +1316,13 @@ class _FormattingTab(NScrollableForm):
def updateTheme(self) -> None:
"""Update theme elements."""
iPx = SHARED.theme.baseIconHeight
logger.debug("Theme Update: _FormattingTab")
self.ignoredKeywordsButton.setThemeIcon("add", "green")
self.btnTextFont.setThemeIcon("font")
self.btnPageHeader.setThemeIcon("revert", "green")
iPx = SHARED.theme.baseIconHeight
self.pixT.setPixmap(SHARED.theme.getPixmap("margin_top", (iPx, iPx)))
self.pixB.setPixmap(SHARED.theme.getPixmap("margin_bottom", (iPx, iPx)))
self.pixL.setPixmap(SHARED.theme.getPixmap("margin_left", (iPx, iPx)))
@@ -72,6 +72,9 @@ def testToolManuscript_Init(monkeypatch, qtbot, nwGUI, projPath, mockRnd):
manus.btnPreview.click()
assert manus.docPreview.toPlainText().strip() == allText
# Trigger a theme update, which is only a visual refresh, but it shouldn't crash
manus.updateTheme()
nwGUI.closeProject() # This should auto-close the manuscript tool
# qtbot.stop()
@@ -148,6 +151,9 @@ def testToolManuscript_Builds(qtbot, nwGUI, projPath):
assert new is not None
assert new.name == "Test Build 2"
# Trigger a theme update, which should propagate to settings
manus.updateTheme()
# Close the dialog should also close the child dialogs
manus.btnClose.click()
if isinstance(bSettings, GuiBuildSettings):