summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qfusionstyle.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-12-19 16:52:37 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-01-12 11:59:27 +0000
commit574692e5ac95e1f2061812a43f14d325c077b7c8 (patch)
treee4f221b2819361145fc3c5fae611329520101a8d /src/widgets/styles/qfusionstyle.cpp
parent505559c4a86073370fd681fb20ab11cb41c24b29 (diff)
QFusionStyle: fix painting handle with tickmarks enabled
The handle was drawn outside of the widget's rect when tickmarks were enabled (TicksAbove/TicksLeft). Pick-to: 6.7 6.6 6.5 Fixes: QTBUG-83604 Change-Id: Iff3a1a330317576a759e3fd6795d0b4849e2044b Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/widgets/styles/qfusionstyle.cpp')
-rw-r--r--src/widgets/styles/qfusionstyle.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index ce9ccc6864..fe132859a2 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -3210,23 +3210,28 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
switch (subControl) {
case SC_SliderHandle: {
+ const bool bothTicks = (slider->tickPosition & QSlider::TicksBothSides) == QSlider::TicksBothSides;
if (slider->orientation == Qt::Horizontal) {
rect.setHeight(proxy()->pixelMetric(PM_SliderThickness, option));
rect.setWidth(proxy()->pixelMetric(PM_SliderLength, option));
int centerY = slider->rect.center().y() - rect.height() / 2;
- if (slider->tickPosition & QSlider::TicksAbove)
- centerY += tickSize;
- if (slider->tickPosition & QSlider::TicksBelow)
- centerY -= tickSize;
+ if (!bothTicks) {
+ if (slider->tickPosition & QSlider::TicksAbove)
+ centerY += tickSize;
+ if (slider->tickPosition & QSlider::TicksBelow)
+ centerY -= tickSize - 1;
+ }
rect.moveTop(centerY);
} else {
rect.setWidth(proxy()->pixelMetric(PM_SliderThickness, option));
rect.setHeight(proxy()->pixelMetric(PM_SliderLength, option));
int centerX = slider->rect.center().x() - rect.width() / 2;
- if (slider->tickPosition & QSlider::TicksAbove)
- centerX += tickSize;
- if (slider->tickPosition & QSlider::TicksBelow)
- centerX -= tickSize;
+ if (!bothTicks) {
+ if (slider->tickPosition & QSlider::TicksAbove)
+ centerX += tickSize;
+ if (slider->tickPosition & QSlider::TicksBelow)
+ centerX -= tickSize - 1;
+ }
rect.moveLeft(centerX);
}
}
@@ -3234,18 +3239,23 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
case SC_SliderGroove: {
QPoint grooveCenter = slider->rect.center();
const int grooveThickness = QStyleHelper::dpiScaled(7, option);
+ const bool bothTicks = (slider->tickPosition & QSlider::TicksBothSides) == QSlider::TicksBothSides;
if (slider->orientation == Qt::Horizontal) {
rect.setHeight(grooveThickness);
- if (slider->tickPosition & QSlider::TicksAbove)
- grooveCenter.ry() += tickSize;
- if (slider->tickPosition & QSlider::TicksBelow)
- grooveCenter.ry() -= tickSize;
+ if (!bothTicks) {
+ if (slider->tickPosition & QSlider::TicksAbove)
+ grooveCenter.ry() += tickSize;
+ if (slider->tickPosition & QSlider::TicksBelow)
+ grooveCenter.ry() -= tickSize - 1;
+ }
} else {
rect.setWidth(grooveThickness);
- if (slider->tickPosition & QSlider::TicksAbove)
- grooveCenter.rx() += tickSize;
- if (slider->tickPosition & QSlider::TicksBelow)
- grooveCenter.rx() -= tickSize;
+ if (!bothTicks) {
+ if (slider->tickPosition & QSlider::TicksAbove)
+ grooveCenter.rx() += tickSize;
+ if (slider->tickPosition & QSlider::TicksBelow)
+ grooveCenter.rx() -= tickSize - 1;
+ }
}
rect.moveCenter(grooveCenter);
break;