Skip to content

Commit

Permalink
QWindows11Style: Adjust Subline for QLineEdit to fit rounded corners
Browse files Browse the repository at this point in the history
Reduce the size of the subline for QLineEdit to fit the begin and end of
the rounded frame corner.

Task-number: QTBUG-132261
Pick-to: 6.8
Change-Id: I879f30c2bdc6601fef4738aeec71d7ab7bcee22c
Reviewed-by: Christian Ehrlicher <[email protected]>
(cherry picked from commit 5e656b9)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
  • Loading branch information
Wladimir Leuschner authored and Qt Cherry-pick Bot committed Dec 22, 2024
1 parent 4c2f439 commit 4eaaf89
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/plugins/styles/modernwindows/qwindows11style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
if (widget && widget->objectName() == QStringLiteral(u"qt_spinbox_lineedit"))
break;
if (const auto *panel = qstyleoption_cast<const QStyleOptionFrame *>(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);
Expand All @@ -966,12 +965,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: {
Expand Down

0 comments on commit 4eaaf89

Please sign in to comment.