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>
bb10
Jake Petroules 2017-02-27 19:57:30 -08:00
parent 8f52ad9fe0
commit 07ec102195
7 changed files with 22 additions and 7 deletions

View File

@ -2433,6 +2433,12 @@
See also
\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}

View File

@ -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;

View File

@ -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;

View File

@ -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()
*/

View File

@ -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

View File

@ -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)) {

View File

@ -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.