mirror of
https://github.com/ankitects/anki.git
synced 2025-09-22 16:02:23 -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"]
|
||||
|
||||
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)
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue