summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAxel Spoerl <Axel.Spoerl@qt.io>2022-02-11 14:01:27 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-16 12:39:47 +0000
commit71599dc5b49a0976a5b14f0a6577e83aef1dc9c7 (patch)
tree1392d4eaddac03d5a366ec0a274f54505584b923
parentb3d19fbf95143141c772b327eec07c8975a52514 (diff)
downloadqtbase-71599dc5b49a0976a5b14f0a6577e83aef1dc9c7.tar.gz
Eliminate double arrow in QToolButton
- InstantPopup mode is set and - application uses a stylesheet that does not apply to QToolButton Task-number: QTBUG-100401 Change-Id: Iadf752ad9280d59763f4efc1938927a9b83e6ad9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit ea0e0a865237983b484ed88447b9fc4c473e2759) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index c02ce92ee6..0d072b8770 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3307,18 +3307,18 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
toolOpt.features &= ~QStyleOptionToolButton::Arrow;
toolOpt.text = QString(); // we need to draw the arrow and the text ourselves
}
- const bool drawDropDown = tool->features & QStyleOptionToolButton::MenuButtonPopup;
+ bool drawDropDown = tool->features & QStyleOptionToolButton::MenuButtonPopup;
bool customDropDown = drawDropDown && hasStyleRule(w, PseudoElement_ToolButtonMenu);
bool customDropDownArrow = false;
- const bool drawMenuIndicator = tool->features & QStyleOptionToolButton::HasMenu;
+ bool drawMenuIndicator = tool->features & QStyleOptionToolButton::HasMenu;
if (customDropDown) {
toolOpt.subControls &= ~QStyle::SC_ToolButtonMenu;
customDropDownArrow = hasStyleRule(w, PseudoElement_ToolButtonMenuArrow);
if (customDropDownArrow)
toolOpt.features &= ~(QStyleOptionToolButton::Menu | QStyleOptionToolButton::HasMenu);
}
- bool customMenuIndicator = (!customDropDown && drawMenuIndicator)
- && hasStyleRule(w, PseudoElement_ToolButtonMenuIndicator);
+ const bool customMenuIndicator = (!customDropDown && drawMenuIndicator)
+ && hasStyleRule(w, PseudoElement_ToolButtonMenuIndicator);
if (customMenuIndicator)
toolOpt.features &= ~QStyleOptionToolButton::HasMenu;
@@ -3336,11 +3336,18 @@ 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;
+ drawMenuIndicator = false;
+ }
} else {
rule.drawRule(p, opt->rect);
toolOpt.rect = rule.contentsRect(opt->rect);
@@ -3350,6 +3357,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
}
const QRect cr = toolOpt.rect;
+ // Draw DropDownButton unless drawn before
if (drawDropDown) {
if (opt->subControls & QStyle::SC_ToolButtonMenu) {
QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenu);