From a0def9b90dd9eb18692b35df12e5a43ca0e5fa32 Mon Sep 17 00:00:00 2001 From: Doris Verria Date: Tue, 30 Mar 2021 10:58:17 +0200 Subject: 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 Reviewed-by: Richard Moe Gustavsen (cherry picked from commit 37f9f2e7afb2539ead355f1115e10835c2df9f92) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/styles/qstylesheetstyle.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 6efba358c0..b9c0aaa199 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -5855,6 +5855,13 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c case SE_PushButtonBevel: case SE_PushButtonFocusRect: if (const QStyleOptionButton *btn = qstyleoption_cast(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) -- cgit v1.2.3