Add icon colour settings to themes and enforce them on all GUI icons

This commit is contained in:
Veronica Berglyd Olsen
2025-10-26 14:02:18 +01:00
parent 2c1c46b98d
commit 6db67e909d
25 changed files with 216 additions and 187 deletions
+3 -3
View File
@@ -79,10 +79,10 @@ class GuiDictionaries(NNonBlockingDialog):
self.huInfo.setOpenExternalLinks(True)
self.huInfo.setWordWrap(True)
self.huInput = QLineEdit(self)
self.huBrowse = NIconToolButton(self, iSz, "browse")
self.huBrowse = NIconToolButton(self, iSz, "browse", "systemio")
self.huBrowse.clicked.connect(self._doBrowseHunspell)
self.huImport = QPushButton(self.tr("Add Dictionary"), self)
self.huImport.setIcon(SHARED.theme.getIcon("add", "green"))
self.huImport.setIcon(SHARED.theme.getIcon("add", "add"))
self.huImport.clicked.connect(self._doImportHunspell)
self.huPathBox = QHBoxLayout()
@@ -97,7 +97,7 @@ class GuiDictionaries(NNonBlockingDialog):
self.inInfo = QLabel(self.tr("Dictionary install location"), self)
self.inPath = QLineEdit(self)
self.inPath.setReadOnly(True)
self.inBrowse = NIconToolButton(self, iSz, "browse")
self.inBrowse = NIconToolButton(self, iSz, "browse", "systemio")
self.inBrowse.clicked.connect(self._doOpenInstallLocation)
self.inBox = QHBoxLayout()
+1 -1
View File
@@ -59,7 +59,7 @@ class GuiLipsum(NDialog):
# Icon
self.docIcon = QLabel(self)
self.docIcon.setPixmap(SHARED.theme.getPixmap("text", (64, 64), "blue"))
self.docIcon.setPixmap(SHARED.theme.getPixmap("text", (64, 64), "info"))
self.leftBox = QVBoxLayout()
self.leftBox.setSpacing(4)
+9 -11
View File
@@ -43,7 +43,7 @@ from novelwriter.core.item import NWItem
from novelwriter.enum import nwBuildFmt, nwStandardButton
from novelwriter.extensions.modified import NDialog, NIconToolButton, NPushButton
from novelwriter.extensions.progressbars import NProgressSimple
from novelwriter.types import QtAlignCenter, QtRoleAction, QtRoleDestruct, QtRoleReject, QtUserRole
from novelwriter.types import QtAlignCenter, QtRoleAction, QtRoleDestruct, QtUserRole
if TYPE_CHECKING:
from PyQt6.QtGui import QCloseEvent
@@ -143,7 +143,7 @@ class GuiManuscriptBuild(NDialog):
# Build Path
self.lblPath = QLabel(self.tr("Path"), self)
self.buildPath = QLineEdit(self)
self.btnBrowse = NIconToolButton(self, iSz, "browse")
self.btnBrowse = NIconToolButton(self, iSz, "browse", "systemio")
self.pathBox = QHBoxLayout()
self.pathBox.addWidget(self.buildPath)
@@ -153,7 +153,7 @@ class GuiManuscriptBuild(NDialog):
# Build Name
self.lblName = QLabel(self.tr("File Name"), self)
self.buildName = QLineEdit(self)
self.btnReset = NIconToolButton(self, iSz, "revert", "green")
self.btnReset = NIconToolButton(self, iSz, "revert", "reset")
self.btnReset.setToolTip(self.tr("Reset file name to default"))
self.nameBox = QHBoxLayout()
@@ -178,7 +178,7 @@ class GuiManuscriptBuild(NDialog):
self.buildBox.setVerticalSpacing(4)
# Dialog Buttons
self.btnOpen = NPushButton(self, self.tr("Open Folder"), bSz, "browse", "yellow")
self.btnOpen = NPushButton(self, self.tr("Open Folder"), bSz, "browse", "systemio")
self.btnOpen.setAutoDefault(False)
self.btnBuild = SHARED.theme.getStandardButton(nwStandardButton.BUILD, self)
@@ -260,13 +260,11 @@ class GuiManuscriptBuild(NDialog):
@pyqtSlot("QAbstractButton*")
def _dialogButtonClicked(self, button: QAbstractButton) -> None:
"""Handle button clicks from the dialog button box."""
role = self.btnBox.buttonRole(button)
if role == QtRoleAction:
if button == self.btnBuild:
self._runBuild()
elif button == self.btnOpen:
self._openOutputFolder()
elif role == QtRoleReject:
if button == self.btnBuild:
self._runBuild()
elif button == self.btnOpen:
self._openOutputFolder()
elif button == self.btnClose:
self.close()
@pyqtSlot()
+8 -8
View File
@@ -271,10 +271,10 @@ 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")
self.tbAdd.setThemeIcon("add", "add")
self.tbDel.setThemeIcon("remove", "remove")
self.tbCopy.setThemeIcon("copy", "accept")
self.tbEdit.setThemeIcon("edit", "change")
buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON)
self.tbAdd.setStyleSheet(buttonStyle)
@@ -484,7 +484,7 @@ class GuiManuscript(NToolDialog):
for key, name in self._builds.builds():
bItem = QListWidgetItem()
bItem.setText(name)
bItem.setIcon(SHARED.theme.getIcon("build_settings", "blue"))
bItem.setIcon(SHARED.theme.getIcon("build_settings", "action"))
bItem.setData(self.D_KEY, key)
self.buildList.addItem(bItem)
self._buildMap[key] = bItem
@@ -574,8 +574,8 @@ class _DetailsWidget(QWidget):
self.listView.clear()
on = SHARED.theme.getIcon("bullet-on", "blue")
off = SHARED.theme.getIcon("bullet-off", "blue")
on = SHARED.theme.getIcon("bullet-on", "action")
off = SHARED.theme.getIcon("bullet-off", "action")
# Name
item = QTreeWidgetItem()
@@ -991,7 +991,7 @@ class _StatsWidget(QWidget):
def updateTheme(self) -> None:
"""Update theme elements."""
logger.debug("Theme Update: _StatsWidget")
self.toggleButton.setThemeIcon("unfold")
self.toggleButton.setThemeIcon("unfold", "default")
##
# Private Slots
+21 -22
View File
@@ -52,7 +52,7 @@ from novelwriter.extensions.switch import NSwitch
from novelwriter.extensions.switchbox import NSwitchBox
from novelwriter.types import (
QtAlignCenter, QtAlignLeft, QtHeaderFixed, QtHeaderStretch, QtRoleAccept,
QtRoleApply, QtRoleDestruct, QtRoleReject, QtUserRole
QtRoleApply, QtRoleDestruct, QtUserRole
)
if TYPE_CHECKING:
@@ -229,15 +229,14 @@ class GuiBuildSettings(NToolDialog):
@pyqtSlot("QAbstractButton*")
def _dialogButtonClicked(self, button: QAbstractButton) -> None:
"""Handle button clicks from the dialog button box."""
role = self.btnBox.buttonRole(button)
if role == QtRoleApply:
if button == self.btnApply:
self._applyChanges()
self._emitBuildData()
elif role == QtRoleAccept:
elif button == self.btnSave:
self._applyChanges()
self._emitBuildData()
self.close()
elif role == QtRoleReject:
elif button == self.btnClose:
self._build.resetChangedState()
self.close()
@@ -302,9 +301,9 @@ class _FilterTab(NFixedPage):
self._statusFlags: dict[int, QIcon] = {
self.F_NONE: QIcon(),
self.F_FILTERED: SHARED.theme.getIcon("filter", "orange"),
self.F_INCLUDED: SHARED.theme.getIcon("pin", "blue"),
self.F_EXCLUDED: SHARED.theme.getIcon("exclude", "red"),
self.F_FILTERED: SHARED.theme.getIcon("filter", "altaction"),
self.F_INCLUDED: SHARED.theme.getIcon("pin", "action"),
self.F_EXCLUDED: SHARED.theme.getIcon("exclude", "reject"),
}
self._trIncluded = self.tr("Included in manuscript")
@@ -410,14 +409,14 @@ class _FilterTab(NFixedPage):
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")
self._statusFlags[self.F_EXCLUDED] = SHARED.theme.getIcon("exclude", "red")
self._statusFlags[self.F_FILTERED] = SHARED.theme.getIcon("filter", "altaction")
self._statusFlags[self.F_INCLUDED] = SHARED.theme.getIcon("pin", "action")
self._statusFlags[self.F_EXCLUDED] = SHARED.theme.getIcon("exclude", "reject")
self.loadContent()
self.includedButton.setIcon(self._statusFlags[self.F_INCLUDED])
self.excludedButton.setIcon(self._statusFlags[self.F_EXCLUDED])
self.resetButton.setThemeIcon("revert", "green")
self.resetButton.setThemeIcon("revert", "reset")
##
# Slots
@@ -492,7 +491,7 @@ class _FilterTab(NFixedPage):
default=self._build.getBool("filter.includeNotes")
)
self.filterOpt.addItem(
SHARED.theme.getIcon("unchecked", "red"),
SHARED.theme.getIcon("unchecked", "reject"),
self._build.getLabel("filter.includeInactive"),
"doc:filter.includeInactive",
default=self._build.getBool("filter.includeInactive")
@@ -811,12 +810,12 @@ class _HeadingsTab(NScrollablePage):
"""Update theme elements."""
logger.debug("Theme Update: _HeadingsTab")
self.btnPart.setThemeIcon("edit", "green")
self.btnChapter.setThemeIcon("edit", "green")
self.btnUnnumbered.setThemeIcon("edit", "green")
self.btnScene.setThemeIcon("edit", "green")
self.btnAScene.setThemeIcon("edit", "green")
self.btnSection.setThemeIcon("edit", "green")
self.btnPart.setThemeIcon("edit", "change")
self.btnChapter.setThemeIcon("edit", "change")
self.btnUnnumbered.setThemeIcon("edit", "change")
self.btnScene.setThemeIcon("edit", "change")
self.btnAScene.setThemeIcon("edit", "change")
self.btnSection.setThemeIcon("edit", "change")
self.formSyntax.initHighlighter()
self.formSyntax.rehighlight()
@@ -1318,9 +1317,9 @@ class _FormattingTab(NScrollableForm):
"""Update theme elements."""
logger.debug("Theme Update: _FormattingTab")
self.ignoredKeywordsButton.setThemeIcon("add", "green")
self.btnTextFont.setThemeIcon("font")
self.btnPageHeader.setThemeIcon("revert", "green")
self.ignoredKeywordsButton.setThemeIcon("add", "add")
self.btnTextFont.setThemeIcon("font", "tool")
self.btnPageHeader.setThemeIcon("revert", "reset")
iPx = SHARED.theme.baseIconHeight
self.pixT.setPixmap(SHARED.theme.getPixmap("margin_top", (iPx, iPx)))
+6 -6
View File
@@ -258,7 +258,7 @@ class _OpenProjectPage(QWidget):
# Info / Tool
self.aMissing = QAction(self)
self.aMissing.setIcon(SHARED.theme.getIcon("alert_warn", "orange"))
self.aMissing.setIcon(SHARED.theme.getIcon("alert_warn", "warning"))
self.aMissing.setToolTip(self.tr("The project path is not reachable."))
self.selectedPath = QLineEdit(self)
@@ -534,7 +534,7 @@ class _NewProjectForm(QWidget):
self.projPath = QLineEdit(self)
self.projPath.setReadOnly(True)
self.browsePath = NIconToolButton(self, iSz, "browse")
self.browsePath = NIconToolButton(self, iSz, "browse", "systemio")
self.browsePath.clicked.connect(self._doBrowse)
self.pathBox = QHBoxLayout()
@@ -545,20 +545,20 @@ class _NewProjectForm(QWidget):
self.projFill = QLineEdit(self)
self.projFill.setReadOnly(True)
self.browseFill = NIconToolButton(self, iSz, "document_add", "blue")
self.browseFill = NIconToolButton(self, iSz, "document_add", "add")
self.fillMenu = QMenu(self.browseFill)
self.fillBlank = qtAddAction(self.fillMenu, self.tr("Create a fresh project"))
self.fillBlank.setIcon(SHARED.theme.getIcon("document"))
self.fillBlank.setIcon(SHARED.theme.getIcon("document", "file"))
self.fillBlank.triggered.connect(self._setFillBlank)
self.fillSample = qtAddAction(self.fillMenu, self.tr("Create an example project"))
self.fillSample.setIcon(SHARED.theme.getIcon("document_add", "blue"))
self.fillSample.setIcon(SHARED.theme.getIcon("document_add", "add"))
self.fillSample.triggered.connect(self._setFillSample)
self.fillCopy = qtAddAction(self.fillMenu, self.tr("Copy an existing project"))
self.fillCopy.setIcon(SHARED.theme.getIcon("project_copy", "green"))
self.fillCopy.setIcon(SHARED.theme.getIcon("project_copy", "action"))
self.fillCopy.triggered.connect(self._setFillCopy)
self.browseFill.setMenu(self.fillMenu)
+1 -1
View File
@@ -292,7 +292,7 @@ class GuiWritingStats(NToolDialog):
self.saveMenu.addAction(self.saveJSON)
self.saveMenu.addAction(self.saveCSV)
self.btnSave = NPushButton(self, self.tr("Save As"), bSz, "btn_save", "blue")
self.btnSave = NPushButton(self, self.tr("Save As"), bSz, "btn_save", "action")
self.btnSave.setAutoDefault(False)
self.btnSave.setMenu(self.saveMenu)