From b564809ddc3d894b31eff58833e4b71f9e7ae7a2 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 11 Aug 2009 21:02:51 +0200 Subject: QMenuBar does not respect the border-image stylesheet property Added WA_StyledBackground to QMenuBar when using style sheets. This also implies that CE_PanelMenuBar (drawing only the menubar border) no longer needs to be drawn. Tested in uiloader/baselne/css_borderimage_allwidgets.ui. Task-number: 230363 Reviewed-by: olivier --- src/gui/styles/qstylesheetstyle.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 5f6d4ab..7523883 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -2734,6 +2734,9 @@ void QStyleSheetStyle::polish(QWidget *w) #ifndef QT_NO_MDIAREA || qobject_cast(w) #endif +#ifndef QT_NO_MENUBAR + || qobject_cast(w) +#endif || qobject_cast(w)) { w->setAttribute(Qt::WA_StyledBackground, true); } @@ -3456,6 +3459,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q case CE_MenuEmptyArea: case CE_MenuBarEmptyArea: if (rule.hasDrawable()) { + // Drawn by PE_Widget return; } break; @@ -3606,6 +3610,11 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.drawRule(p, opt->rect); QCommonStyle::drawControl(ce, &mi, p, w); } else { + if (rule.hasDrawable() && !(opt->state & QStyle::State_Selected)) { + // So that the menu bar background is not hidden by the items + mi.palette.setColor(QPalette::Window, Qt::transparent); + mi.palette.setColor(QPalette::Button, Qt::transparent); + } baseStyle()->drawControl(ce, &mi, p, w); } } @@ -4189,7 +4198,6 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op #endif //fall tghought case PE_PanelMenu: - case PE_PanelMenuBar: case PE_PanelStatusBar: if(rule.hasDrawable()) { rule.drawRule(p, opt->rect); @@ -4197,6 +4205,13 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } break; + case PE_PanelMenuBar: + if (rule.hasDrawable()) { + // Drawn by PE_Widget + return; + } + break; + case PE_IndicatorToolBarSeparator: case PE_IndicatorToolBarHandle: { PseudoElement ps = pe == PE_IndicatorToolBarHandle ? PseudoElement_ToolBarHandle : PseudoElement_ToolBarSeparator; -- cgit v0.12