mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 08:22:24 -04:00
Fix rgba values in Qt
This commit is contained in:
parent
caba214d6a
commit
44d91b94c6
1 changed files with 5 additions and 1 deletions
|
@ -181,6 +181,11 @@ class ThemeManager:
|
||||||
return vars["dark" if self.night_mode else "light"]
|
return vars["dark" if self.night_mode else "light"]
|
||||||
|
|
||||||
def qcolor(self, colors: dict[str, str]) -> QColor:
|
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))
|
return QColor(self.var(colors))
|
||||||
|
|
||||||
def _determine_night_mode(self) -> bool:
|
def _determine_night_mode(self) -> bool:
|
||||||
|
@ -275,7 +280,6 @@ class ThemeManager:
|
||||||
palette.setColor(QPalette.ColorRole.ButtonText, text)
|
palette.setColor(QPalette.ColorRole.ButtonText, text)
|
||||||
|
|
||||||
hlbg = self.qcolor(colors.HIGHLIGHT_BG)
|
hlbg = self.qcolor(colors.HIGHLIGHT_BG)
|
||||||
hlbg.setAlpha(64)
|
|
||||||
palette.setColor(
|
palette.setColor(
|
||||||
QPalette.ColorRole.HighlightedText, self.qcolor(colors.HIGHLIGHT_FG)
|
QPalette.ColorRole.HighlightedText, self.qcolor(colors.HIGHLIGHT_FG)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue