From 9d41bd431280d7bb1f0fa3865e49a13200ff9608 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 17 May 2022 04:15:12 +0200 Subject: 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 1c338e6d07a42631a6603c5bb0bc86f6806addd6. Add problematic case to stylesheet baseline test. Fixes: QTBUG-102866 Pick-to: 6.3 6.2 Change-Id: I5d79e65b33a2e41ac07c8efe0c15697c5be65201 Reviewed-by: Axel Spoerl Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qstylesheetstyle.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index f84fd040e3..0437561d13 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3282,7 +3282,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC if (customDropDownArrow) toolOpt.features &= ~(QStyleOptionToolButton::Menu | QStyleOptionToolButton::HasMenu); } - const bool customMenuIndicator = (!customDropDown && drawMenuIndicator) + const bool customMenuIndicator = (!drawDropDown && drawMenuIndicator) && hasStyleRule(w, PseudoElement_ToolButtonMenuIndicator); if (customMenuIndicator) toolOpt.features &= ~QStyleOptionToolButton::HasMenu; @@ -3354,9 +3354,9 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC } else if (drawMenuIndicator) { QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenuIndicator); - QRect r = subRule.hasGeometry() || subRule.hasPosition() - ? positionRect(w, subRule, PseudoElement_ToolButtonMenuIndicator, toolOpt.rect, toolOpt.direction) - : subRule.contentsRect(opt->rect); + // content padding does not impact the indicator, so use the original rect to + // calculate position of the sub element within the toplevel rule + QRect r = positionRect(w, rule, subRule, PseudoElement_ToolButtonMenuIndicator, opt->rect, toolOpt.direction); if (subRule.hasDrawable()) { subRule.drawRule(p, r); } else { @@ -3397,7 +3397,6 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC } subRule.drawRule(p, arrowRect); } - return; } break; -- cgit v1.2.3