Add verbose debug logging for QKeyMapper::possibleKeys()

Generalized from the logging used in the Apple key mapper.

Change-Id: I61cc120e31b72995071756961d36f6a7fae14553
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2023-09-21 14:14:46 +02:00
parent f8f5e2c122
commit 9ef757ed29
2 changed files with 12 additions and 12 deletions

View File

@ -37,6 +37,8 @@ QKeyMapper::~QKeyMapper()
QList<QKeyCombination> QKeyMapper::possibleKeys(const QKeyEvent *e) QList<QKeyCombination> QKeyMapper::possibleKeys(const QKeyEvent *e)
{ {
qCDebug(lcQpaKeyMapper).verbosity(3) << "Computing possible key combinations for" << e;
const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration(); const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
const auto *platformKeyMapper = platformIntegration->keyMapper(); const auto *platformKeyMapper = platformIntegration->keyMapper();
QList<QKeyCombination> result = platformKeyMapper->possibleKeyCombinations(e); QList<QKeyCombination> result = platformKeyMapper->possibleKeyCombinations(e);
@ -48,6 +50,16 @@ QList<QKeyCombination> QKeyMapper::possibleKeys(const QKeyEvent *e)
result << (Qt::Key(e->text().at(0).unicode()) | e->modifiers()); 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; return result;
} }

View File

@ -541,8 +541,6 @@ QList<QKeyCombination> QAppleKeyMapper::possibleKeyCombinations(const QKeyEvent
{ {
QList<QKeyCombination> ret; QList<QKeyCombination> ret;
qCDebug(lcQpaKeyMapper) << "Computing possible keys for" << event;
const auto nativeVirtualKey = event->nativeVirtualKey(); const auto nativeVirtualKey = event->nativeVirtualKey();
if (!nativeVirtualKey) if (!nativeVirtualKey)
return ret; return ret;
@ -579,16 +577,6 @@ QList<QKeyCombination> 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; return ret;
} }