diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-07-15 08:52:43 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-07-17 13:20:21 +0200 |
commit | 38114b83250cc9b14069d41935fb8822475de45a (patch) | |
tree | e63bcf534c0705eef79aa66373383960ae7ff381 /src/widgets/styles | |
parent | 2738a80acd9e2f81a88dd270e45ad00284a910fe (diff) | |
download | qtbase-38114b83250cc9b14069d41935fb8822475de45a.tar.gz |
Fusion: better support dark themes in the dial
A UI in dark mode will have a dark background. Pick a light color to
draw the notches. Since in the mac style, the dark mode's 'dark' color
is lighter than the 'light' color, pick whichever is lighter.
Pick-to: 6.4
Change-Id: I333ea95b80d7a19504000877337b28839b4a8b9f
Reviewed-by: Doris Verria <doris.verria@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qstylehelper.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp index 2df4745627..f79e83be61 100644 --- a/src/widgets/styles/qstylehelper.cpp +++ b/src/widgets/styles/qstylehelper.cpp @@ -226,7 +226,7 @@ QPolygonF calcLines(const QStyleOptionSlider *dial) void drawDial(const QStyleOptionSlider *option, QPainter *painter) { - QPalette pal = option->palette; + const QPalette pal = option->palette; QColor buttonColor = pal.button().color(); const int width = option->rect.width(); const int height = option->rect.height(); @@ -240,7 +240,11 @@ void drawDial(const QStyleOptionSlider *option, QPainter *painter) // Draw notches if (option->subControls & QStyle::SC_DialTickmarks) { - painter->setPen(option->palette.dark().color().darker(120)); + const bool inverted = pal.window().color().lightness() < pal.text().color().lightness() + && pal.light().color().lightness() > pal.dark().color().lightness(); + const QColor notchColor = inverted ? pal.light().color().lighter(120) + : pal.dark().color().darker(120); + painter->setPen(notchColor); painter->drawLines(QStyleHelper::calcLines(option)); } |