summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2022-01-03 10:26:19 +0100
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2022-01-17 18:23:50 +0100
commit8c4dee6f97d744ee54d60733f5e160da5e7616c7 (patch)
tree256b46ac1ec80043956421318bf2350c2fc4471f /src
parentc0ca46de3eb4c92630c27ba0171f2947dc5be5f0 (diff)
QFusionStyle: don't draw an invalid outline for up/down buttons
When they are disabled ('NoButtons'). Otherwise, we end up with a tiny dot (top left or right corner of a spinbox). Pick-to: 6.2 6.3 5.15 Fixes: QTBUG-99486 Change-Id: Ic99f4bce2abd57c988254296a749b5d5b23cfb39 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/styles/qfusionstyle.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 00a80f565a..43e9c38f07 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -2027,22 +2027,24 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
cachePainter.setPen(d->topShadow());
cachePainter.drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1));
- // Draw button gradient
- QColor buttonColor = d->buttonColor(option->palette);
- QRect updownRect = upRect.adjusted(0, -2, 0, downRect.height() + 2);
- QLinearGradient gradient = qt_fusion_gradient(updownRect, (isEnabled && option->state & State_MouseOver ) ? buttonColor : buttonColor.darker(104));
+ if (!upRect.isNull()) {
+ // Draw button gradient
+ const QColor buttonColor = d->buttonColor(option->palette);
+ const QRect updownRect = upRect.adjusted(0, -2, 0, downRect.height() + 2);
+ const QLinearGradient gradient = qt_fusion_gradient(updownRect, (isEnabled && option->state & State_MouseOver )
+ ? buttonColor : buttonColor.darker(104));
- // Draw button gradient
- cachePainter.setPen(Qt::NoPen);
- cachePainter.setBrush(gradient);
+ cachePainter.setPen(Qt::NoPen);
+ cachePainter.setBrush(gradient);
- cachePainter.save();
- cachePainter.setClipRect(updownRect);
- cachePainter.drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2);
- cachePainter.setPen(QPen(d->innerContrastLine()));
- cachePainter.setBrush(Qt::NoBrush);
- cachePainter.drawRoundedRect(r.adjusted(1, 1, -2, -2), 2, 2);
- cachePainter.restore();
+ cachePainter.save();
+ cachePainter.setClipRect(updownRect);
+ cachePainter.drawRoundedRect(r.adjusted(0, 0, -1, -1), 2, 2);
+ cachePainter.setPen(QPen(d->innerContrastLine()));
+ cachePainter.setBrush(Qt::NoBrush);
+ cachePainter.drawRoundedRect(r.adjusted(1, 1, -2, -2), 2, 2);
+ cachePainter.restore();
+ }
if ((spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled) && upIsActive) {
if (sunken)
@@ -2070,12 +2072,14 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
cachePainter.restore();
}
- // outline the up/down buttons
- cachePainter.setPen(outline);
- if (spinBox->direction == Qt::RightToLeft) {
- cachePainter.drawLine(upRect.right(), upRect.top() - 1, upRect.right(), downRect.bottom() + 1);
- } else {
- cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.left(), downRect.bottom() + 1);
+ if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
+ // buttonSymbols == NoButtons results in 'null' rects
+ // and a tiny rect painted in the corner.
+ cachePainter.setPen(outline);
+ if (spinBox->direction == Qt::RightToLeft)
+ cachePainter.drawLine(upRect.right(), upRect.top() - 1, upRect.right(), downRect.bottom() + 1);
+ else
+ cachePainter.drawLine(upRect.left(), upRect.top() - 1, upRect.left(), downRect.bottom() + 1);
}
if (upIsActive && sunken) {