From b7a63351a4ed64f9264a868707f507fe09850199 Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Tue, 17 Dec 2024 14:24:44 +0100 Subject: [PATCH] QWindows11Style: Adjust Subline for QLineEdit to fit rounded corners Reduce the size of the subline for QLineEdit to fit the begin and end of the rounded frame corner. Task-number: QTBUG-132261 Change-Id: I879f30c2bdc6601fef4738aeec71d7ab7bcee22c Reviewed-by: Christian Ehrlicher (cherry picked from commit 5e656b9ea3c192f389b7e4f7aa2ae6b010cec306) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 4eaaf89db5bf25d30ea2b336a6cd0f4287849d53) --- src/plugins/styles/modernwindows/qwindows11style.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index 03f94c73329..c653cb6db3b 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -932,8 +932,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption if (widget && widget->objectName() == QStringLiteral(u"qt_spinbox_lineedit")) break; if (const auto *panel = qstyleoption_cast(option)) { - QRectF frameRect = option->rect; - frameRect.adjust(0.5,0.5,-0.5,-0.5); + QRectF frameRect = option->rect.marginsRemoved(QMargins(1, 1, 1, 1)); QBrush fillColor = option->palette.brush(QPalette::Base); painter->setBrush(fillColor); painter->setPen(Qt::NoPen); @@ -951,12 +950,14 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption } break; case PE_FrameLineEdit: { + const qreal sublineOffset = secondLevelRoundingRadius + 1.5; + QRectF rect = option->rect; + rect.adjust(1.5, 1.5, -1.5, -1.5); painter->setBrush(Qt::NoBrush); painter->setPen(highContrastTheme == true ? option->palette.buttonText().color() : QPen(WINUI3Colors[colorSchemeIndex][frameColorLight])); - painter->drawRoundedRect(option->rect, secondLevelRoundingRadius, secondLevelRoundingRadius); - painter->setClipRect(option->rect.adjusted(-2, -2, 2, 2)); + painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius); painter->setPen(editSublineColor(option, colorSchemeIndex)); - painter->drawLine(option->rect.bottomLeft() + QPointF(1,0.5), option->rect.bottomRight() + QPointF(-1,0.5)); + painter->drawLine(option->rect.bottomLeft() + QPointF(sublineOffset, 0.5), option->rect.bottomRight() + QPointF(-sublineOffset, 0.5)); } break; case PE_Frame: {