Styles/fusion: Adjust QSlider painting with modified paint rect

When the painting rect is adjusted within an overloaded
QSlider::initStyleOption() there are some glitches when using the fusion
style:
 - the tickmarks are not painted inside the specified rect / it is
   ignored
 - the glue groove bar is clipped incorrectly

Pick-to: 6.6
Fixes: QTBUG-111314
Change-Id: If140c5348031d869b527c6c4850b4a8d34b395c1
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 8594fe1b8dc848d8a2d61197acce67963f5fe20e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Christian Ehrlicher 2023-12-20 09:16:24 +01:00 committed by Qt Cherry-pick Bot
parent 33b4c2d4af
commit 9622c7797a

View File

@ -2754,10 +2754,11 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
if (slider->upsideDown)
clipRect = QRect(handle.right(), groove.top(), groove.right() - handle.right(), groove.height());
else
clipRect = QRect(groove.left(), groove.top(), handle.left(), groove.height());
clipRect = QRect(groove.left(), groove.top(),
handle.left() - slider->rect.left(), groove.height());
} else {
if (slider->upsideDown)
clipRect = QRect(groove.left(), handle.bottom(), groove.width(), groove.height() - handle.bottom());
clipRect = QRect(groove.left(), handle.bottom(), groove.width(), groove.height() - (handle.bottom() - slider->rect.top()));
else
clipRect = QRect(groove.left(), groove.top(), groove.width(), handle.top() - groove.top());
}
@ -2768,6 +2769,8 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
}
if (option->subControls & SC_SliderTickmarks) {
painter->save();
painter->translate(slider->rect.x(), slider->rect.y());
painter->setPen(outline);
int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
@ -2823,6 +2826,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
v = nextInterval;
}
painter->drawLines(lines);
painter->restore();
}
// draw handle
if ((option->subControls & SC_SliderHandle) ) {