From 9a3bdbf40af7e4915ed343c8e9917a0f3f54e0ae Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 25 Aug 2018 22:39:38 +0200 Subject: [PATCH] QSS/QTabBar: properly handle QTabBar::scroller PM_TabBarScrollButtonWidth used the size of the ::scroller subcontrol without considering that there are two QToolButtons and therefore returned the wrong size for a single QToolButton. QStyleSheetStyle::subElementRect() had no handling for SE_TabBarScrollLeft/RightButton and therefore the values for the scroller toolbuttons set via the stylesheet were never used. Fix it by dividing the scroller width by two and add the code path to handle SE_TabBarScrollLeft/RightButton in QStyleSheetStyle::subElementRect Task-number: QTBUG-69653 Change-Id: I1adfe6333f3183bba621bbbb4d10969920c6cd46 Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qstylesheetstyle.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index fccc4f33a2..3e55bdaabc 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4853,13 +4853,12 @@ int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const return 0; break; - case PM_TabBarScrollButtonWidth: { + case PM_TabBarScrollButtonWidth: subRule = renderRule(w, opt, PseudoElement_TabBarScroller); if (subRule.hasContentsSize()) { QSize sz = subRule.size(); - return sz.width() != -1 ? sz.width() : sz.height(); + return (sz.width() != -1 ? sz.width() : sz.height()) / 2; } - } break; case PM_TabBarTabShiftHorizontal: @@ -5918,6 +5917,12 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c } break; + case SE_TabBarScrollLeftButton: + case SE_TabBarScrollRightButton: + if (hasStyleRule(w, PseudoElement_TabBarScroller)) + return ParentStyle::subElementRect(se, opt, w); + break; + case SE_TabBarTearIndicator: { QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTear); if (subRule.hasContentsSize()) {