From 791eebe8a6453ba171ab1b8053bf16311467dad2 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 9 Mar 2024 10:36:59 +0100 Subject: [PATCH] Add custom sorting function so that default themes come first --- novelwriter/gui/theme.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/novelwriter/gui/theme.py b/novelwriter/gui/theme.py index 412a5363..a6e23e29 100644 --- a/novelwriter/gui/theme.py +++ b/novelwriter/gui/theme.py @@ -344,7 +344,7 @@ class GuiTheme: if themeName: self._themeList.append((themeKey, themeName)) - self._themeList = sorted(self._themeList, key=lambda x: x[1]) + self._themeList = sorted(self._themeList, key=_sortTheme) return self._themeList @@ -360,7 +360,7 @@ class GuiTheme: if syntaxName: self._syntaxList.append((syntaxKey, syntaxName)) - self._syntaxList = sorted(self._syntaxList, key=lambda x: x[1]) + self._syntaxList = sorted(self._syntaxList, key=_sortTheme) return self._syntaxList @@ -725,6 +725,13 @@ class GuiIcons: # Module Functions # =============================================================================================== # + +def _sortTheme(data: tuple[str, str]) -> str: + """Key function for theme sorting.""" + key, name = data + return f"*{name}" if key.startswith("default_") else name + + def _loadInternalName(confParser: NWConfigParser, confFile: str | Path) -> str: """Open a conf file and read the 'name' setting.""" try: