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
|
From d7c0ab28df83eb4a4c39495a25e609047c735d59 Mon Sep 17 00:00:00 2001
From: ivan tkachenko <me@ratijas.tk>
Date: Sat, 4 Jun 2022 05:00:53 +0300
Subject: [PATCH] KStyle: Fix QQC2 ProgressBar desktop style in RTL layout
direction
BUG: 430101
(cherry picked from commit 2bf9fc4c7be280e2b77f7c150855e0fca0b80d9a)
* asturm 2022-07-26: Merged with clang-format changes in commit
32149dc002ae574ed41f111bf52712b1765b906b
---
kstyle/breezestyle.cpp | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp
index c9fba292..0d7a8432 100644
--- a/kstyle/breezestyle.cpp
+++ b/kstyle/breezestyle.cpp
@@ -1749,23 +1749,27 @@ namespace Breeze
const bool horizontal( BreezePrivate::isProgressBarHorizontal( progressBarOption ) );
// check inverted appearance
- const bool inverted( progressBarOption->invertedAppearance );
+ bool inverted(progressBarOption->invertedAppearance);
+ if (horizontal) {
+ // un-invert in RTL layout
+ inverted ^= option->direction == Qt::RightToLeft;
+ }
// get progress and steps
- const qreal progress( progressBarOption->progress - progressBarOption->minimum );
+ const int progress(progressBarOption->progress - progressBarOption->minimum);
const int steps( qMax( progressBarOption->maximum - progressBarOption->minimum, 1 ) );
//Calculate width fraction
- const qreal widthFrac = qMin( qreal(1), progress/steps );
+ const qreal position = qreal(progress) / qreal(steps);
+ const qreal visualPosition = inverted ? 1 - position : position;
// convert the pixel width
- const int indicatorSize( widthFrac*( horizontal ? rect.width():rect.height() ) );
+ const int indicatorSize(visualPosition * (horizontal ? rect.width() : rect.height()));
QRect indicatorRect;
if( horizontal )
{
-
- indicatorRect = QRect( inverted ? ( rect.right() - indicatorSize + 1):rect.left(), rect.y(), indicatorSize, rect.height() );
+ indicatorRect = QRect(rect.left(), rect.y(), indicatorSize, rect.height());
indicatorRect = visualRect( option->direction, rect, indicatorRect );
} else indicatorRect = QRect( rect.x(), inverted ? rect.top() : (rect.bottom() - indicatorSize + 1), rect.width(), indicatorSize );
--
2.35.1
|