From 38114b83250cc9b14069d41935fb8822475de45a Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Fri, 15 Jul 2022 08:52:43 +0200 Subject: 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 --- src/widgets/styles/qstylehelper.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/widgets/styles') 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)); } -- cgit v1.2.3