-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqmenu-checkmark-and-icon.patch
48 lines (46 loc) · 2.43 KB
/
qmenu-checkmark-and-icon.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3727,11 +3727,14 @@
iconRect.moveLeft(iconRect.left());
else
iconRect.moveRight(iconRect.right());
+ if (checkable)
+ iconRect.moveLeft(iconRect.left() + 24);
iconRule.drawRule(p, iconRect);
QRect pmr(0, 0, pixw, pixh);
pmr.moveCenter(iconRect.center());
p->drawPixmap(pmr.topLeft(), pixmap);
- } else if (checkable) {
+ }
+ if (checkable) {
QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
if (subSubRule.hasDrawable() || checked) {
QStyleOptionMenuItem newMi = mi;
@@ -3745,7 +3748,7 @@
}
QRect textRect = subRule.contentsRect(opt->rect);
- textRect.setLeft(textRect.left() + m->maxIconWidth);
+ textRect.setLeft(textRect.left() + m->maxIconWidth + 24);
textRect.setWidth(textRect.width() - mi.tabWidth);
const QRect vTextRect = visualRect(opt->direction, m->rect, textRect);
@@ -5093,7 +5096,10 @@
if (mi->text.contains(QLatin1Char('\t')))
sz.rwidth() += 12; //as in QCommonStyle
bool checkable = mi->checkType != QStyleOptionMenuItem::NotCheckable;
- if (!mi->icon.isNull()) {
+ bool hasIcon = !mi->icon.isNull();
+ if (checkable && hasIcon) {
+ sz.rwidth() += 24;
+ } else if (hasIcon) {
const int pmSmall = pixelMetric(PM_SmallIconSize);
const QSize pmSize = mi->icon.actualSize(QSize(pmSmall, pmSmall));
sz.rwidth() += pmSize.width() + 4;
@@ -5101,6 +5107,8 @@
QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
QRect checkmarkRect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
sz.rwidth() += std::max(mi->maxIconWidth, checkmarkRect.width()) + 4;
+ } else {
+ sz.rwidth() += 18;
}
return subRule.boxSize(subRule.adjustSize(sz));
}