From 9ef757ed2917593b94ab84868dcfee812c4d344b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 21 Sep 2023 14:14:46 +0200 Subject: [PATCH] Add verbose debug logging for QKeyMapper::possibleKeys() Generalized from the logging used in the Apple key mapper. Change-Id: I61cc120e31b72995071756961d36f6a7fae14553 Reviewed-by: Timur Pocheptsov --- src/gui/kernel/qkeymapper.cpp | 12 ++++++++++++ src/gui/platform/darwin/qapplekeymapper.mm | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/gui/kernel/qkeymapper.cpp b/src/gui/kernel/qkeymapper.cpp index 76ec7eba0dd..d62ff5657b0 100644 --- a/src/gui/kernel/qkeymapper.cpp +++ b/src/gui/kernel/qkeymapper.cpp @@ -37,6 +37,8 @@ QKeyMapper::~QKeyMapper() QList QKeyMapper::possibleKeys(const QKeyEvent *e) { + qCDebug(lcQpaKeyMapper).verbosity(3) << "Computing possible key combinations for" << e; + const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration(); const auto *platformKeyMapper = platformIntegration->keyMapper(); QList result = platformKeyMapper->possibleKeyCombinations(e); @@ -48,6 +50,16 @@ QList QKeyMapper::possibleKeys(const QKeyEvent *e) result << (Qt::Key(e->text().at(0).unicode()) | e->modifiers()); } + if (lcQpaKeyMapper().isDebugEnabled()) { + qCDebug(lcQpaKeyMapper) << "Resulting possible key combinations:"; + for (auto keyCombination : result) { + auto keySequence = QKeySequence(keyCombination); + qCDebug(lcQpaKeyMapper).verbosity(0) << "\t-" + << keyCombination << "/" << keySequence << "/" + << qUtf8Printable(keySequence.toString(QKeySequence::NativeText)); + } + } + return result; } diff --git a/src/gui/platform/darwin/qapplekeymapper.mm b/src/gui/platform/darwin/qapplekeymapper.mm index 7aefe64c6a5..944ae424b59 100644 --- a/src/gui/platform/darwin/qapplekeymapper.mm +++ b/src/gui/platform/darwin/qapplekeymapper.mm @@ -541,8 +541,6 @@ QList QAppleKeyMapper::possibleKeyCombinations(const QKeyEvent { QList ret; - qCDebug(lcQpaKeyMapper) << "Computing possible keys for" << event; - const auto nativeVirtualKey = event->nativeVirtualKey(); if (!nativeVirtualKey) return ret; @@ -579,16 +577,6 @@ QList QAppleKeyMapper::possibleKeyCombinations(const QKeyEvent } } - if (lcQpaKeyMapper().isDebugEnabled()) { - qCDebug(lcQpaKeyMapper) << "Possible keys:"; - for (auto keyCombination : ret) { - auto keySequence = QKeySequence(keyCombination); - qCDebug(lcQpaKeyMapper).verbosity(0) << "\t-" - << keyCombination << "/" << keySequence << "/" - << qUtf8Printable(keySequence.toString(QKeySequence::NativeText)); - } - } - return ret; }