If you set sequence to a StandardKey, then read back the property,
you will get an int, which is not suitable for display.
Now you can use sequenceString for tooltips, preference dialogs
for setting shortcuts, and such.
[ChangeLog][QtQuick] Added Shortcut.sequenceString property to read
back the key sequence as a displayable string
Change-Id: I63ee46f8a2c2da1b1c803282baa894fb1667fe67
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
emit sequenceChanged();
}
+/*!
+ \qmlproperty string QtQuick::Shortcut::sequenceString
+ \since 5.6
+
+ This property provides the shortcut's key sequence as a string,
+ for display purposes (tooltips, for example).
+
+ \sa sequence
+*/
+QString QQuickShortcut::sequenceString() const
+{
+ return m_shortcut.toString(QKeySequence::NativeText);
+}
+
/*!
\qmlproperty bool QtQuick::Shortcut::enabled
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QVariant sequence READ sequence WRITE setSequence NOTIFY sequenceChanged FINAL)
+ Q_PROPERTY(QString sequenceString READ sequenceString NOTIFY sequenceChanged FINAL REVISION 1)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged FINAL)
Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL)
Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext NOTIFY contextChanged FINAL)
QVariant sequence() const;
void setSequence(const QVariant &sequence);
+ Q_REVISION(1) QString sequenceString() const;
+
bool isEnabled() const;
void setEnabled(bool enabled);
qmlRegisterType<QQuickTextMetrics>("QtQuick", 2, 4, "TextMetrics");
qmlRegisterType<QQuickShortcut>("QtQuick", 2, 5, "Shortcut");
+
+ qmlRegisterType<QQuickShortcut,1>("QtQuick", 2, 6, "Shortcut");
}