Fix a few icons and add icon theme setting
This commit is contained in:
@@ -114,6 +114,7 @@ class Config:
|
||||
self.guiLocale = self._qLocale.name()
|
||||
self.guiTheme = "default" # GUI theme
|
||||
self.guiSyntax = "default_light" # Syntax theme
|
||||
self.guiIcons = "material_rounded_normal" # Icons theme
|
||||
self.guiFont = QFont() # Main GUI font
|
||||
self.guiScale = 1.0 # Set automatically by Theme class
|
||||
self.hideVScroll = False # Hide vertical scroll bars on main widgets
|
||||
@@ -605,6 +606,7 @@ class Config:
|
||||
self.setGuiFont(conf.rdStr(sec, "font", ""))
|
||||
self.guiTheme = conf.rdStr(sec, "theme", self.guiTheme)
|
||||
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.hideVScroll = conf.rdBool(sec, "hidevscroll", self.hideVScroll)
|
||||
self.hideHScroll = conf.rdBool(sec, "hidehscroll", self.hideHScroll)
|
||||
@@ -716,6 +718,7 @@ class Config:
|
||||
"font": self.guiFont.toString(),
|
||||
"theme": str(self.guiTheme),
|
||||
"syntax": str(self.guiSyntax),
|
||||
"icons": str(self.guiIcons),
|
||||
"localisation": str(self.guiLocale),
|
||||
"hidevscroll": str(self.hideVScroll),
|
||||
"hidehscroll": str(self.hideHScroll),
|
||||
|
||||
@@ -267,7 +267,7 @@ class GuiNovelToolBar(QWidget):
|
||||
def updateTheme(self) -> None:
|
||||
"""Update theme elements."""
|
||||
# Icons
|
||||
self.tbNovel.setThemeIcon("cls_novel")
|
||||
self.tbNovel.setThemeIcon("cls_novel", "red")
|
||||
self.tbRefresh.setThemeIcon("refresh", "green")
|
||||
self.tbMore.setThemeIcon("more_vertical")
|
||||
|
||||
|
||||
+15
-10
@@ -307,7 +307,7 @@ class GuiTheme:
|
||||
# Icons
|
||||
defaultIcons = "typicons_light" if backLNess >= 0.5 else "typicons_dark"
|
||||
self.iconCache.loadTheme(self.themeIcons or defaultIcons)
|
||||
self.iconCache.loadNewTheme("")
|
||||
self.iconCache.loadNewTheme(CONFIG.guiIcons)
|
||||
|
||||
# Apply Styles
|
||||
QApplication.setPalette(self._guiPalette)
|
||||
@@ -627,15 +627,20 @@ class GuiIcons:
|
||||
|
||||
def loadNewTheme(self, iconTheme: str) -> bool:
|
||||
"""Load new style theme."""
|
||||
themePath = self._iconPath / "material_rounded_normal.icons"
|
||||
with open(themePath, mode="r", encoding="utf-8") as icons:
|
||||
for icon in icons:
|
||||
bits = icon.partition("=")
|
||||
key = bits[0].strip()
|
||||
value = bits[2].strip()
|
||||
if key and value:
|
||||
if key.startswith("icon:"):
|
||||
self._svgData[key[5:]] = value.encode("utf-8")
|
||||
themePath = self._iconPath / f"{iconTheme}.icons"
|
||||
try:
|
||||
with open(themePath, mode="r", encoding="utf-8") as icons:
|
||||
for icon in icons:
|
||||
bits = icon.partition("=")
|
||||
key = bits[0].strip()
|
||||
value = bits[2].strip()
|
||||
if key and value:
|
||||
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
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ class GuiManuscript(NToolDialog):
|
||||
self.tbAdd.setStyleSheet(buttonStyle)
|
||||
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.setStyleSheet(buttonStyle)
|
||||
self.tbDel.clicked.connect(self._deleteSelectedBuild)
|
||||
|
||||
Reference in New Issue
Block a user