3
3
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
4
4
5
5
6
+ import sys
7
+
6
8
from PySide6 import QtCore
7
9
from PySide6 .QtCore import QEvent
8
10
from PySide6 .QtGui import (
@@ -25,11 +27,27 @@ def __init__(self, parent: QWidget, thumb_size: tuple[int, int]) -> None: # noq
25
27
self .hovered = False
26
28
self .selected = False
27
29
28
- self .select_color : QColor = QPalette .color (
29
- self .palette (),
30
- QPalette .ColorGroup .Active ,
31
- QPalette .ColorRole .Accent ,
32
- )
30
+ # NOTE: As of PySide 6.8.0.1, the QPalette.ColorRole.Accent role no longer works on Windows.
31
+ # The QPalette.ColorRole.AlternateBase does for some reason, but not on macOS.
32
+ self .select_color : QColor
33
+ if sys .platform == "win32" :
34
+ self .select_color = QPalette .color (
35
+ self .palette (),
36
+ QPalette .ColorGroup .Active ,
37
+ QPalette .ColorRole .AlternateBase ,
38
+ )
39
+ self .select_color .setHsl (
40
+ self .select_color .hslHue (),
41
+ self .select_color .hslSaturation (),
42
+ max (self .select_color .lightness (), 100 ),
43
+ 255 ,
44
+ )
45
+ else :
46
+ self .select_color = QPalette .color (
47
+ self .palette (),
48
+ QPalette .ColorGroup .Active ,
49
+ QPalette .ColorRole .Accent ,
50
+ )
33
51
34
52
self .select_color_faded : QColor = QColor (self .select_color )
35
53
self .select_color_faded .setHsl (
@@ -39,11 +57,26 @@ def __init__(self, parent: QWidget, thumb_size: tuple[int, int]) -> None: # noq
39
57
127 ,
40
58
)
41
59
42
- self .hover_color : QColor = QPalette .color (
43
- self .palette (),
44
- QPalette .ColorGroup .Active ,
45
- QPalette .ColorRole .Accent ,
46
- )
60
+ self .hover_color : QColor
61
+ if sys .platform == "win32" :
62
+ self .hover_color = QPalette .color (
63
+ self .palette (),
64
+ QPalette .ColorGroup .Active ,
65
+ QPalette .ColorRole .AlternateBase ,
66
+ )
67
+ self .hover_color .setHsl (
68
+ self .hover_color .hslHue (),
69
+ self .hover_color .hslSaturation (),
70
+ max (self .hover_color .lightness (), 100 ),
71
+ 255 ,
72
+ )
73
+ else :
74
+ self .hover_color = QPalette .color (
75
+ self .palette (),
76
+ QPalette .ColorGroup .Active ,
77
+ QPalette .ColorRole .Accent ,
78
+ )
79
+
47
80
self .hover_color .setHsl (
48
81
self .hover_color .hslHue (),
49
82
self .hover_color .hslSaturation (),
0 commit comments