diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 21:06:47 +0200 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-03-23 21:06:47 +0200 |
commit | 42e4ae042a4c86e58bcb8b6d2d59ba4a988285b4 (patch) | |
tree | a7f25b1d335a834a7c3ae104cee913ef3a4dd4fb /src/widgets/styles/qfusionstyle.cpp | |
parent | 4ee4fc18b4067b90efa46ca9baba74f53b54d9ec (diff) | |
parent | 168ff3419f256fdb35b586275d293fc0cd773fe1 (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.9' into tqtc/lts-5.15-opensourcev5.15.9-lts-lgpl
Change-Id: Iaff6b55275e50d19973e1020853d8622587069f9
Diffstat (limited to 'src/widgets/styles/qfusionstyle.cpp')
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index f4345d97c4..a225d4b563 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -2040,22 +2040,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) @@ -2083,12 +2085,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) { |