summaryrefslogtreecommitdiffstats
path: root/src/gui/styles/qstylesheetstyle.cpp
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-11-04 15:09:27 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2009-11-04 15:54:31 (GMT)
commit5f9187991c25c3bbe812b788251678f0ab1116a3 (patch)
tree85d552449ea82b7d2c18528400579d3507af4385 /src/gui/styles/qstylesheetstyle.cpp
parent3ac785411d860e48e14f6b2542b666a6d508cff1 (diff)
downloadQt-5f9187991c25c3bbe812b788251678f0ab1116a3.zip
Qt-5f9187991c25c3bbe812b788251678f0ab1116a3.tar.gz
Qt-5f9187991c25c3bbe812b788251678f0ab1116a3.tar.bz2
Wrong styling of checkable menu items.
When using style sheets, the fallback for the menu item is QWindowsStyle. However, QWindowsStyle doesn't draw anything when the item is not checked. We now mimick what QWindowsStyle would draw in QStyleSheetStyle::drawControl(). The "static const int windows*" variables in qwindowsstyle.cpp have been moved into QWindowsStylePrivate to make them accessible to QStyleSheetStyle. Reviewed-by: Olivier Task-number: QTBUG-2218 Task-number: QTBUG-2217 Task-number: QTBUG-3479
Diffstat (limited to 'src/gui/styles/qstylesheetstyle.cpp')
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index e61658b..ce73fd8 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -3606,6 +3606,27 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
}
} else if (hasStyleRule(w, PseudoElement_MenuCheckMark) || hasStyleRule(w, PseudoElement_MenuRightArrow)) {
QWindowsStyle::drawControl(ce, &mi, p, w);
+ if (mi.checkType != QStyleOptionMenuItem::NotCheckable && !mi.checked) {
+ // We have a style defined, but QWindowsStyle won't draw anything if not checked.
+ // So we mimick what QWindowsStyle would do.
+ int checkcol = qMax<int>(mi.maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
+ QRect vCheckRect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x(), mi.rect.y(), checkcol, mi.rect.height()));
+ if (mi.state.testFlag(State_Enabled) && mi.state.testFlag(State_Selected)) {
+ qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &mi.palette.brush(QPalette::Button));
+ } else {
+ QBrush fill(mi.palette.light().color(), Qt::Dense4Pattern);
+ qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &fill);
+ }
+ QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
+ if (subSubRule.hasDrawable()) {
+ QStyleOptionMenuItem newMi(mi);
+ newMi.rect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x() + QWindowsStylePrivate::windowsItemFrame,
+ mi.rect.y() + QWindowsStylePrivate::windowsItemFrame,
+ checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
+ mi.rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
+ drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w);
+ }
+ }
} else {
if (rule.hasDrawable() && !subRule.hasDrawable() && !(opt->state & QStyle::State_Selected)) {
mi.palette.setColor(QPalette::Window, Qt::transparent);