diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-02-27 19:57:30 -0800 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-03-08 20:51:01 +0000 |
commit | 07ec1021952a2aff80c9baccea9dcd947f5b5c0a (patch) | |
tree | 4478115edd712ba382fce371ffa829add1dd3784 /src/widgets | |
parent | 8f52ad9fe084eee26869e4a94a678076845a6f58 (diff) |
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) <ogoffart@woboq.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | 6 | ||||
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 4 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.cpp | 5 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.h | 1 | ||||
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qmdisubwindow.cpp | 8 |
7 files changed, 22 insertions, 7 deletions
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index 61379fb2f0..1bf6c082a1 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -2434,6 +2434,12 @@ \l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}. \row + \li \b{\c titlebar-show-tooltips-on-buttons}} + \target titlebar-show-tooltips-on-buttons-prop + \li \c bool + \li Whether tool tips are shown on window title bar buttons. + + \row \li \b{\c text-align} \target text-align-prop \li \l{#Alignment}{Alignment} \li The alignment of text and icon within the contents of the widget. 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)) { diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index a9e89e8f67..5ea86a592e 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -158,9 +158,6 @@ #include <QMainWindow> #include <QScrollBar> #include <QDebug> -#if QT_CONFIG(style_mac) -#include <private/qmacstyle_mac_p.h> -#endif #include <QMdiArea> #include <QScopedValueRollback> @@ -300,11 +297,8 @@ static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOpti Q_ASSERT(helpEvent->type() == QEvent::ToolTip); Q_ASSERT(widget); -#if QT_CONFIG(style_mac) - // Native Mac windows don't show tool tip. - if (qobject_cast<QMacStyle *>(widget->style())) + if (widget->style()->styleHint(QStyle::SH_TitleBar_ShowToolTipsOnButtons, &opt, widget)) return; -#endif // Convert CC_MdiControls to CC_TitleBar. Sub controls of different complex // controls cannot be in the same switch as they might have the same value. |