Use the simplified theme icon setter where possible

This commit is contained in:
Veronica Berglyd Olsen
2024-04-01 20:38:16 +02:00
parent 24e45fb661
commit b44072a9fa
6 changed files with 45 additions and 50 deletions
+18 -18
View File
@@ -2365,16 +2365,16 @@ class GuiDocToolBar(QWidget):
palette.setColor(QPalette.ColorRole.Text, SHARED.theme.colText) palette.setColor(QPalette.ColorRole.Text, SHARED.theme.colText)
self.setPalette(palette) self.setPalette(palette)
self.tbBoldMD.setIcon(SHARED.theme.getIcon("fmt_bold-md")) self.tbBoldMD.setThemeIcon("fmt_bold-md")
self.tbItalicMD.setIcon(SHARED.theme.getIcon("fmt_italic-md")) self.tbItalicMD.setThemeIcon("fmt_italic-md")
self.tbStrikeMD.setIcon(SHARED.theme.getIcon("fmt_strike-md")) self.tbStrikeMD.setThemeIcon("fmt_strike-md")
self.tbBold.setIcon(SHARED.theme.getIcon("fmt_bold")) self.tbBold.setThemeIcon("fmt_bold")
self.tbItalic.setIcon(SHARED.theme.getIcon("fmt_italic")) self.tbItalic.setThemeIcon("fmt_italic")
self.tbStrike.setIcon(SHARED.theme.getIcon("fmt_strike")) self.tbStrike.setThemeIcon("fmt_strike")
self.tbUnderline.setIcon(SHARED.theme.getIcon("fmt_underline")) self.tbUnderline.setThemeIcon("fmt_underline")
self.tbMark.setIcon(SHARED.theme.getIcon("fmt_mark")) self.tbMark.setThemeIcon("fmt_mark")
self.tbSuperscript.setIcon(SHARED.theme.getIcon("fmt_superscript")) self.tbSuperscript.setThemeIcon("fmt_superscript")
self.tbSubscript.setIcon(SHARED.theme.getIcon("fmt_subscript")) self.tbSubscript.setThemeIcon("fmt_subscript")
return return
@@ -2634,8 +2634,8 @@ class GuiDocEditSearch(QFrame):
self.toggleProject.setIcon(SHARED.theme.getIcon("search_project")) self.toggleProject.setIcon(SHARED.theme.getIcon("search_project"))
self.toggleMatchCap.setIcon(SHARED.theme.getIcon("search_preserve")) self.toggleMatchCap.setIcon(SHARED.theme.getIcon("search_preserve"))
self.cancelSearch.setIcon(SHARED.theme.getIcon("search_cancel")) self.cancelSearch.setIcon(SHARED.theme.getIcon("search_cancel"))
self.searchButton.setIcon(SHARED.theme.getIcon("search")) self.searchButton.setThemeIcon("search")
self.replaceButton.setIcon(SHARED.theme.getIcon("search_replace")) self.replaceButton.setThemeIcon("search_replace")
# Set stylesheets # Set stylesheets
self.searchOpt.setStyleSheet("QToolBar {padding: 0;}") self.searchOpt.setStyleSheet("QToolBar {padding: 0;}")
@@ -2913,11 +2913,11 @@ class GuiDocEditHeader(QWidget):
def updateTheme(self) -> None: def updateTheme(self) -> None:
"""Update theme elements.""" """Update theme elements."""
self.tbButton.setIcon(SHARED.theme.getIcon("menu")) self.tbButton.setThemeIcon("menu")
self.outlineButton.setIcon(SHARED.theme.getIcon("list")) self.outlineButton.setThemeIcon("list")
self.searchButton.setIcon(SHARED.theme.getIcon("search")) self.searchButton.setThemeIcon("search")
self.minmaxButton.setIcon(SHARED.theme.getIcon("maximise")) self.minmaxButton.setThemeIcon("maximise")
self.closeButton.setIcon(SHARED.theme.getIcon("close")) self.closeButton.setThemeIcon("close")
buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON) buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON)
self.tbButton.setStyleSheet(buttonStyle) self.tbButton.setStyleSheet(buttonStyle)
@@ -2985,7 +2985,7 @@ class GuiDocEditHeader(QWidget):
@pyqtSlot(bool) @pyqtSlot(bool)
def _focusModeChanged(self, focusMode: bool) -> None: def _focusModeChanged(self, focusMode: bool) -> None:
"""Update minimise/maximise icon of the Focus Mode button.""" """Update minimise/maximise icon of the Focus Mode button."""
self.minmaxButton.setIcon(SHARED.theme.getIcon("minimise" if focusMode else "maximise")) self.minmaxButton.setThemeIcon("minimise" if focusMode else "maximise")
return return
## ##
+6 -6
View File
@@ -745,11 +745,11 @@ class GuiDocViewHeader(QWidget):
def updateTheme(self) -> None: def updateTheme(self) -> None:
"""Update theme elements.""" """Update theme elements."""
self.outlineButton.setIcon(SHARED.theme.getIcon("list")) self.outlineButton.setThemeIcon("list")
self.backButton.setIcon(SHARED.theme.getIcon("backward")) self.backButton.setThemeIcon("backward")
self.forwardButton.setIcon(SHARED.theme.getIcon("forward")) self.forwardButton.setThemeIcon("forward")
self.refreshButton.setIcon(SHARED.theme.getIcon("refresh")) self.refreshButton.setThemeIcon("refresh")
self.closeButton.setIcon(SHARED.theme.getIcon("close")) self.closeButton.setThemeIcon("close")
buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON) buttonStyle = SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON)
self.outlineButton.setStyleSheet(buttonStyle) self.outlineButton.setStyleSheet(buttonStyle)
@@ -921,7 +921,7 @@ class GuiDocViewFooter(QWidget):
fPx = int(0.9*SHARED.theme.fontPixelSize) fPx = int(0.9*SHARED.theme.fontPixelSize)
bulletIcon = SHARED.theme.getToggleIcon("bullet", (fPx, fPx)) bulletIcon = SHARED.theme.getToggleIcon("bullet", (fPx, fPx))
self.showHide.setIcon(SHARED.theme.getIcon("panel")) self.showHide.setThemeIcon("panel")
self.showComments.setIcon(bulletIcon) self.showComments.setIcon(bulletIcon)
self.showSynopsis.setIcon(bulletIcon) self.showSynopsis.setIcon(bulletIcon)
+3 -3
View File
@@ -38,6 +38,7 @@ from novelwriter.common import checkInt
from novelwriter.constants import nwHeaders, nwLabels, nwLists, trConst from novelwriter.constants import nwHeaders, nwLabels, nwLists, trConst
from novelwriter.core.index import IndexHeading, IndexItem from novelwriter.core.index import IndexHeading, IndexItem
from novelwriter.enum import nwDocMode, nwItemClass from novelwriter.enum import nwDocMode, nwItemClass
from novelwriter.extensions.modified import NIconToolButton
from novelwriter.gui.theme import STYLES_FLAT_TABS, STYLES_MIN_TOOLBUTTON from novelwriter.gui.theme import STYLES_FLAT_TABS, STYLES_MIN_TOOLBUTTON
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -65,8 +66,7 @@ class GuiDocViewerPanel(QWidget):
self.aInactive.setCheckable(True) self.aInactive.setCheckable(True)
self.aInactive.toggled.connect(self._toggleHideInactive) self.aInactive.toggled.connect(self._toggleHideInactive)
self.optsButton = QToolButton(self) self.optsButton = NIconToolButton(self, iSz)
self.optsButton.setIconSize(iSz)
self.optsButton.setMenu(self.optsMenu) self.optsButton.setMenu(self.optsMenu)
self.optsButton.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup) self.optsButton.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
@@ -100,7 +100,7 @@ class GuiDocViewerPanel(QWidget):
def updateTheme(self, updateTabs: bool = True) -> None: def updateTheme(self, updateTabs: bool = True) -> None:
"""Update theme elements.""" """Update theme elements."""
self.optsButton.setIcon(SHARED.theme.getIcon("menu")) self.optsButton.setThemeIcon("menu")
self.optsButton.setStyleSheet(SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON)) self.optsButton.setStyleSheet(SHARED.theme.getStyleSheet(STYLES_MIN_TOOLBUTTON))
self.mainTabs.setStyleSheet(SHARED.theme.getStyleSheet(STYLES_FLAT_TABS)) self.mainTabs.setStyleSheet(SHARED.theme.getStyleSheet(STYLES_FLAT_TABS))
self.updateHandle(self._lastHandle) self.updateHandle(self._lastHandle)
+3 -3
View File
@@ -270,9 +270,9 @@ class GuiNovelToolBar(QWidget):
def updateTheme(self) -> None: def updateTheme(self) -> None:
"""Update theme elements.""" """Update theme elements."""
# Icons # Icons
self.tbNovel.setIcon(SHARED.theme.getIcon("cls_novel")) self.tbNovel.setThemeIcon("cls_novel")
self.tbRefresh.setIcon(SHARED.theme.getIcon("refresh")) self.tbRefresh.setThemeIcon("refresh")
self.tbMore.setIcon(SHARED.theme.getIcon("menu")) self.tbMore.setThemeIcon("menu")
qPalette = self.palette() qPalette = self.palette()
qPalette.setBrush(QPalette.ColorRole.Window, qPalette.base()) qPalette.setBrush(QPalette.ColorRole.Window, qPalette.base())
+6 -5
View File
@@ -385,16 +385,17 @@ class GuiProjectToolBar(QWidget):
self.tbAdd.setStyleSheet(buttonStyle) self.tbAdd.setStyleSheet(buttonStyle)
self.tbMore.setStyleSheet(buttonStyle) self.tbMore.setStyleSheet(buttonStyle)
self.tbQuick.setIcon(SHARED.theme.getIcon("bookmark")) self.tbQuick.setThemeIcon("bookmark")
self.tbMoveU.setIcon(SHARED.theme.getIcon("up")) self.tbMoveU.setThemeIcon("up")
self.tbMoveD.setIcon(SHARED.theme.getIcon("down")) self.tbMoveD.setThemeIcon("down")
self.tbAdd.setThemeIcon("add")
self.tbMore.setThemeIcon("menu")
self.aAddEmpty.setIcon(SHARED.theme.getIcon("proj_document")) self.aAddEmpty.setIcon(SHARED.theme.getIcon("proj_document"))
self.aAddChap.setIcon(SHARED.theme.getIcon("proj_chapter")) self.aAddChap.setIcon(SHARED.theme.getIcon("proj_chapter"))
self.aAddScene.setIcon(SHARED.theme.getIcon("proj_scene")) self.aAddScene.setIcon(SHARED.theme.getIcon("proj_scene"))
self.aAddNote.setIcon(SHARED.theme.getIcon("proj_note")) self.aAddNote.setIcon(SHARED.theme.getIcon("proj_note"))
self.aAddFolder.setIcon(SHARED.theme.getIcon("proj_folder")) self.aAddFolder.setIcon(SHARED.theme.getIcon("proj_folder"))
self.tbAdd.setIcon(SHARED.theme.getIcon("add"))
self.tbMore.setIcon(SHARED.theme.getIcon("menu"))
self.buildQuickLinksMenu() self.buildQuickLinksMenu()
self._buildRootMenu() self._buildRootMenu()
+9 -15
View File
@@ -130,30 +130,24 @@ class GuiSideBar(QWidget):
buttonStyle = SHARED.theme.getStyleSheet(STYLES_BIG_TOOLBUTTON) buttonStyle = SHARED.theme.getStyleSheet(STYLES_BIG_TOOLBUTTON)
self.tbProject.setIcon(SHARED.theme.getIcon("view_editor"))
self.tbProject.setStyleSheet(buttonStyle) self.tbProject.setStyleSheet(buttonStyle)
self.tbNovel.setIcon(SHARED.theme.getIcon("view_novel"))
self.tbNovel.setStyleSheet(buttonStyle) self.tbNovel.setStyleSheet(buttonStyle)
self.tbSearch.setIcon(SHARED.theme.getIcon("view_search"))
self.tbSearch.setStyleSheet(buttonStyle) self.tbSearch.setStyleSheet(buttonStyle)
self.tbOutline.setIcon(SHARED.theme.getIcon("view_outline"))
self.tbOutline.setStyleSheet(buttonStyle) self.tbOutline.setStyleSheet(buttonStyle)
self.tbBuild.setIcon(SHARED.theme.getIcon("view_build"))
self.tbBuild.setStyleSheet(buttonStyle) self.tbBuild.setStyleSheet(buttonStyle)
self.tbDetails.setIcon(SHARED.theme.getIcon("proj_details"))
self.tbDetails.setStyleSheet(buttonStyle) self.tbDetails.setStyleSheet(buttonStyle)
self.tbStats.setIcon(SHARED.theme.getIcon("proj_stats"))
self.tbStats.setStyleSheet(buttonStyle) self.tbStats.setStyleSheet(buttonStyle)
self.tbSettings.setIcon(SHARED.theme.getIcon("settings"))
self.tbSettings.setStyleSheet(buttonStyle) self.tbSettings.setStyleSheet(buttonStyle)
self.tbProject.setThemeIcon("view_editor")
self.tbNovel.setThemeIcon("view_novel")
self.tbSearch.setThemeIcon("view_search")
self.tbOutline.setThemeIcon("view_outline")
self.tbBuild.setThemeIcon("view_build")
self.tbDetails.setThemeIcon("proj_details")
self.tbStats.setThemeIcon("proj_stats")
self.tbSettings.setThemeIcon("settings")
return return
# END Class GuiSideBar # END Class GuiSideBar