summaryrefslogtreecommitdiff
path: root/kde-plasma/breeze/files/breeze-5.24.6-fix-qqc2-sliders-in-rtl.patch
blob: b8b3504a0a0ea4aa13934c56f580486334085864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
From 53f24305536850b244b730f9a04024daf02e753b Mon Sep 17 00:00:00 2001
From: Jan Blackquill <uhhadd@gmail.com>
Date: Fri, 3 Jun 2022 17:34:02 -0400
Subject: [PATCH] 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
(cherry picked from commit e8b1d4aa47daf99041332f43c29fabdf70f25004)

* asturm 2022-07-26: Merged with clang-format changes in commit
  32149dc002ae574ed41f111bf52712b1765b906b

---
 kstyle/breezestyle.cpp | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp
index 2ef2ea98..c9fba292 100644
--- a/kstyle/breezestyle.cpp
+++ b/kstyle/breezestyle.cpp
@@ -51,6 +51,7 @@
 #include <QDialogButtonBox>
 #include <QGraphicsItem>
 #include <QGraphicsProxyWidget>
+#include <qnamespace.h>
 
 #if BREEZE_HAVE_QTQUICK
 #include <QQuickWindow>
@@ -6679,6 +6680,7 @@ namespace Breeze
                 }
 
                 // 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 );
 
@@ -6693,8 +6695,8 @@ namespace Breeze
                     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 ) );
-                        else painter->drawLine( tickLine.translated( 0, upsideDown ? (rect.height() - position):position ) );
+                        if( horizontal ) painter->drawLine(tickLine.translated(reverseTicks ? (rect.width() - position) : position, 0));
+                        else painter->drawLine(tickLine.translated(0, reverseTicks ? (rect.height() - position) : position));
                     }
 
                     // go to next position
@@ -6729,11 +6731,15 @@ namespace Breeze
 
                     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 {
 
-- 
2.35.1