summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-12-04 17:15:30 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-12-05 13:56:09 +0100
commit97ac281c1d70dcfbb137e5a83e24a747e9510116 (patch)
tree7e840b62402f539f0d56253685a31e587e4b36a9 /src/widgets
parent925b33bdaabc7d07d6910d5696af1ff49287d8fa (diff)
QStyleSheetStyle: properly honor checkmark size when drawing a QMenu
When drawing a QMenu which is checkable but does not have an icon somewhere, the width of the (possible) checkmark was not considered during drawing and the text was drawn over the checkmark. Also the wrong state was checked for drawing the checked icon (if one was given). Fixes: QTBUG-80506 Task-number: QTBUG-78238 Change-Id: Icf8aa37aab424564054d3549defee93eb0d7c1a4 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 3f57992311..aab4b74c4b 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3711,6 +3711,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
bool dis = !(opt->state & QStyle::State_Enabled),
act = opt->state & QStyle::State_Selected;
+ int textRectOffset = m->maxIconWidth;
if (!mi.icon.isNull()) {
QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
if (act && !dis)
@@ -3736,19 +3737,21 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
p->drawPixmap(pmr.topLeft(), pixmap);
} else if (checkable) {
QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
+ const QRect cmRect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
if (subSubRule.hasDrawable() || checked) {
QStyleOptionMenuItem newMi = mi;
if (!dis)
newMi.state |= State_Enabled;
- if (act)
+ if (mi.checked)
newMi.state |= State_On;
- newMi.rect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
+ newMi.rect = cmRect;
drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w);
}
+ textRectOffset = std::max(textRectOffset, cmRect.width());
}
QRect textRect = subRule.contentsRect(opt->rect);
- textRect.setLeft(textRect.left() + m->maxIconWidth);
+ textRect.setLeft(textRect.left() + textRectOffset);
textRect.setWidth(textRect.width() - mi.tabWidth);
const QRect vTextRect = visualRect(opt->direction, m->rect, textRect);