Also allow custom icon themes

This commit is contained in:
Veronica Berglyd Olsen
2022-12-20 12:50:21 +01:00
parent 6c76e31e0b
commit 1664f92cc8
4 changed files with 15 additions and 10 deletions
+9 -6
View File
@@ -52,14 +52,16 @@ modify it as you like.
`novelwriter/assets/syntax <https://github.com/vkbo/novelWriter/tree/main/novelwriter/assets/syntax>`_.
* The existing GUI themes are stored in
`novelwriter/assets/themes <https://github.com/vkbo/novelWriter/tree/main/novelwriter/assets/themes>`_.
* The existing icon themes are stored in
`novelwriter/assets/icons <https://github.com/vkbo/novelWriter/tree/main/novelwriter/assets/icons>`_.
Remember to also change the name of your theme by modifying the ``name`` setting at the top of the
file, otherwise you may not be able to distinguish them in :guilabel:`Preferences`.
For novelWriter to be able to locate the custom theme files, you must copy them to the
:ref:`a_locations_data` location in your home or user area. There should be a folder there named
``syntax`` for syntax themes and just ``themes`` for GUI themes. These folders are created the
first time you start novelWriter.
``syntax`` for syntax themes, just ``themes`` for GUI themes, and ``icons`` for icon themes. These
folders are created the first time you start novelWriter.
Once the files are copied there, they should show up in :guilabel:`Preferences` with the label you
set as ``name`` inside the file.
@@ -70,8 +72,8 @@ set as ``name`` inside the file.
theme colour scheme.
Gustom GUI Theme
----------------
Gustom GUI and Icons Theme
--------------------------
A GUI theme conf file consists of the follwing settings:
@@ -109,8 +111,9 @@ A GUI theme conf file consists of the follwing settings:
statusunsaved = 100, 100, 100
In the Main section you must at least define the ``name`` and ``icontheme`` settings. The
``icontheme`` settings should correspond to one of the internal icon themes. Either
``typicons_light`` or ``typicons_dark``.
``icontheme`` settings should correspond to one of the internal icon themes, either
``typicons_light`` or ``typicons_dark``, or to an icon theme in your custom icons directory. The
setting must match the icon theme's folder name.
The Palette values correspond the the Qt enum values for QPalette::ColorRole, see the
`Qt documentation <https://doc.qt.io/qt-5.15/qpalette.html#ColorRole-enum>`_ for more details. The
+2 -1
View File
@@ -461,10 +461,11 @@ class Config:
self._confPath.mkdir(exist_ok=True)
self._dataPath.mkdir(exist_ok=True)
# Also create the syntax and themes folders if possible
# Also create the syntax, themes and icons folders if possible
if self._dataPath.is_dir():
(self._dataPath / "syntax").mkdir(exist_ok=True)
(self._dataPath / "themes").mkdir(exist_ok=True)
(self._dataPath / "icons").mkdir(exist_ok=True)
# Check if config file exists, and load it. If not, we save defaults
if (self._confPath / nwFiles.CONF_FILE).is_file():
+4 -2
View File
@@ -507,8 +507,10 @@ class GuiIcons:
self._themeMap = {}
themePath = self._iconPath / iconTheme
if not themePath.is_dir():
logger.warning("No icons loaded for '%s'", iconTheme)
return False
themePath = self.mainConf.dataPath("icons") / iconTheme
if not themePath.is_dir():
logger.warning("No icons loaded for '%s'", iconTheme)
return False
themeConf = themePath / self._confName
logger.info("Loading icon theme '%s'", iconTheme)
-1
View File
@@ -282,7 +282,6 @@ def testGuiTheme_Icons(qtbot, caplog, monkeypatch, nwGUI, fncPath):
# Load a broken theme file
iconsDir = fncPath / "icons"
testIcons = iconsDir / "testicons"
iconsDir.mkdir()
testIcons.mkdir()
writeFile(testIcons / "icons.conf", (
"[Main]\n"