Commit e8b1d4aa authored by Jan Blackquill's avatar Jan Blackquill 🌈
Browse files

kstyle: fix qqc2 desktop style sliders in RtL

We don't do any mirroring of the slider groove rects or tickmarks based on layout direction,
and this causes qqc2-desktop-style sliders to render in the wrong direction.
Swapping the leftRect and the rightRect when option->direction == Qt::RightToLeft
fixes this.

This wasn't broken with QWidgets because QSlider relies on (ab)using the upsideDown option
in order to achieve mirroring of the groove instead of option->direction, and consequently,
this change doesn't affect Qt widgets apps at all.

BUG: 430101
parent 9120bcb1
Pipeline #184878 passed with stage
in 3 minutes and 32 seconds
......@@ -52,6 +52,7 @@
#include <QToolButton>
#include <QTreeView>
#include <QWidgetAction>
#include <qnamespace.h>
#if BREEZE_HAVE_QTQUICK
#include <KCoreAddons>
......@@ -6705,6 +6706,7 @@ bool Style::drawSliderComplexControl(const QStyleOptionComplex *option, QPainter
}
// colors
const auto reverseTicks = option->direction == Qt::LeftToRight ? upsideDown : !upsideDown;
const auto base(_helper->separatorColor(palette));
const auto &highlight =
hasHighlightNeutral(widget, option, mouseOver, hasFocus) ? _helper->neutralText(palette) : palette.color(QPalette::Highlight);
......@@ -6718,9 +6720,9 @@ bool Style::drawSliderComplexControl(const QStyleOptionComplex *option, QPainter
int position(sliderPositionFromValue(sliderOption->minimum, sliderOption->maximum, current, available) + fudge);
foreach (const QLine &tickLine, tickLines) {
if (horizontal)
painter->drawLine(tickLine.translated(upsideDown ? (rect.width() - position) : position, 0));
painter->drawLine(tickLine.translated(reverseTicks ? (rect.width() - position) : position, 0));
else
painter->drawLine(tickLine.translated(0, upsideDown ? (rect.height() - position) : position));
painter->drawLine(tickLine.translated(0, reverseTicks ? (rect.height() - position) : position));
}
// go to next position
......@@ -6752,12 +6754,15 @@ bool Style::drawSliderComplexControl(const QStyleOptionComplex *option, QPainter
if (sliderOption->orientation == Qt::Horizontal) {
auto leftRect(grooveRect);
leftRect.setRight(handleRect.right() - Metrics::Slider_ControlThickness / 2);
_helper->renderSliderGroove(painter, leftRect, upsideDown ? grooveColor : highlight);
auto rightRect(grooveRect);
rightRect.setLeft(handleRect.left() + Metrics::Slider_ControlThickness / 2);
_helper->renderSliderGroove(painter, rightRect, upsideDown ? highlight : grooveColor);
if (option->direction == Qt::RightToLeft)
std::swap(leftRect, rightRect);
_helper->renderSliderGroove(painter, leftRect, upsideDown ? grooveColor : highlight);
_helper->renderSliderGroove(painter, rightRect, upsideDown ? highlight : grooveColor);
} else {
auto topRect(grooveRect);
topRect.setBottom(handleRect.bottom() - Metrics::Slider_ControlThickness / 2);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment