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 <richard.gustavsen@qt.io>
This commit is contained in:
Christian Ehrlicher 2018-08-25 22:39:38 +02:00
parent d2c05b0c85
commit 9a3bdbf40a

View File

@ -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()) {