diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-11-02 19:55:30 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-11-05 14:49:45 +0000 |
commit | 15a07dbd30e3b242a0495eb6a3316411b493fab3 (patch) | |
tree | 9ee48f6736d579255d959c3005c598bb2409d165 /src | |
parent | 01069f8b3161db991d13513013b4487a8ac7d3cf (diff) |
Shortcut: make both nativeText and portableText available
They have different use cases. One is for display purposes,
whereas the other is suitable for storing to settings etc.
[ChangeLog][QtQuick] Added Shortcut.nativeText and portableText
properties to read back the key sequence as a string
Change-Id: I5575925ae08ccc9fa8933afc053651b0f3813181
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/qtquick2/plugins.qmltypes | 3 | ||||
-rw-r--r-- | src/quick/util/qquickshortcut.cpp | 27 | ||||
-rw-r--r-- | src/quick/util/qquickshortcut_p.h | 6 |
3 files changed, 28 insertions, 8 deletions
diff --git a/src/imports/qtquick2/plugins.qmltypes b/src/imports/qtquick2/plugins.qmltypes index f0645213b0..b11906ee09 100644 --- a/src/imports/qtquick2/plugins.qmltypes +++ b/src/imports/qtquick2/plugins.qmltypes @@ -3478,7 +3478,8 @@ Module { exports: ["QtQuick/Shortcut 2.5", "QtQuick/Shortcut 2.6"] exportMetaObjectRevisions: [0, 1] Property { name: "sequence"; type: "QVariant" } - Property { name: "sequenceString"; revision: 1; type: "string"; isReadonly: true } + Property { name: "nativeText"; revision: 1; type: "string"; isReadonly: true } + Property { name: "portableText"; revision: 1; type: "string"; isReadonly: true } Property { name: "enabled"; type: "bool" } Property { name: "autoRepeat"; type: "bool" } Property { name: "context"; type: "Qt::ShortcutContext" } diff --git a/src/quick/util/qquickshortcut.cpp b/src/quick/util/qquickshortcut.cpp index 9f32b6c180..e6f66f7bf1 100644 --- a/src/quick/util/qquickshortcut.cpp +++ b/src/quick/util/qquickshortcut.cpp @@ -134,20 +134,37 @@ void QQuickShortcut::setSequence(const QVariant &sequence) } /*! - \qmlproperty string QtQuick::Shortcut::sequenceString + \qmlproperty string QtQuick::Shortcut::nativeText \since 5.6 - This property provides the shortcut's key sequence as a string, - for display purposes (tooltips, for example). + This property provides the shortcut's key sequence as a platform specific + string. This means that it will be shown translated, and on OS X it will + resemble a key sequence from the menu bar. It is best to display this text + to the user (for example, on a tooltip). - \sa sequence + \sa sequence, portableText */ -QString QQuickShortcut::sequenceString() const +QString QQuickShortcut::nativeText() const { return m_shortcut.toString(QKeySequence::NativeText); } /*! + \qmlproperty string QtQuick::Shortcut::portableText + \since 5.6 + + This property provides the shortcut's key sequence as a string in a + "portable" format, suitable for reading and writing to a file. In many + cases, it will look similar to the native text on Windows and X11. + + \sa sequence, nativeText +*/ +QString QQuickShortcut::portableText() const +{ + return m_shortcut.toString(QKeySequence::PortableText); +} + +/*! \qmlproperty bool QtQuick::Shortcut::enabled This property holds whether the shortcut is enabled. diff --git a/src/quick/util/qquickshortcut_p.h b/src/quick/util/qquickshortcut_p.h index db02f8afae..d8a233af78 100644 --- a/src/quick/util/qquickshortcut_p.h +++ b/src/quick/util/qquickshortcut_p.h @@ -57,7 +57,8 @@ class QQuickShortcut : public QObject, public QQmlParserStatus 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(QString nativeText READ nativeText NOTIFY sequenceChanged FINAL REVISION 1) + Q_PROPERTY(QString portableText READ portableText 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) @@ -69,7 +70,8 @@ public: QVariant sequence() const; void setSequence(const QVariant &sequence); - Q_REVISION(1) QString sequenceString() const; + QString nativeText() const; + QString portableText() const; bool isEnabled() const; void setEnabled(bool enabled); |