diff options
| author | Johannes Grunenberg <nerixdev@outlook.de> | 2025-09-23 22:47:33 +0200 |
|---|---|---|
| committer | Johannes Grunenberg <nerixdev@outlook.de> | 2025-09-24 21:26:55 +0200 |
| commit | 99616081f191ad9d5ab93eef30b760c2087f46df (patch) | |
| tree | 0ddf674fefa8e63ca972b2bfa49bf5967b9d2290 /src | |
| parent | 1f67152e21c5a9527a1d4b046ee0fd521c0fb808 (diff) | |
QWindows11Style: Handle inverted sliders correctly
QSliders with `setInvertedAppearance(true)` didn't show the blue groove
and ticks correctly. With this change, the highlighted groove is on the
right side if a hozizontal slider is inverted and on the top side if a
vertical slider is inverted.
Note that `upsideDown` is true for non-inverted vertical sliders but
false for non-inverted horizontal sliders.
Pick-to: 6.10
Change-Id: I8c75dbc1006349209316fce58a5ec383221a916f
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/styles/modernwindows/qwindows11style.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index bb4111df9a2..a86bad5b30b 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -381,9 +381,11 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt rightRect = QRect(handlePos.x(), rect.top(), (rect.width() - handlePos.x()), rect.height()); } else { rect = QRect(rect.center().x() - 2, slrect.top(), 4, slrect.height() - 5); - rightRect = QRect(rect.left(), rect.top() + 1, rect.width(), (handlePos.y() - rect.top())); - leftRect = QRect(rect.left(), handlePos.y(), rect.width(), (rect.height() - handlePos.y())); + leftRect = QRect(rect.left(), rect.top() + 1, rect.width(), (handlePos.y() - rect.top())); + rightRect = QRect(rect.left(), handlePos.y(), rect.width(), (rect.height() - handlePos.y())); } + if (slider->upsideDown) + qSwap(leftRect, rightRect); painter->setPen(Qt::NoPen); painter->setBrush(calculateAccentColor(option)); @@ -427,8 +429,9 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt break; const int v_ = qMin(v, slider->maximum); int tickLength = (v_ == slider->minimum || v_ >= slider->maximum) ? 4 : 3; - pos = QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, - v_, available) + fudge; + pos = QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, v_, + available, slider->upsideDown); + pos += fudge; if (slider->orientation == Qt::Horizontal) { if (ticks & QSlider::TicksAbove) { lines.append(QLineF(pos, tickOffset - 1 - bothOffset + 0.5, |
