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. Change-Id: I333ea95b80d7a19504000877337b28839b4a8b9f Reviewed-by: Doris Verria <doris.verria@qt.io> (cherry picked from commit 38114b83250cc9b14069d41935fb8822475de45a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
68ebfc4c2f
commit
85077365c0
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user