diff options
author | Andy Shaw <andy.shaw@qt.io> | 2020-10-08 16:20:22 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2020-10-08 17:34:47 +0000 |
commit | 51a57c7ea852151235b692475f08915edb16bb90 (patch) | |
tree | 053f5f3a6db90b955cee8550bd0d9b8e7aa2efef /src/imports | |
parent | 88bdce23e260cce2d3a163997d9032c3e6fac858 (diff) |
Only add a shortcut if the sequence is not empty
If the sequence is empty then reset m_shortcutId to -1 so it does not
have a shortcut attached to it.
Change-Id: I16945950145d9d3ca7da73e998b28d64997501d0
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 746358e855613de5401f5be867365188a19e4800)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/platform/qquickplatformmenuitem.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/imports/platform/qquickplatformmenuitem.cpp b/src/imports/platform/qquickplatformmenuitem.cpp index b45a95aa..72ad7d5d 100644 --- a/src/imports/platform/qquickplatformmenuitem.cpp +++ b/src/imports/platform/qquickplatformmenuitem.cpp @@ -558,8 +558,12 @@ void QQuickPlatformMenuItem::setShortcut(const QVariant& shortcut) sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(m_shortcut.toInt())); else sequence = QKeySequence::fromString(m_shortcut.toString()); - m_shortcutId = QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence, - Qt::WindowShortcut, QQuickShortcutContext::matcher); + if (!sequence.isEmpty()) { + m_shortcutId = QGuiApplicationPrivate::instance()->shortcutMap.addShortcut(this, sequence, + Qt::WindowShortcut, QQuickShortcutContext::matcher); + } else { + m_shortcutId = -1; + } #endif emit shortcutChanged(); } |