From 44d91b94c68bfe11ecf622011bc1e5a1bd0414de Mon Sep 17 00:00:00 2001 From: Matthias Metelka <62722460+kleinerpirat@users.noreply.github.com> Date: Sun, 23 Oct 2022 23:18:57 +0200 Subject: [PATCH] Fix rgba values in Qt --- qt/aqt/theme.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qt/aqt/theme.py b/qt/aqt/theme.py index 52f6b9459..ce5503e8f 100644 --- a/qt/aqt/theme.py +++ b/qt/aqt/theme.py @@ -181,6 +181,11 @@ class ThemeManager: return vars["dark" if self.night_mode else "light"] def qcolor(self, colors: dict[str, str]) -> QColor: + """Create QColor instance from CSS string for the current theme.""" + + if m:= re.match(r"rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d+\.*\d+?)\)", self.var(colors)): + return QColor(int(m.group(1)), int(m.group(2)), int(m.group(3)), 255 * float(m.group(4))) + return QColor(self.var(colors)) def _determine_night_mode(self) -> bool: @@ -275,7 +280,6 @@ class ThemeManager: palette.setColor(QPalette.ColorRole.ButtonText, text) hlbg = self.qcolor(colors.HIGHLIGHT_BG) - hlbg.setAlpha(64) palette.setColor( QPalette.ColorRole.HighlightedText, self.qcolor(colors.HIGHLIGHT_FG) )