QQuickMacStyle: tweak NSTextFieldCell's drawing

This cell is drawing a frame/outline around a text field (a line edit in Qt).
Starting from macOS Tahoe this frame is slightly offset and with
larger size than requested (probably because now text field has
rounded corners and also the outline is thin and barely visible),
and as a result clipped by the current context's clip. In the
'Light' theme QLineEdit is completely invisible (unless it has a
focus). To address this issue we adjust the rect we draw line edit
with so it's the same as prior to Tahoe.

Note: this patch is a cherry-pick of fb61543e6e2 in qtbase, which
fixes the exact same problem for Widgets.

Pick-to: 6.9 6.8 6.5
Fixes: QTBUG-138465
Change-Id: I5955f4304e9fcd56de993267ff8963f6b133f14a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 01f096cea9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Richard Moe Gustavsen 2025-10-08 10:56:09 +02:00 committed by Qt Cherry-pick Bot
parent 67ff19dcbe
commit 92211ecbdc
1 changed files with 9 additions and 1 deletions

View File

@ -2769,7 +2769,15 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
}
}
[tf.cell drawWithFrame:rect inView:tf];
CGRect fixedRect = rect;
if (qt_apple_runningWithLiquidGlass()) {
// The text edit cell is drawn with a little offset to the left and
// the size increase compared to the 'rect' we want it to be drawn in. As a
// result, the cell's 'outline' is clipped away. Adjusting the rectangle
// for this, so that it's inside the clip rect, as it was before Tahoe.
fixedRect = CGRectInset(rect, 1., 1.);
}
[tf.cell drawWithFrame:fixedRect inView:tf];
});
} else {
QCommonStyle::drawPrimitive(pe, opt, p);