From b1a9a7794f51dd214e884fe331c5d1009972a48e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 5 Nov 2018 11:31:19 +0100 Subject: Add setter for property QStyleHints::showShortcutsInContextMenus Add a tri-state setter logic similar to the other properties. Fixes: QTBUG-71471 Change-Id: Iddb5be18a037634a53ad8725bddb91c12fb33fed Reviewed-by: Shawn Rutledge --- src/gui/kernel/qstylehints.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/gui/kernel/qstylehints.cpp') diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp index b00e6fb0fd..9b5b7a6f1e 100644 --- a/src/gui/kernel/qstylehints.cpp +++ b/src/gui/kernel/qstylehints.cpp @@ -77,6 +77,7 @@ public: int m_cursorFlashTime = -1; int m_tabFocusBehavior = -1; int m_uiEffects = -1; + int m_showShortcutsInContextMenus = -1; int m_wheelScrollLines = -1; int m_mouseQuickSelectionThreshold = -1; }; @@ -358,10 +359,25 @@ bool QStyleHints::showIsMaximized() const \since 5.10 \brief \c true if the platform normally shows shortcut key sequences in context menus, otherwise \c false. + + Since Qt 5.13, the setShowShortcutsInContextMenus() function can be used to + override the platform default. */ bool QStyleHints::showShortcutsInContextMenus() const { - return themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool(); + Q_D(const QStyleHints); + return d->m_showShortcutsInContextMenus >= 0 + ? d->m_showShortcutsInContextMenus != 0 + : themeableHint(QPlatformTheme::ShowShortcutsInContextMenus, QPlatformIntegration::ShowShortcutsInContextMenus).toBool(); +} + +void QStyleHints::setShowShortcutsInContextMenus(bool s) +{ + Q_D(QStyleHints); + if (s != showShortcutsInContextMenus()) { + d->m_showShortcutsInContextMenus = s ? 1 : 0; + emit showShortcutsInContextMenusChanged(s); + } } /*! -- cgit v1.2.3