OSDN Git Service

fix QKeySequence encoding for certain keys
authorIvailo Monev <xakepa10@gmail.com>
Tue, 8 Dec 2020 11:20:52 +0000 (11:20 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Wed, 9 Dec 2020 05:01:56 +0000 (05:01 +0000)
the fallback for the case when the key is not found in the translated keys
table is the same as the one removed with this change anyway so the changes
done with this commit remove bad assumption about Qt::Key enum values,
deduplicates code and removes branch

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/core/global/qnamespace.h
src/gui/kernel/qkeysequence.cpp

index fab00bb..1a3b303 100644 (file)
@@ -510,6 +510,7 @@ public:
         Key_Super_R                       = 0xffec,
         Key_Hyper_L                       = 0xffed,
         Key_Hyper_R                       = 0xffee,
+
         // latin
         Key_Space                         = 0x0020,
         Key_Exclam                        = 0x0021,
index 8450f77..e64b1b8 100644 (file)
@@ -938,14 +938,7 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat
     key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier);
     QString p;
 
-    if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
-        if (!QChar::requiresSurrogates(key)) {
-            p = QChar::toUpper(ushort(key));
-        } else {
-            p += QChar(QChar::highSurrogate(key));
-            p += QChar(QChar::lowSurrogate(key));
-        }
-    } else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) {
+    if (key >= Qt::Key_F1 && key <= Qt::Key_F35) {
             p = nativeText ? QShortcut::tr("F%1").arg(key - Qt::Key_F1 + 1)
                            : QString::fromLatin1("F%1").arg(key - Qt::Key_F1 + 1);
     } else if (key) {