Fix button colour bug (#2557)

This commit is contained in:
Veronica Berglyd Olsen
2025-10-27 22:57:42 +01:00
committed by GitHub
3 changed files with 66 additions and 16 deletions
+26 -4
View File
@@ -79,6 +79,27 @@ A colour theme ``.conf`` file consists of the following settings:
inactive = red
disabled = faded
[Icon]
tool = default
sidebar = default
accept = green
reject = red
action = blue
altaction = orange
apply = green
create = yellow
destroy = faded
reset = green
add = green
change = green
remove = red
shortcode = default
markdown = orange
systemio = yellow
info = blue
warning = orange
error = red
[Palette]
window = base:D105
windowtext = default
@@ -141,6 +162,7 @@ affects.
"``[Main]``", "Meta data about the theme, You must at least set ``name``, ``mode`` and ``author``, and ``mode`` must be either ``light`` or ``dark``."
"``[Base]``", "The base colours of the theme. These are also selectable colours in various places inside the app, like for icon colours in **Preferences**."
"``[Project]``", "The colours used for icons and markers for the different project item types."
"``[Icon]``", "The colours used for icons and buttons on the user interface. The names correspond to button and icon roles."
"``[Palette]``", "The colours used for styling the user interface. The values correspond to the ColorRole_ values in the Qt library."
"``[GUI]``", "The colours used for styling additional elements of the user interface."
"``[Syntax]``", "The colours used for syntax highlighting in documents."
@@ -174,10 +196,10 @@ There are several ways to enter colour values:
.. versionadded:: 2.8
The ``[Syntax]`` section was moved into the main theme file. Previously, these settings were in
their own file. The ``[Icons]`` section was renamed to ``[Base]``. Added the ``line`` and
``whitespace`` settings. Dropped the ``license``, ``licenseurl``, and ``description`` settings.
The ``author`` field is now required if the theme is included in the app, but not for user
themes.
their own file. The ``[Icons]`` section was renamed to ``[Base]``, and a new ``[Icon]`` section
added for button and icon roles. Added the ``line`` and ``whitespace`` settings. Dropped the
``license``, ``licenseurl``, and ``description`` settings. The ``author`` field is now required
if the theme is included in the app, but not for user themes.
Icon Themes
+11 -11
View File
@@ -2489,17 +2489,17 @@ class GuiDocToolBar(QWidget):
palette.setColor(QPalette.ColorRole.Text, syntax.text)
self.setPalette(palette)
self.tbBoldMD.setThemeIcon("fmt_bold", "mdformat")
self.tbItalicMD.setThemeIcon("fmt_italic", "mdformat")
self.tbStrikeMD.setThemeIcon("fmt_strike", "mdformat")
self.tbMarkMD.setThemeIcon("fmt_mark", "mdformat")
self.tbBold.setThemeIcon("fmt_bold", "scformat")
self.tbItalic.setThemeIcon("fmt_italic", "scformat")
self.tbStrike.setThemeIcon("fmt_strike", "scformat")
self.tbUnderline.setThemeIcon("fmt_underline", "scformat")
self.tbMark.setThemeIcon("fmt_mark", "scformat")
self.tbSuperscript.setThemeIcon("fmt_superscript", "scformat")
self.tbSubscript.setThemeIcon("fmt_subscript", "scformat")
self.tbBoldMD.setThemeIcon("fmt_bold", "markdown")
self.tbItalicMD.setThemeIcon("fmt_italic", "markdown")
self.tbStrikeMD.setThemeIcon("fmt_strike", "markdown")
self.tbMarkMD.setThemeIcon("fmt_mark", "markdown")
self.tbBold.setThemeIcon("fmt_bold", "shortcode")
self.tbItalic.setThemeIcon("fmt_italic", "shortcode")
self.tbStrike.setThemeIcon("fmt_strike", "shortcode")
self.tbUnderline.setThemeIcon("fmt_underline", "shortcode")
self.tbMark.setThemeIcon("fmt_mark", "shortcode")
self.tbSuperscript.setThemeIcon("fmt_superscript", "shortcode")
self.tbSubscript.setThemeIcon("fmt_subscript", "shortcode")
class GuiDocEditSearch(QFrame):
+29 -1
View File
@@ -249,7 +249,10 @@ class GuiTheme:
def getRawBaseColor(self, name: str) -> bytes:
"""Return a base color."""
return self._svgColors.get(name, self._svgColors.get("default", b"#000000"))
if color := self._svgColors.get(name):
return color
logger.warning("No colour named '%s'", name)
return self._svgColors.get("default", b"#000000")
##
# Theme Methods
@@ -583,6 +586,8 @@ class GuiTheme:
self.iconCache.clear()
self._svgColors = {}
self._qColors = {}
# Base
self._setBaseColor("base", base)
self._setBaseColor("default", default)
self._setBaseColor("faded", faded)
@@ -593,6 +598,8 @@ class GuiTheme:
self._setBaseColor("cyan", cyan)
self._setBaseColor("blue", blue)
self._setBaseColor("purple", purple)
# Project
self._setBaseColor("root", blue)
self._setBaseColor("folder", yellow)
self._setBaseColor("file", default)
@@ -604,6 +611,27 @@ class GuiTheme:
self._setBaseColor("inactive", red)
self._setBaseColor("disabled", faded)
# Icon
self._setBaseColor("tool", default)
self._setBaseColor("sidebar", default)
self._setBaseColor("accept", green)
self._setBaseColor("reject", red)
self._setBaseColor("action", blue)
self._setBaseColor("altaction", orange)
self._setBaseColor("apply", green)
self._setBaseColor("create", yellow)
self._setBaseColor("destroy", faded)
self._setBaseColor("reset", green)
self._setBaseColor("add", green)
self._setBaseColor("change", green)
self._setBaseColor("remove", red)
self._setBaseColor("shortcode", default)
self._setBaseColor("markdown", orange)
self._setBaseColor("systemio", yellow)
self._setBaseColor("info", blue)
self._setBaseColor("warning", orange)
self._setBaseColor("error", red)
def _readColor(self, parser: ConfigParser, section: str, name: str) -> QColor:
"""Parse a colour value from a config string."""
return self.parseColor(parser.get(section, name, fallback="default"))