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 <shawn.rutledge@qt.io>
This commit is contained in:
Friedemann Kleint 2018-11-05 11:31:19 +01:00
parent 45a6397e3e
commit b1a9a7794f
2 changed files with 20 additions and 2 deletions

View File

@ -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);
}
}
/*!

View File

@ -64,7 +64,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject
Q_PROPERTY(bool setFocusOnTouchRelease READ setFocusOnTouchRelease STORED false CONSTANT FINAL)
Q_PROPERTY(bool showIsFullScreen READ showIsFullScreen STORED false CONSTANT FINAL)
Q_PROPERTY(bool showIsMaximized READ showIsMaximized STORED false CONSTANT FINAL)
Q_PROPERTY(bool showShortcutsInContextMenus READ showShortcutsInContextMenus STORED false CONSTANT FINAL)
Q_PROPERTY(bool showShortcutsInContextMenus READ showShortcutsInContextMenus WRITE setShowShortcutsInContextMenus NOTIFY showShortcutsInContextMenusChanged FINAL)
Q_PROPERTY(int startDragDistance READ startDragDistance NOTIFY startDragDistanceChanged FINAL)
Q_PROPERTY(int startDragTime READ startDragTime NOTIFY startDragTimeChanged FINAL)
Q_PROPERTY(int startDragVelocity READ startDragVelocity STORED false CONSTANT FINAL)
@ -93,6 +93,7 @@ public:
bool showIsFullScreen() const;
bool showIsMaximized() const;
bool showShortcutsInContextMenus() const;
void setShowShortcutsInContextMenus(bool showShortcutsInContextMenus);
int passwordMaskDelay() const;
QChar passwordMaskCharacter() const;
qreal fontSmoothingGamma() const;
@ -117,6 +118,7 @@ Q_SIGNALS:
void startDragTimeChanged(int startDragTime);
void tabFocusBehaviorChanged(Qt::TabFocusBehavior tabFocusBehavior);
void useHoverEffectsChanged(bool useHoverEffects);
void showShortcutsInContextMenusChanged(bool);
void wheelScrollLinesChanged(int scrollLines);
void mouseQuickSelectionThresholdChanged(int threshold);