From 63e248aae7aecce2299bfd7941bd37fdfc136dcf Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 7 Jan 2010 14:11:28 +0100 Subject: Mac style doesn't honour QStyle::State_HasFocus for non-widgets. This patch draws the focus frame for widgets other than QLineEdit (e.g. for line edits in Webkit). The frame is drawn outside the rectangle passed in the option-rect. Task-number: QTBUG-5530 Reviewed-by: MortenS --- src/gui/styles/qmacstyle_mac.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 4075cf7..53740fc 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -3109,6 +3109,18 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai break; case PE_PanelLineEdit: QWindowsStyle::drawPrimitive(pe, opt, p, w); + // 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 (const QStyleOptionFrame *panel = qstyleoption_cast(opt)) { + 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, w); + } + } + break; case PE_FrameTabWidget: if (const QStyleOptionTabWidgetFrame *twf -- cgit v0.12