summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDoris Verria <doris.verria@qt.io>2021-03-30 10:58:17 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-04-06 15:21:24 +0000
commit80a02a05794271058aee7962ff86fc1ab2014962 (patch)
tree52543e1c4817d887f97db6ca5ec7008830ee1bb2 /src
parent72d75a98f14c1033ddc588b30ede0dae5d82d48c (diff)
Fix label margins for pulldowns with custom styled menu indicator on macOS
Don't apply the QMacStyle's pulldownButton titlemargins to the QPushButton's contents rect if the button has a custom styled menu indicator. This causes the button's text/icon to be misaligned. Fixes: QTBUG-86134 Change-Id: I6ef95d51071c1d79f1cc07425a46958f50091b7e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 37f9f2e7afb2539ead355f1115e10835c2df9f92) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 2c06986561..d0809b87bc 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -5839,6 +5839,13 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
case SE_PushButtonBevel:
case SE_PushButtonFocusRect:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ if (btn->features & QStyleOptionButton::HasMenu
+ && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator)) {
+ QStyleOptionButton btnOpt(*btn);
+ btnOpt.features &= ~QStyleOptionButton::HasMenu;
+ return rule.baseStyleCanDraw() ? baseStyle()->subElementRect(se, &btnOpt, w)
+ : QWindowsStyle::subElementRect(se, &btnOpt, w);
+ }
if (rule.hasBox() || !rule.hasNativeBorder()) {
return visualRect(opt->direction, opt->rect, se == SE_PushButtonBevel
? rule.borderRect(opt->rect)