From 8ad9bdf9578d2879d7484c61cf9a46a667f642a4 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 18 Nov 2018 13:41:52 +0100 Subject: QScrollBar: fix horizontal scrollbars in RTL mode When a QScrollBar had a stylesheet the subControlRect() was not properly mirrored which lead to a wrong scrolling behavior. Fix it by adjusting the resulting rect with visualRect(). This reverts 00c9ec63a552d040e851b561c11428fabf1a2b08 since it did not completely fixed the issue for all use cases. Fixes: QTBUG-27279 Fixes: QTBUG-38748 Fixes: QTBUG-40443 Change-Id: I19718287be7b4cfc9dbe6951fff99ae48264a855 Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qstylesheetstyle.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index fe6a4d0e40..96c6fdf2e2 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -5632,22 +5632,18 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp } else { sliderlen = maxlen; } - const int sliderPosition = sb->orientation == Qt::Horizontal && sb->direction == Qt::RightToLeft ? sb->maximum - sb->sliderPosition + sb->minimum : sb->sliderPosition; int sliderstart = (styleOptionSlider.orientation == Qt::Horizontal ? contentRect.left() : contentRect.top()) - + sliderPositionFromValue(sb->minimum, sb->maximum, sliderPosition, + + sliderPositionFromValue(sb->minimum, sb->maximum, sb->sliderPosition, maxlen - sliderlen, sb->upsideDown); QRect sr = (sb->orientation == Qt::Horizontal) ? QRect(sliderstart, contentRect.top(), sliderlen, contentRect.height()) : QRect(contentRect.left(), sliderstart, contentRect.width(), sliderlen); - if (sc == SC_ScrollBarSlider) { - return sr; - } else if (sc == SC_ScrollBarSubPage) { - return QRect(contentRect.topLeft(), sb->orientation == Qt::Horizontal ? sr.bottomLeft() : sr.topRight()); - } else { // SC_ScrollBarAddPage - return QRect(sb->orientation == Qt::Horizontal ? sr.topRight() : sr.bottomLeft(), contentRect.bottomRight()); - } - break; + if (sc == SC_ScrollBarSubPage) + sr = QRect(contentRect.topLeft(), sb->orientation == Qt::Horizontal ? sr.bottomLeft() : sr.topRight()); + else if (sc == SC_ScrollBarAddPage) + sr = QRect(sb->orientation == Qt::Horizontal ? sr.topRight() : sr.bottomLeft(), contentRect.bottomRight()); + return visualRect(styleOptionSlider.direction, grooveRect, sr); } case SC_ScrollBarAddLine: pe = PseudoElement_ScrollBarAddLine; break; case SC_ScrollBarSubLine: pe = PseudoElement_ScrollBarSubLine; break; -- cgit v1.2.3