diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-05-03 15:54:57 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-05-16 20:32:27 +0200 |
commit | 1c338e6d07a42631a6603c5bb0bc86f6806addd6 (patch) | |
tree | de4596c3990bac4029c9c916d93504c64249f66c /src/widgets/styles | |
parent | 8af70190966e38dc3a697859f427276aecfe44d4 (diff) |
Stylesheet: fix toolbutton menu indicator rendering
Turn off native indicators if we have custom rules, and if we drew
natively, don't draw custom indicators. This amends
ea0e0a865237983b484ed88447b9fc4c473e2759 which turned off custom drawing
too aggressively, removing custom indicators also if no custom drop
down arrow (which is only relevant for drop down menu buttons) was set.
When then drawing the custom indicator, respect positioning rules in the
style sheet.
Extend baseline test.
Fixes: QTBUG-102866
Pick-to: 6.3 6.2
Change-Id: I5ca353f42e704ec3f6e57677c35118a9cb358b0b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 02fe3f88e1..f84fd040e3 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3301,18 +3301,22 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC rule.drawBackground(p, toolOpt.rect); } - // Let base or windows style draw the button - // set drawDropDown and drawMenuIndicator flags to false, - // unless customDropDownArrow needs to be drawn - if (rule.baseStyleCanDraw() && !(tool->features & QStyleOptionToolButton::Arrow)) { - baseStyle()->drawComplexControl(cc, &toolOpt, p, w); - } else { - QWindowsStyle::drawComplexControl(cc, &toolOpt, p, w); - } - if (!customDropDownArrow) { - drawDropDown = false; + QStyleOptionToolButton nativeToolOpt(toolOpt); + // don't draw natively if we have a custom rule for menu indicators and/or buttons + if (customMenuIndicator) + nativeToolOpt.features &= ~(QStyleOptionToolButton::Menu | QStyleOptionToolButton::HasMenu); + if (customDropDown || customDropDownArrow) + nativeToolOpt.features &= ~(QStyleOptionToolButton::Menu | QStyleOptionToolButton::HasMenu | QStyleOptionToolButton::MenuButtonPopup); + // Let base or windows style draw the button, which will include the menu-button + if (rule.baseStyleCanDraw() && !(tool->features & QStyleOptionToolButton::Arrow)) + baseStyle()->drawComplexControl(cc, &nativeToolOpt, p, w); + else + QWindowsStyle::drawComplexControl(cc, &nativeToolOpt, p, w); + // if we did draw natively, don't draw custom + if (nativeToolOpt.features & (QStyleOptionToolButton::Menu | QStyleOptionToolButton::HasMenu)) drawMenuIndicator = false; - } + if (nativeToolOpt.features & QStyleOptionToolButton::MenuButtonPopup && !customDropDownArrow) + drawDropDown = false; } else { rule.drawRule(p, opt->rect); toolOpt.rect = rule.contentsRect(opt->rect); @@ -3349,7 +3353,8 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC } } else if (drawMenuIndicator) { QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenuIndicator); - QRect r = subRule.hasGeometry() + + QRect r = subRule.hasGeometry() || subRule.hasPosition() ? positionRect(w, subRule, PseudoElement_ToolButtonMenuIndicator, toolOpt.rect, toolOpt.direction) : subRule.contentsRect(opt->rect); if (subRule.hasDrawable()) { |