Stylesheet: Another positioning fix for the menu indicator
Draw tool button menu indicator relative to frame, not content, so that
padding added in the stylesheet creates room between text and indicator.
Also, prevent another double-arrow by ignoring menu indicator rendering
when a menu button subcontrol is used, as the two are mutually
exclusive. This amends 1c338e6d07
.
Add problematic case to stylesheet baseline test.
Fixes: QTBUG-102866
Pick-to: 6.3 6.2
Change-Id: I5d79e65b33a2e41ac07c8efe0c15697c5be65201
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
2f35653a30
commit
9d41bd4312
@ -3282,7 +3282,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
|
|||||||
if (customDropDownArrow)
|
if (customDropDownArrow)
|
||||||
toolOpt.features &= ~(QStyleOptionToolButton::Menu | QStyleOptionToolButton::HasMenu);
|
toolOpt.features &= ~(QStyleOptionToolButton::Menu | QStyleOptionToolButton::HasMenu);
|
||||||
}
|
}
|
||||||
const bool customMenuIndicator = (!customDropDown && drawMenuIndicator)
|
const bool customMenuIndicator = (!drawDropDown && drawMenuIndicator)
|
||||||
&& hasStyleRule(w, PseudoElement_ToolButtonMenuIndicator);
|
&& hasStyleRule(w, PseudoElement_ToolButtonMenuIndicator);
|
||||||
if (customMenuIndicator)
|
if (customMenuIndicator)
|
||||||
toolOpt.features &= ~QStyleOptionToolButton::HasMenu;
|
toolOpt.features &= ~QStyleOptionToolButton::HasMenu;
|
||||||
@ -3354,9 +3354,9 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
|
|||||||
} else if (drawMenuIndicator) {
|
} else if (drawMenuIndicator) {
|
||||||
QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenuIndicator);
|
QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenuIndicator);
|
||||||
|
|
||||||
QRect r = subRule.hasGeometry() || subRule.hasPosition()
|
// content padding does not impact the indicator, so use the original rect to
|
||||||
? positionRect(w, subRule, PseudoElement_ToolButtonMenuIndicator, toolOpt.rect, toolOpt.direction)
|
// calculate position of the sub element within the toplevel rule
|
||||||
: subRule.contentsRect(opt->rect);
|
QRect r = positionRect(w, rule, subRule, PseudoElement_ToolButtonMenuIndicator, opt->rect, toolOpt.direction);
|
||||||
if (subRule.hasDrawable()) {
|
if (subRule.hasDrawable()) {
|
||||||
subRule.drawRule(p, r);
|
subRule.drawRule(p, r);
|
||||||
} else {
|
} else {
|
||||||
@ -3397,7 +3397,6 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
|
|||||||
}
|
}
|
||||||
subRule.drawRule(p, arrowRect);
|
subRule.drawRule(p, arrowRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
QToolButton {
|
||||||
|
border: 5px solid #9e9e9e;
|
||||||
|
background: #ffffff;
|
||||||
|
padding-top: 8px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
}
|
||||||
|
QToolButton[popupMode=InstantPopup] {
|
||||||
|
padding-right: 75px;
|
||||||
|
}
|
||||||
|
QToolButton::menu-indicator {
|
||||||
|
subcontrol-position: right;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user