QWindows11Style: Align QSpinBox rect to match QLineEdits rect

The content rects for QSpinBoxes were smaller than QLineEdits rects for
UI elements that should have the same size. This patch increases the
content rect for QSpinBoxes.

Task-number: QTBUG-132261
Change-Id: I59e752b719399c5845ab3ef81c6e271deda16273
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit a53e095882551caf3684a1f6a205b6c7d76a8913)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 4c2f439001f49c9aa380d16f0e1fa7e574e03fe8)
This commit is contained in:
Wladimir Leuschner 2024-12-17 15:33:05 +01:00 committed by Christian Ehrlicher
parent 2bf4bafb48
commit fb3e74615d

View File

@ -250,20 +250,24 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt
case CC_SpinBox:
if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
if (sb->frame && (sub & SC_SpinBoxFrame)) {
const qreal sublineOffset = secondLevelRoundingRadius + 2.0;
painter->save();
painter->setClipRect(option->rect.adjusted(-2, -2, 2, 2));
painter->setPen(editSublineColor(option, colorSchemeIndex));
painter->drawLine(option->rect.bottomLeft() + QPointF(7,-0.5), option->rect.bottomRight() + QPointF(-7,-0.5));
painter->drawLine(option->rect.bottomLeft() + QPointF(sublineOffset, 0.5),
option->rect.bottomRight() + QPointF(-sublineOffset, 0.5));
painter->restore();
}
const QRectF frameRect = QRectF(option->rect).adjusted(2.5, 2.5, -2.5, -2.5);
const QRectF frameRect = QRectF(option->rect).marginsRemoved(QMarginsF(1.5, 1.5, 1.5, 1.5));
const QBrush fillBrush = option->palette.brush(QPalette::Base);
painter->setBrush(fillBrush);
painter->setPen(QPen(highContrastTheme == true ? sb->palette.buttonText().color() : WINUI3Colors[colorSchemeIndex][frameColorLight]));
painter->setPen(QPen(highContrastTheme == true ? sb->palette.buttonText().color()
: WINUI3Colors[colorSchemeIndex][frameColorLight]));
painter->drawRoundedRect(frameRect, secondLevelRoundingRadius, secondLevelRoundingRadius);
const QPoint mousePos = widget ? widget->mapFromGlobal(QCursor::pos()) : QPoint();
if (sub & SC_SpinBoxEditField) {
const QRect rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget).adjusted(0, 0, 0, 1);
const QRect rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField,
widget).adjusted(0, 0, 0, 1);
if (!(state & State_HasFocus) && rect.contains(mousePos)) {
const QColor fillColor = WINUI3Colors[colorSchemeIndex][subtleHighlightColor];
painter->setPen(Qt::NoPen);