Skip to content

Commit

Permalink
fix(ui): use the new correct(ish) accent color role for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
CyanVoxel committed Jan 31, 2025
1 parent 82edbee commit 202891a
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions tagstudio/src/qt/widgets/thumb_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio


import sys

from PySide6 import QtCore
from PySide6.QtCore import QEvent
from PySide6.QtGui import (
Expand All @@ -25,11 +27,21 @@ def __init__(self, parent: QWidget, thumb_size: tuple[int, int]) -> None: # noq
self.hovered = False
self.selected = False

self.select_color: QColor = QPalette.color(
self.palette(),
QPalette.ColorGroup.Active,
QPalette.ColorRole.Accent,
)
# NOTE: As of PySide 6.8.0.1, the QPalette.ColorRole.Accent role no longer works on Windows.
# The QPalette.ColorRole.AlternateBase does for some reason, but not on macOS.
self.select_color: QColor
if sys.platform == "win32":
self.select_color = QPalette.color(
self.palette(),
QPalette.ColorGroup.Active,
QPalette.ColorRole.AlternateBase,
)
else:
self.select_color = QPalette.color(
self.palette(),
QPalette.ColorGroup.Active,
QPalette.ColorRole.Accent,
)

self.select_color_faded: QColor = QColor(self.select_color)
self.select_color_faded.setHsl(
Expand All @@ -39,11 +51,20 @@ def __init__(self, parent: QWidget, thumb_size: tuple[int, int]) -> None: # noq
127,
)

self.hover_color: QColor = QPalette.color(
self.palette(),
QPalette.ColorGroup.Active,
QPalette.ColorRole.Accent,
)
self.hover_color: QColor
if sys.platform == "win32":
self.hover_color = QPalette.color(
self.palette(),
QPalette.ColorGroup.Active,
QPalette.ColorRole.AlternateBase,
)
else:
self.hover_color = QPalette.color(
self.palette(),
QPalette.ColorGroup.Active,
QPalette.ColorRole.Accent,
)

self.hover_color.setHsl(
self.hover_color.hslHue(),
self.hover_color.hslSaturation(),
Expand Down

0 comments on commit 202891a

Please sign in to comment.