From 409e3eab092ae9896f453b69f4b4749e654680bb Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 28 Mar 2019 10:42:38 +0100 Subject: QMacStyle - fix PE_InticatorTabClose handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/plugins/styles/mac/qmacstyle_mac.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index fd006b1ca3..0745e917a2 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -3411,18 +3411,20 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai case PE_IndicatorTabClose: { // Make close button visible only on the hovered tab. QTabBar *tabBar = qobject_cast(w->parentWidget()); + const QWidget *closeBtn = w; if (!tabBar) { // QStyleSheetStyle instead of CloseButton (which has // a QTabBar as a parent widget) uses the QTabBar itself: tabBar = qobject_cast(const_cast(w)); + closeBtn = decltype(closeBtn)(property("_q_styleSheetRealCloseButton").value()); } if (tabBar) { const bool documentMode = tabBar->documentMode(); const QTabBarPrivate *tabBarPrivate = static_cast(QObjectPrivate::get(tabBar)); const int hoveredTabIndex = tabBarPrivate->hoveredTabIndex(); if (!documentMode || - (hoveredTabIndex != -1 && ((w == tabBar->tabButton(hoveredTabIndex, QTabBar::LeftSide)) || - (w == tabBar->tabButton(hoveredTabIndex, QTabBar::RightSide))))) { + (hoveredTabIndex != -1 && ((closeBtn == tabBar->tabButton(hoveredTabIndex, QTabBar::LeftSide)) || + (closeBtn == tabBar->tabButton(hoveredTabIndex, QTabBar::RightSide))))) { const bool hover = (opt->state & State_MouseOver); const bool selected = (opt->state & State_Selected); const bool pressed = (opt->state & State_Sunken); -- cgit v1.2.3