From 88daafb4167f4d095c8e2559eea3bc67259c1900 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 9 Oct 2020 11:16:03 +0200 Subject: Native style, macOS: always draw a TextField using NSTextField There is no apparent reason as to why we should let QCommonStyle fill the background before it calls PE_FrameLineEdit in QMacStyle. The NSTextField cell already draws the correct background, which is supposede to be semi-transparent in dark-mode. Therefore, just let PE_PanelLineEdit and PE_FrameLineEdit be drawn the same way. Change-Id: Iacd4f1b1802e1b0c2b96a92cf271b681c10b8cff Reviewed-by: Mitch Curtis --- .../nativestyle/qstyle/mac/qquickmacstyle_mac.mm | 31 +--------------------- 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm index 9575f888..e857ff96 100644 --- a/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm +++ b/src/imports/nativestyle/qstyle/mac/qquickmacstyle_mac.mm @@ -2971,6 +2971,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai p->drawRect(opt->rect); p->setPen(oldPen); break; } + case PE_PanelLineEdit: case PE_FrameLineEdit: if (const QStyleOptionFrame *frame = qstyleoption_cast(opt)) { if (frame->state & State_Sunken) { @@ -3017,36 +3018,6 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai } } break; - case PE_PanelLineEdit: - { - const QStyleOptionFrame *panel = qstyleoption_cast(opt); - if (qt_mac_applicationIsInDarkMode() || (panel && panel->lineWidth <= 0)) { - // QCommonStyle::drawPrimitive(PE_PanelLineEdit) fill the background with - // a proper color, defined in opt->palette and then, if lineWidth > 0, it - // calls QMacStyle::drawPrimitive(PE_FrameLineEdit). We use NSTextFieldCell - // to handle PE_FrameLineEdit, which will use system-default background. - // In 'Dark' mode it's transparent and thus it's not over-painted. - QCommonStyle::drawPrimitive(pe, opt, p); - } else { - // In 'Light' mode, if panel->lineWidth > 0, we have to use the correct - // background color when drawing PE_FrameLineEdit, so let's call it - // directly and set the proper color there. - drawPrimitive(PE_FrameLineEdit, opt, p); - } - - // Draw the focus frame for widgets other than QLineEdit (e.g. for line edits in Webkit). - // Focus frame is drawn outside the rectangle passed in the option-rect. - if (panel) { -// if ((opt->state & State_HasFocus) && !qobject_cast(w)) { -// int vmargin = pixelMetric(QStyle::PM_FocusFrameVMargin); -// int hmargin = pixelMetric(QStyle::PM_FocusFrameHMargin); -// QStyleOptionFrame focusFrame = *panel; -// focusFrame.rect = panel->rect.adjusted(-hmargin, -vmargin, hmargin, vmargin); -// drawControl(CE_FocusFrame, &focusFrame, p); -// } - } - } - break; case PE_PanelScrollAreaCorner: { const QBrush brush(opt->palette.brush(QPalette::Base)); p->fillRect(opt->rect, brush); -- cgit v1.2.3