Make icon theme a part of the GUI theme (solves #1172)
This commit is contained in:
@@ -1,2 +1,3 @@
|
|||||||
[Main]
|
[Main]
|
||||||
name = Default System Theme
|
name = Default Theme
|
||||||
|
icontheme = typicons_light
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ credit = Veronica Berglyd Olsen
|
|||||||
url = https://github.com/vkbo/novelWriter
|
url = https://github.com/vkbo/novelWriter
|
||||||
license = CC BY-SA 4.0
|
license = CC BY-SA 4.0
|
||||||
licenseurl = https://creativecommons.org/licenses/by-sa/4.0/
|
licenseurl = https://creativecommons.org/licenses/by-sa/4.0/
|
||||||
|
icontheme = typicons_dark
|
||||||
|
|
||||||
[Palette]
|
[Palette]
|
||||||
window = 54, 54, 54
|
window = 54, 54, 54
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ credit = Ethan Schoonover
|
|||||||
url = https://ethanschoonover.com/solarized/
|
url = https://ethanschoonover.com/solarized/
|
||||||
license = MIT
|
license = MIT
|
||||||
licenseurl = https://github.com/altercation/solarized/blob/master/LICENSE
|
licenseurl = https://github.com/altercation/solarized/blob/master/LICENSE
|
||||||
|
icontheme = typicons_dark
|
||||||
|
|
||||||
[Palette]
|
[Palette]
|
||||||
window = 0, 43, 54
|
window = 0, 43, 54
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ credit = Ethan Schoonover
|
|||||||
url = https://ethanschoonover.com/solarized/
|
url = https://ethanschoonover.com/solarized/
|
||||||
license = MIT
|
license = MIT
|
||||||
licenseurl = https://github.com/altercation/solarized/blob/master/LICENSE
|
licenseurl = https://github.com/altercation/solarized/blob/master/LICENSE
|
||||||
|
icontheme = typicons_light
|
||||||
|
|
||||||
[Palette]
|
[Palette]
|
||||||
window = 238, 232, 213
|
window = 238, 232, 213
|
||||||
|
|||||||
@@ -508,12 +508,6 @@ class Config:
|
|||||||
logger.info("Using straight double quotes, so disabling auto-replace")
|
logger.info("Using straight double quotes, so disabling auto-replace")
|
||||||
self.doReplaceDQuote = False
|
self.doReplaceDQuote = False
|
||||||
|
|
||||||
# Check deprecated settings
|
|
||||||
if self.guiIcons in ("typicons_colour_dark", "typicons_grey_dark"):
|
|
||||||
self.guiIcons = "typicons_dark"
|
|
||||||
elif self.guiIcons in ("typicons_colour_light", "typicons_grey_light"):
|
|
||||||
self.guiIcons = "typicons_light"
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def saveConfig(self):
|
def saveConfig(self):
|
||||||
|
|||||||
@@ -185,22 +185,6 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
self.tr("Requires restart.")
|
self.tr("Requires restart.")
|
||||||
)
|
)
|
||||||
|
|
||||||
# Select Icon Theme
|
|
||||||
self.guiIcons = QComboBox()
|
|
||||||
self.guiIcons.setMinimumWidth(minWidth)
|
|
||||||
self.iconCache = self.mainTheme.iconCache.listThemes()
|
|
||||||
for iconDir, iconName in self.iconCache:
|
|
||||||
self.guiIcons.addItem(iconName, iconDir)
|
|
||||||
iconIdx = self.guiIcons.findData(self.mainConf.guiIcons)
|
|
||||||
if iconIdx != -1:
|
|
||||||
self.guiIcons.setCurrentIndex(iconIdx)
|
|
||||||
|
|
||||||
self.mainForm.addRow(
|
|
||||||
self.tr("Main icon theme"),
|
|
||||||
self.guiIcons,
|
|
||||||
self.tr("Requires restart.")
|
|
||||||
)
|
|
||||||
|
|
||||||
# Editor Theme
|
# Editor Theme
|
||||||
self.guiSyntax = QComboBox()
|
self.guiSyntax = QComboBox()
|
||||||
self.guiSyntax.setMinimumWidth(self.mainConf.pxInt(200))
|
self.guiSyntax.setMinimumWidth(self.mainConf.pxInt(200))
|
||||||
@@ -288,7 +272,6 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
"""
|
"""
|
||||||
guiLang = self.guiLang.currentData()
|
guiLang = self.guiLang.currentData()
|
||||||
guiTheme = self.guiTheme.currentData()
|
guiTheme = self.guiTheme.currentData()
|
||||||
guiIcons = self.guiIcons.currentData()
|
|
||||||
guiSyntax = self.guiSyntax.currentData()
|
guiSyntax = self.guiSyntax.currentData()
|
||||||
guiFont = self.guiFont.text()
|
guiFont = self.guiFont.text()
|
||||||
guiFontSize = self.guiFontSize.value()
|
guiFontSize = self.guiFontSize.value()
|
||||||
@@ -298,7 +281,6 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
needsRestart = False
|
needsRestart = False
|
||||||
needsRestart |= self.mainConf.guiLang != guiLang
|
needsRestart |= self.mainConf.guiLang != guiLang
|
||||||
needsRestart |= self.mainConf.guiTheme != guiTheme
|
needsRestart |= self.mainConf.guiTheme != guiTheme
|
||||||
needsRestart |= self.mainConf.guiIcons != guiIcons
|
|
||||||
needsRestart |= self.mainConf.guiFont != guiFont
|
needsRestart |= self.mainConf.guiFont != guiFont
|
||||||
needsRestart |= self.mainConf.guiFontSize != guiFontSize
|
needsRestart |= self.mainConf.guiFontSize != guiFontSize
|
||||||
|
|
||||||
@@ -308,7 +290,6 @@ class GuiPreferencesGeneral(QWidget):
|
|||||||
|
|
||||||
self.mainConf.guiLang = guiLang
|
self.mainConf.guiLang = guiLang
|
||||||
self.mainConf.guiTheme = guiTheme
|
self.mainConf.guiTheme = guiTheme
|
||||||
self.mainConf.guiIcons = guiIcons
|
|
||||||
self.mainConf.guiSyntax = guiSyntax
|
self.mainConf.guiSyntax = guiSyntax
|
||||||
self.mainConf.guiFont = guiFont
|
self.mainConf.guiFont = guiFont
|
||||||
self.mainConf.guiFontSize = guiFontSize
|
self.mainConf.guiFontSize = guiFontSize
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ class GuiTheme:
|
|||||||
self.themeUrl = ""
|
self.themeUrl = ""
|
||||||
self.themeLicense = ""
|
self.themeLicense = ""
|
||||||
self.themeLicenseUrl = ""
|
self.themeLicenseUrl = ""
|
||||||
|
self.themeIcons = ""
|
||||||
|
|
||||||
# GUI
|
# GUI
|
||||||
self.statNone = [120, 120, 120]
|
self.statNone = [120, 120, 120]
|
||||||
@@ -267,6 +268,7 @@ class GuiTheme:
|
|||||||
self.themeUrl = confParser.rdStr(cnfSec, "url", "")
|
self.themeUrl = confParser.rdStr(cnfSec, "url", "")
|
||||||
self.themeLicense = confParser.rdStr(cnfSec, "license", "N/A")
|
self.themeLicense = confParser.rdStr(cnfSec, "license", "N/A")
|
||||||
self.themeLicenseUrl = confParser.rdStr(cnfSec, "licenseurl", "")
|
self.themeLicenseUrl = confParser.rdStr(cnfSec, "licenseurl", "")
|
||||||
|
self.themeIcons = confParser.rdStr(cnfSec, "icontheme", "")
|
||||||
|
|
||||||
# Palette
|
# Palette
|
||||||
cnfSec = "Palette"
|
cnfSec = "Palette"
|
||||||
@@ -293,6 +295,9 @@ class GuiTheme:
|
|||||||
self.statUnsaved = self._loadColour(confParser, cnfSec, "statusunsaved")
|
self.statUnsaved = self._loadColour(confParser, cnfSec, "statusunsaved")
|
||||||
self.statSaved = self._loadColour(confParser, cnfSec, "statussaved")
|
self.statSaved = self._loadColour(confParser, cnfSec, "statussaved")
|
||||||
|
|
||||||
|
# Set Icon Theme
|
||||||
|
self.mainConf.guiIcons = self.themeIcons
|
||||||
|
|
||||||
# CSS File
|
# CSS File
|
||||||
cssData = readTextFile(self.cssFile)
|
cssData = readTextFile(self.cssFile)
|
||||||
if cssData:
|
if cssData:
|
||||||
@@ -492,7 +497,6 @@ class GuiIcons:
|
|||||||
# Storage
|
# Storage
|
||||||
self._qIcons = {}
|
self._qIcons = {}
|
||||||
self._themeMap = {}
|
self._themeMap = {}
|
||||||
self._themeList = []
|
|
||||||
self._headerDec = []
|
self._headerDec = []
|
||||||
self._confName = "icons.conf"
|
self._confName = "icons.conf"
|
||||||
|
|
||||||
@@ -668,28 +672,6 @@ class GuiIcons:
|
|||||||
]
|
]
|
||||||
return self._headerDec[minmax(hLevel, 0, 4)]
|
return self._headerDec[minmax(hLevel, 0, 4)]
|
||||||
|
|
||||||
def listThemes(self):
|
|
||||||
"""Scan the icons themes folder and list all themes.
|
|
||||||
"""
|
|
||||||
if self._themeList:
|
|
||||||
return self._themeList
|
|
||||||
|
|
||||||
confParser = NWConfigParser()
|
|
||||||
for themeDir in os.listdir(self._iconPath):
|
|
||||||
themePath = os.path.join(self._iconPath, themeDir)
|
|
||||||
if not os.path.isdir(themePath):
|
|
||||||
continue
|
|
||||||
|
|
||||||
logger.debug("Checking icon theme config for '%s'", themeDir)
|
|
||||||
themeConf = os.path.join(themePath, self._confName)
|
|
||||||
themeName = _loadInternalName(confParser, themeConf)
|
|
||||||
if themeName:
|
|
||||||
self._themeList.append((themeDir, themeName))
|
|
||||||
|
|
||||||
self._themeList = sorted(self._themeList, key=lambda x: x[1])
|
|
||||||
|
|
||||||
return self._themeList
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -192,32 +192,6 @@ def testBaseConfig_Init(monkeypatch, tmpDir, fncDir, outDir, refDir, filesDir):
|
|||||||
tstConf.doReplaceSQuote = orDoSng
|
tstConf.doReplaceSQuote = orDoSng
|
||||||
assert tstConf.saveConfig() is True
|
assert tstConf.saveConfig() is True
|
||||||
|
|
||||||
# Test Correcting icon theme
|
|
||||||
origIcons = tstConf.guiIcons
|
|
||||||
|
|
||||||
tstConf.guiIcons = "typicons_colour_dark"
|
|
||||||
assert tstConf.saveConfig() is True
|
|
||||||
assert tstConf.loadConfig() is True
|
|
||||||
assert tstConf.guiIcons == "typicons_dark"
|
|
||||||
|
|
||||||
tstConf.guiIcons = "typicons_grey_dark"
|
|
||||||
assert tstConf.saveConfig() is True
|
|
||||||
assert tstConf.loadConfig() is True
|
|
||||||
assert tstConf.guiIcons == "typicons_dark"
|
|
||||||
|
|
||||||
tstConf.guiIcons = "typicons_colour_light"
|
|
||||||
assert tstConf.saveConfig() is True
|
|
||||||
assert tstConf.loadConfig() is True
|
|
||||||
assert tstConf.guiIcons == "typicons_light"
|
|
||||||
|
|
||||||
tstConf.guiIcons = "typicons_grey_light"
|
|
||||||
assert tstConf.saveConfig() is True
|
|
||||||
assert tstConf.loadConfig() is True
|
|
||||||
assert tstConf.guiIcons == "typicons_light"
|
|
||||||
|
|
||||||
tstConf.guiIcons = origIcons
|
|
||||||
assert tstConf.saveConfig()
|
|
||||||
|
|
||||||
# Localisation
|
# Localisation
|
||||||
# ============
|
# ============
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ def testGuiTheme_Main(qtbot, monkeypatch, nwMinimal, tmpDir):
|
|||||||
assert novelwriter.CONFIG.confPath == nwMinimal
|
assert novelwriter.CONFIG.confPath == nwMinimal
|
||||||
novelwriter.CONFIG.guiTheme = "default_dark"
|
novelwriter.CONFIG.guiTheme = "default_dark"
|
||||||
novelwriter.CONFIG.guiSyntax = "tomorrow_night_eighties"
|
novelwriter.CONFIG.guiSyntax = "tomorrow_night_eighties"
|
||||||
novelwriter.CONFIG.guiIcons = "typicons_colour_dark"
|
novelwriter.CONFIG.guiIcons = "typicons_dark"
|
||||||
novelwriter.CONFIG.guiFont = "Cantarell"
|
novelwriter.CONFIG.guiFont = "Cantarell"
|
||||||
novelwriter.CONFIG.guiFontSize = 11
|
novelwriter.CONFIG.guiFontSize = 11
|
||||||
novelwriter.CONFIG.confChanged = True
|
novelwriter.CONFIG.confChanged = True
|
||||||
|
|||||||
Reference in New Issue
Block a user