Skip to content

fix(ui): restore Windows accent color on PySide 6.8.0.1 (Fix #668) #755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 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,27 @@ 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,
)
self.select_color.setHsl(
self.select_color.hslHue(),
self.select_color.hslSaturation(),
max(self.select_color.lightness(), 100),
255,
)
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 +57,26 @@ 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,
)
self.hover_color.setHsl(
self.hover_color.hslHue(),
self.hover_color.hslSaturation(),
max(self.hover_color.lightness(), 100),
255,
)
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