diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2019-03-28 10:42:38 +0100 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2019-04-01 14:11:25 +0000 |
commit | 409e3eab092ae9896f453b69f4b4749e654680bb (patch) | |
tree | c74efc8e8937333af6bef43051c9c68e73be1b18 /src/widgets | |
parent | 6ccbe7ffdfee0a69ba50d22f577075b1d8cb0b04 (diff) |
QMacStyle - fix PE_InticatorTabClose handling
for the case a custom style sheet is in use and QStyleSheetStyle
replaces the widget (close button) with its parent (QTabBar).
We still need this button though to compare against tabButton
on a hovered tab. This allows us to have, indeed, native-looking
tabs as documented (aka similar to Safari or the "Terminal" application).
Change-Id: I53ff78699e705db6d7c7b84774b8e188a1277535
Fixes: QTBUG-61092
Fixes: QTBUG-74689
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 79fa20851f..73b147e622 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4590,8 +4590,12 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op break; #if QT_CONFIG(tabbar) case PE_IndicatorTabClose: - if (w) + if (w) { + // QMacStyle needs a real widget, not its parent - to implement + // 'document mode' properly, drawing nothing if a tab is not hovered. + baseStyle()->setProperty("_q_styleSheetRealCloseButton", QVariant::fromValue((void *)w)); w = w->parentWidget(); //match on the QTabBar instead of the CloseButton + } pseudoElement = PseudoElement_TabBarTabCloseButton; #endif @@ -4609,6 +4613,9 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } else { baseStyle()->drawPrimitive(pe, opt, p, w); } + + if (baseStyle()->property("_q_styleSheetRealCloseButton").toBool()) + baseStyle()->setProperty("_q_styleSheetRealCloseButton", QVariant(QVariant::Invalid)); } QPixmap QStyleSheetStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap, |