From 07ec1021952a2aff80c9baccea9dcd947f5b5c0a Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 27 Feb 2017 19:57:30 -0800 Subject: Introduce SH_TitleBar_ShowToolTipsOnButtons style hint This removes some tight coupling between QMdiSubWindow and QMacStyle in order to allow the latter to be moved into a plugin. Change-Id: I090c2c5774279c0454486c3db2e77f00a646b145 Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Marc Mutz Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qcommonstyle.cpp | 3 +++ src/widgets/styles/qmacstyle_mac.mm | 4 ++++ src/widgets/styles/qstyle.cpp | 5 +++++ src/widgets/styles/qstyle.h | 1 + src/widgets/styles/qstylesheetstyle.cpp | 2 ++ 5 files changed, 15 insertions(+) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 18a0c4fb64..095cda1949 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5231,6 +5231,9 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget ret = QAbstractItemView::ScrollPerItem; break; #endif + case SH_TitleBar_ShowToolTipsOnButtons: + ret = true; + break; default: ret = 0; break; diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 4f318d3333..241f647b26 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -3025,6 +3025,10 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_ItemView_ScrollMode: ret = QAbstractItemView::ScrollPerPixel; break; + case SH_TitleBar_ShowToolTipsOnButtons: + // min/max/close buttons on windows don't show tool tips + ret = false; + break; default: ret = QCommonStyle::styleHint(sh, opt, w, hret); break; diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 01d972af65..7b2ac49fa4 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1987,6 +1987,11 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, by the style. Can be overridden with QAbstractItemView::setVerticalScrollMode() and QAbstractItemView::setHorizontalScrollMode(). This enum value has been introduced in Qt 5.7. + \value SH_TitleBar_ShowToolTipsOnButtons + Determines if tool tips are shown on window title bar buttons. + The Mac style, for example, sets this to false. + This enum value has been introduced in Qt 5.10. + \sa styleHint() */ diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index ce33dbed62..ae5ddbcd1f 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -737,6 +737,7 @@ public: SH_Menu_SubMenuResetWhenReenteringParent, SH_Menu_SubMenuDontStartSloppyOnLeave, SH_ItemView_ScrollMode, + SH_TitleBar_ShowToolTipsOnButtons, // Add new style hint values here SH_CustomBase = 0xf0000000 diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 65894a6dde..085c743437 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -679,6 +679,7 @@ static const char knownStyleHints[][45] = { "titlebar-minimize-icon", "titlebar-normal-icon", "titlebar-shade-icon", + "titlebar-show-tooltips-on-buttons", "titlebar-unshade-icon", "toolbutton-popup-delay", "trash-icon", @@ -5317,6 +5318,7 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi } case SH_ItemView_ArrowKeysNavigateIntoChildren: s = QLatin1String("arrow-keys-navigate-into-children"); break; case SH_ItemView_PaintAlternatingRowColorsForEmptyArea: s = QLatin1String("paint-alternating-row-colors-for-empty-area"); break; + case SH_TitleBar_ShowToolTipsOnButtons: s = QLatin1String("titlebar-show-tooltips-on-buttons"); break; default: break; } if (!s.isEmpty() && rule.hasStyleHint(s)) { -- cgit v1.2.3