summaryrefslogtreecommitdiffstats
path: root/src/plugins/styles/mac/qmacstyle_mac.mm
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-13 20:01:51 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-28 12:45:36 +0000
commitc4c7bebb6ae18388f67f0c7b015ecb975177b7a7 (patch)
tree73f99ff3af0a7ef297ddac9bd0ed872afa63e774 /src/plugins/styles/mac/qmacstyle_mac.mm
parent3e1b877b95eddcb7efd33e5149c904dae3911617 (diff)
QStyleSheet: never treat styled scrollbars as transient
If a style sheet is applied to a scrollbar, then we cannot treat it as transient, as the QStyleSheetStyle doesn't implement any fade-in/out animation logic. And we also need to set the overlap to 0 (in both the style sheet and the macOS style) if the scrollbars are not transient; otherwise the opaque scrollbar will be placed on top of the content. Since a style sheet might only apply to a scrollbar based on its orientation, we also have to pass the style option through to all calls of the styleHint function. And since that function is also called from other QStyle implementations in the macOS style, we have to make sure that we call styleHint() on the widget's style to get the correct value based on the style sheet. Fixes: QTBUG-63381 Change-Id: Ic67ce3a7cb5089f885dabfd5a1951e3029915446 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit f5105ea89a76d6051f058834d99385582cc61f85) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/plugins/styles/mac/qmacstyle_mac.mm')
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index afa72b3f09..c95847851e 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -2553,10 +2553,13 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
case PM_ToolBarFrameWidth:
ret = 1;
break;
- case PM_ScrollView_ScrollBarOverlap:
- ret = [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay ?
- pixelMetric(PM_ScrollBarExtent, opt, widget) : 0;
+ case PM_ScrollView_ScrollBarOverlap: {
+ const QStyle *realStyle = widget ? widget->style() : proxy();
+ ret = realStyle->styleHint(SH_ScrollBar_Transient, opt, widget)
+ ? realStyle->pixelMetric(PM_ScrollBarExtent, opt, widget)
+ : 0;
break;
+ }
default:
ret = QCommonStyle::pixelMetric(metric, opt, widget);
break;
@@ -5192,7 +5195,8 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
const auto cocoaSize = d->effectiveAquaSizeConstrain(opt, widget);
const CGFloat maxExpandScale = expandedKnobWidths[cocoaSize] / knobWidths[cocoaSize];
- const bool isTransient = proxy()->styleHint(SH_ScrollBar_Transient, opt, widget);
+ const QStyle *realStyle = widget ? widget->style() : proxy();
+ const bool isTransient = realStyle->styleHint(SH_ScrollBar_Transient, opt, widget);
if (!isTransient)
d->stopAnimation(opt->styleObject);
bool wasActive = false;