summaryrefslogtreecommitdiff
path: root/src/controls/qquickaction.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-06-12 23:48:01 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-20 23:59:31 +0200
commitffbf8d724f39e9c8d05ae2049e8b79a61570e235 (patch)
treeb1bdf614d2063eb71cc50f0f21d58076e8f21a72 /src/controls/qquickaction.cpp
parent0a3192fe4100dd790dc1467cc2cab200fb996ab0 (diff)
downloadqtquickcontrols-ffbf8d724f39e9c8d05ae2049e8b79a61570e235.tar.gz
Support StandardKeys for Action/MenuItem::shortcut
Change-Id: I2054a59fcda26795721e5d7d04cc644220da372b Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com> Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'src/controls/qquickaction.cpp')
-rw-r--r--src/controls/qquickaction.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/controls/qquickaction.cpp b/src/controls/qquickaction.cpp
index e240d111..aaae51c5 100644
--- a/src/controls/qquickaction.cpp
+++ b/src/controls/qquickaction.cpp
@@ -156,9 +156,20 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \qmlproperty string Action::shortcut
+ \qmlproperty keysequence Action::shortcut
- Shortcut bound to the action. Defaults to the empty string.
+ Shortcut bound to the action. The keysequence can be a string
+ or a \l {QKeySequence::StandardKey}{standard key}.
+
+ Defaults to an empty string.
+
+ \qml
+ Action {
+ id: copyAction
+ text: qsTr("&Copy")
+ shortcut: StandardKey.Copy
+ }
+ \endqml
*/
/*! \qmlsignal Action::triggered()
@@ -226,14 +237,19 @@ bool qShortcutContextMatcher(QObject *o, Qt::ShortcutContext context)
return false;
}
-QString QQuickAction::shortcut() const
+QVariant QQuickAction::shortcut() const
{
return m_shortcut.toString(QKeySequence::NativeText);
}
-void QQuickAction::setShortcut(const QString &arg)
+void QQuickAction::setShortcut(const QVariant &arg)
{
- QKeySequence sequence = QKeySequence::fromString(arg);
+ QKeySequence sequence;
+ if (arg.type() == QVariant::Int)
+ sequence = QKeySequence(static_cast<QKeySequence::StandardKey>(arg.toInt()));
+ else
+ sequence = QKeySequence::fromString(arg.toString());
+
if (sequence == m_shortcut)
return;