From 1664f92cc8bcb0534737b2f356714cce052e8633 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Tue, 20 Dec 2022 12:50:21 +0100 Subject: [PATCH] Also allow custom icon themes --- docs/source/int_customise.rst | 15 +++++++++------ novelwriter/config.py | 3 ++- novelwriter/gui/theme.py | 6 ++++-- tests/test_gui/test_gui_theme.py | 1 - 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/source/int_customise.rst b/docs/source/int_customise.rst index 27b94284..07b130b4 100644 --- a/docs/source/int_customise.rst +++ b/docs/source/int_customise.rst @@ -52,14 +52,16 @@ modify it as you like. `novelwriter/assets/syntax `_. * The existing GUI themes are stored in `novelwriter/assets/themes `_. +* The existing icon themes are stored in + `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 `_ for more details. The diff --git a/novelwriter/config.py b/novelwriter/config.py index b6708add..e60a9444 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -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(): diff --git a/novelwriter/gui/theme.py b/novelwriter/gui/theme.py index c3516556..17e58ff4 100644 --- a/novelwriter/gui/theme.py +++ b/novelwriter/gui/theme.py @@ -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) diff --git a/tests/test_gui/test_gui_theme.py b/tests/test_gui/test_gui_theme.py index f5751e7b..c8133f6b 100644 --- a/tests/test_gui/test_gui_theme.py +++ b/tests/test_gui/test_gui_theme.py @@ -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"