From e6c9ef72a9d39a450909aa49030bcae1724af23d Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 4 Sep 2020 10:43:21 +0200 Subject: [PATCH] QWindowsKeyMapper: fix mixed math between int and enum/flags Either do it between ints, or cast to the right types before doing it. This should enable removing operator+ and - between int and QFlags. Change-Id: I30ecc03566cff8ce880b048ba3a9d7d50f3c8509 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index bca23cb33e..c6569d3983 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -907,7 +907,7 @@ bool QWindowsKeyMapper::translateMultimediaKeyEventInternal(QWindow *window, con // QTBUG-43343: Make sure to return false if Qt does not handle the key, otherwise, // the keys are not passed to the active media player. # if QT_CONFIG(shortcut) - const QKeySequence sequence(Qt::Modifier(state) + qtKey); + const QKeySequence sequence(Qt::Modifier(state) | Qt::Key(qtKey)); return QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(sequence); # else return false; @@ -1379,14 +1379,14 @@ QList QWindowsKeyMapper::possibleKeys(const QKeyEvent *e) const result << int(Qt::Key_Enter + keyMods); return result; } - result << int(baseKey + keyMods); // The base key is _always_ valid, of course + result << int(baseKey) + int(keyMods); // The base key is _always_ valid, of course for (size_t i = 1; i < NumMods; ++i) { Qt::KeyboardModifiers neededMods = ModsTbl[i]; quint32 key = kbItem.qtKey[i]; if (key && key != baseKey && ((keyMods & neededMods) == neededMods)) { const Qt::KeyboardModifiers missingMods = keyMods & ~neededMods; - const int matchedKey = int(key) + missingMods; + const int matchedKey = int(key) + int(missingMods); const auto it = std::find_if(result.begin(), result.end(), [key] (int k) { return (k & ~Qt::KeyboardModifierMask) == key; });