Fix a few icons and add icon theme setting

This commit is contained in:
Veronica Berglyd Olsen
2025-01-08 00:21:08 +01:00
parent 5cc29a7605
commit fa046897dc
4 changed files with 20 additions and 12 deletions
+3
View File
@@ -114,6 +114,7 @@ class Config:
self.guiLocale = self._qLocale.name() self.guiLocale = self._qLocale.name()
self.guiTheme = "default" # GUI theme self.guiTheme = "default" # GUI theme
self.guiSyntax = "default_light" # Syntax theme self.guiSyntax = "default_light" # Syntax theme
self.guiIcons = "material_rounded_normal" # Icons theme
self.guiFont = QFont() # Main GUI font self.guiFont = QFont() # Main GUI font
self.guiScale = 1.0 # Set automatically by Theme class self.guiScale = 1.0 # Set automatically by Theme class
self.hideVScroll = False # Hide vertical scroll bars on main widgets self.hideVScroll = False # Hide vertical scroll bars on main widgets
@@ -605,6 +606,7 @@ class Config:
self.setGuiFont(conf.rdStr(sec, "font", "")) self.setGuiFont(conf.rdStr(sec, "font", ""))
self.guiTheme = conf.rdStr(sec, "theme", self.guiTheme) self.guiTheme = conf.rdStr(sec, "theme", self.guiTheme)
self.guiSyntax = conf.rdStr(sec, "syntax", self.guiSyntax) self.guiSyntax = conf.rdStr(sec, "syntax", self.guiSyntax)
self.guiIcons = conf.rdStr(sec, "icons", self.guiIcons)
self.guiLocale = conf.rdStr(sec, "localisation", self.guiLocale) self.guiLocale = conf.rdStr(sec, "localisation", self.guiLocale)
self.hideVScroll = conf.rdBool(sec, "hidevscroll", self.hideVScroll) self.hideVScroll = conf.rdBool(sec, "hidevscroll", self.hideVScroll)
self.hideHScroll = conf.rdBool(sec, "hidehscroll", self.hideHScroll) self.hideHScroll = conf.rdBool(sec, "hidehscroll", self.hideHScroll)
@@ -716,6 +718,7 @@ class Config:
"font": self.guiFont.toString(), "font": self.guiFont.toString(),
"theme": str(self.guiTheme), "theme": str(self.guiTheme),
"syntax": str(self.guiSyntax), "syntax": str(self.guiSyntax),
"icons": str(self.guiIcons),
"localisation": str(self.guiLocale), "localisation": str(self.guiLocale),
"hidevscroll": str(self.hideVScroll), "hidevscroll": str(self.hideVScroll),
"hidehscroll": str(self.hideHScroll), "hidehscroll": str(self.hideHScroll),
+1 -1
View File
@@ -267,7 +267,7 @@ class GuiNovelToolBar(QWidget):
def updateTheme(self) -> None: def updateTheme(self) -> None:
"""Update theme elements.""" """Update theme elements."""
# Icons # Icons
self.tbNovel.setThemeIcon("cls_novel") self.tbNovel.setThemeIcon("cls_novel", "red")
self.tbRefresh.setThemeIcon("refresh", "green") self.tbRefresh.setThemeIcon("refresh", "green")
self.tbMore.setThemeIcon("more_vertical") self.tbMore.setThemeIcon("more_vertical")
+15 -10
View File
@@ -307,7 +307,7 @@ class GuiTheme:
# Icons # Icons
defaultIcons = "typicons_light" if backLNess >= 0.5 else "typicons_dark" defaultIcons = "typicons_light" if backLNess >= 0.5 else "typicons_dark"
self.iconCache.loadTheme(self.themeIcons or defaultIcons) self.iconCache.loadTheme(self.themeIcons or defaultIcons)
self.iconCache.loadNewTheme("") self.iconCache.loadNewTheme(CONFIG.guiIcons)
# Apply Styles # Apply Styles
QApplication.setPalette(self._guiPalette) QApplication.setPalette(self._guiPalette)
@@ -627,15 +627,20 @@ class GuiIcons:
def loadNewTheme(self, iconTheme: str) -> bool: def loadNewTheme(self, iconTheme: str) -> bool:
"""Load new style theme.""" """Load new style theme."""
themePath = self._iconPath / "material_rounded_normal.icons" themePath = self._iconPath / f"{iconTheme}.icons"
with open(themePath, mode="r", encoding="utf-8") as icons: try:
for icon in icons: with open(themePath, mode="r", encoding="utf-8") as icons:
bits = icon.partition("=") for icon in icons:
key = bits[0].strip() bits = icon.partition("=")
value = bits[2].strip() key = bits[0].strip()
if key and value: value = bits[2].strip()
if key.startswith("icon:"): if key and value:
self._svgData[key[5:]] = value.encode("utf-8") if key.startswith("icon:"):
self._svgData[key[5:]] = value.encode("utf-8")
except Exception:
logger.error("Could not load icon theme settings from: %s", themePath)
logException()
return False
return True return True
+1 -1
View File
@@ -113,7 +113,7 @@ class GuiManuscript(NToolDialog):
self.tbAdd.setStyleSheet(buttonStyle) self.tbAdd.setStyleSheet(buttonStyle)
self.tbAdd.clicked.connect(self._createNewBuild) self.tbAdd.clicked.connect(self._createNewBuild)
self.tbDel = NIconToolButton(self, iSz, "remove") self.tbDel = NIconToolButton(self, iSz, "remove", "red")
self.tbDel.setToolTip(self.tr("Delete Selected Build")) self.tbDel.setToolTip(self.tr("Delete Selected Build"))
self.tbDel.setStyleSheet(buttonStyle) self.tbDel.setStyleSheet(buttonStyle)
self.tbDel.clicked.connect(self._deleteSelectedBuild) self.tbDel.clicked.connect(self._deleteSelectedBuild)