summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qkeysequence.cpp
diff options
context:
space:
mode:
authorDmitry Shachnev <mitya57@gmail.com>2016-01-21 20:15:02 +0300
committerDmitry Shachnev <mitya57@gmail.com>2016-02-02 16:27:38 +0000
commitf5ea4baa0dc81907f4375fe9620dc9c73c26d94c (patch)
tree3a5b6527d7e0674c19db74c10b5124a71bf46c2e /src/gui/kernel/qkeysequence.cpp
parent751e2ce44ffc87a2b528572a5086ba7738a63d1e (diff)
dbusmenu: Add support for shortcuts
To do that, split out and export a QKeySequencePrivate::keyName() function that returns the key text representation without the modifiers. The implementation is compatible with libdbusmenu-qt. Change-Id: Ibc3190a3949813a1610728cf89574027e5d2778d Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'src/gui/kernel/qkeysequence.cpp')
-rw-r--r--src/gui/kernel/qkeysequence.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index 46784f59be3..6bb80042eeb 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1261,7 +1261,28 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat
if ((key & Qt::KeypadModifier) == Qt::KeypadModifier)
addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Num") : QString::fromLatin1("Num"), format);
+ QString p = keyName(key, format);
+#if defined(Q_OS_OSX)
+ if (nativeText)
+ s += p;
+ else
+#endif
+ addKey(s, p, format);
+ return s;
+}
+
+/*!
+ \internal
+ Returns the text representation of the key \a key, which can be used i.e.
+ when the sequence is serialized. This does not take modifiers into account
+ (see encodeString() for a version that does).
+
+ This static method is used by encodeString() and by the D-Bus menu exporter.
+*/
+QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat format)
+{
+ bool nativeText = (format == QKeySequence::NativeText);
key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier);
QString p;
@@ -1312,14 +1333,7 @@ NonSymbol:
}
}
}
-
-#if defined(Q_OS_MACX)
- if (nativeText)
- s += p;
- else
-#endif
- addKey(s, p, format);
- return s;
+ return p;
}
/*!
Matches the sequence with \a seq. Returns ExactMatch if