From 202891a729113f412fd928e4827385bd85a83bbf Mon Sep 17 00:00:00 2001 From: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com> Date: Thu, 30 Jan 2025 21:41:31 -0800 Subject: [PATCH] fix(ui): use the new correct(ish) accent color role for Windows --- tagstudio/src/qt/widgets/thumb_button.py | 41 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/tagstudio/src/qt/widgets/thumb_button.py b/tagstudio/src/qt/widgets/thumb_button.py index cf8dae372..524e42758 100644 --- a/tagstudio/src/qt/widgets/thumb_button.py +++ b/tagstudio/src/qt/widgets/thumb_button.py @@ -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 ( @@ -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( @@ -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(),