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/quick/util/qquickshortcut.cpp | |
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/quick/util/qquickshortcut.cpp')
-rw-r--r-- | src/quick/util/qquickshortcut.cpp | 27 |
1 files changed, 22 insertions, 5 deletions
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. |