Fix palette not being applied in light theme

For some odd reason this problem arose much later than #2016.
This commit is contained in:
Matthias Metelka 2022-10-24 00:13:02 +02:00
parent d6826493fa
commit 63c9d1c310

View file

@ -185,7 +185,6 @@ class ThemeManager:
if m:= re.match(r"rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d+\.*\d+?)\)", self.var(colors)): 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(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:
@ -260,19 +259,10 @@ class ThemeManager:
def _apply_palette(self, app: QApplication) -> None: def _apply_palette(self, app: QApplication) -> None:
set_macos_dark_mode(self.night_mode) set_macos_dark_mode(self.night_mode)
if not self.night_mode:
app.setStyle(QStyleFactory.create(self._default_style)) # type: ignore
self.default_palette.setColor(
QPalette.ColorRole.Window, self.qcolor(colors.CANVAS)
)
app.setPalette(self.default_palette)
return
if not self.macos_dark_mode(): if not self.macos_dark_mode():
app.setStyle(QStyleFactory.create("fusion")) # type: ignore app.setStyle(QStyleFactory.create("fusion")) # type: ignore
palette = QPalette() palette = QPalette()
text = self.qcolor(colors.FG) text = self.qcolor(colors.FG)
palette.setColor(QPalette.ColorRole.WindowText, text) palette.setColor(QPalette.ColorRole.WindowText, text)
palette.setColor(QPalette.ColorRole.ToolTipText, text) palette.setColor(QPalette.ColorRole.ToolTipText, text)
@ -289,11 +279,9 @@ class ThemeManager:
palette.setColor(QPalette.ColorRole.Window, canvas) palette.setColor(QPalette.ColorRole.Window, canvas)
palette.setColor(QPalette.ColorRole.AlternateBase, canvas) palette.setColor(QPalette.ColorRole.AlternateBase, canvas)
palette.setColor(QPalette.ColorRole.Button, QColor("#454545")) input_base = self.qcolor(colors.CANVAS_CODE)
palette.setColor(QPalette.ColorRole.Base, input_base)
canvas_inset = self.qcolor(colors.CANVAS_INSET) palette.setColor(QPalette.ColorRole.ToolTipBase, input_base)
palette.setColor(QPalette.ColorRole.Base, canvas_inset)
palette.setColor(QPalette.ColorRole.ToolTipBase, canvas_inset)
palette.setColor( palette.setColor(
QPalette.ColorRole.PlaceholderText, self.qcolor(colors.FG_SUBTLE) QPalette.ColorRole.PlaceholderText, self.qcolor(colors.FG_SUBTLE)