diff --git a/src/gui/kernel/qkeymapper.cpp b/src/gui/kernel/qkeymapper.cpp index bd7dbd90e9d..76ec7eba0dd 100644 --- a/src/gui/kernel/qkeymapper.cpp +++ b/src/gui/kernel/qkeymapper.cpp @@ -35,21 +35,17 @@ QKeyMapper::~QKeyMapper() { } -QList QKeyMapper::possibleKeys(const QKeyEvent *e) +QList QKeyMapper::possibleKeys(const QKeyEvent *e) { - QList result; - const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration(); const auto *platformKeyMapper = platformIntegration->keyMapper(); - const auto keyCombinations = platformKeyMapper->possibleKeyCombinations(e); - for (auto keyCombination : keyCombinations) - result << keyCombination.toCombined(); + QList result = platformKeyMapper->possibleKeyCombinations(e); if (result.isEmpty()) { if (e->key() && (e->key() != Qt::Key_unknown)) - result << e->keyCombination().toCombined(); + result << e->keyCombination(); else if (!e->text().isEmpty()) - result << int(e->text().at(0).unicode() + (int)e->modifiers()); + result << (Qt::Key(e->text().at(0).unicode()) | e->modifiers()); } return result; diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h index 5c6f89ab82e..1a6a9a608f4 100644 --- a/src/gui/kernel/qkeymapper_p.h +++ b/src/gui/kernel/qkeymapper_p.h @@ -33,7 +33,7 @@ public: ~QKeyMapper(); static QKeyMapper *instance(); - static QList possibleKeys(const QKeyEvent *e); + static QList possibleKeys(const QKeyEvent *e); QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QKeyMapper) diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index a2acf467e12..800e703ac2a 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -493,7 +493,7 @@ void QShortcutMap::clearSequence(QList &ksl) void QShortcutMap::createNewSequences(QKeyEvent *e, QList &ksl, int ignoredModifiers) { Q_D(QShortcutMap); - QList possibleKeys = QKeyMapper::possibleKeys(e); + QList possibleKeys = QKeyMapper::possibleKeys(e); qCDebug(lcShortcutMap) << "Creating new sequences for" << e << "with ignoredModifiers=" << Qt::KeyboardModifiers(ignoredModifiers); int pkTotal = possibleKeys.size(); @@ -522,7 +522,8 @@ void QShortcutMap::createNewSequences(QKeyEvent *e, QList &ksl, in curKsl.setKey(QKeyCombination::fromCombined(0), 2); curKsl.setKey(QKeyCombination::fromCombined(0), 3); } - curKsl.setKey(QKeyCombination::fromCombined(possibleKeys.at(pkNum) & ~ignoredModifiers), index); + const int key = possibleKeys.at(pkNum).toCombined(); + curKsl.setKey(QKeyCombination::fromCombined(key & ~ignoredModifiers), index); } } } diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 0b39d5c1c6f..65ed7a465a5 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -344,22 +344,23 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) return; if (e->modifiers() & Qt::ShiftModifier) { - const QList possibleKeys = QKeyMapper::possibleKeys(e); + const QList possibleKeys = QKeyMapper::possibleKeys(e); int pkTotal = possibleKeys.size(); if (!pkTotal) return; bool found = false; for (int i = 0; i < possibleKeys.size(); ++i) { - if (possibleKeys.at(i) - nextKey == int(e->modifiers()) - || (possibleKeys.at(i) == nextKey && e->modifiers() == Qt::ShiftModifier)) { - nextKey = possibleKeys.at(i); + const int key = possibleKeys.at(i).toCombined(); + if (key - nextKey == int(e->modifiers()) + || (key == nextKey && e->modifiers() == Qt::ShiftModifier)) { + nextKey = key; found = true; break; } } // Use as fallback if (!found) - nextKey = possibleKeys.first(); + nextKey = possibleKeys.first().toCombined(); } else { nextKey |= d->translateModifiers(e->modifiers(), e->text()); }