From 3efedf510c85807df2eb38996af3137e163b23ad Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 11 Dec 2019 18:35:28 +0100 Subject: [PATCH] Improve debug information on key events Summary: Print the Qt::Key value on the debug window Test Plan: When I press the power button I get Key_PowerOff Reviewers: #kwin, romangg Reviewed By: #kwin, romangg Subscribers: romangg, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D25896 --- debug_console.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debug_console.cpp b/debug_console.cpp index f44a230fcd..c0f012ff33 100644 --- a/debug_console.cpp +++ b/debug_console.cpp @@ -289,7 +289,12 @@ void DebugConsoleFilter::keyEvent(KeyEvent *event) }; text.append(timestampRow(event->timestamp())); text.append(tableRow(i18nc("Whether the event is an automatic key repeat", "Repeat"), event->isAutoRepeat())); + + const auto keyMetaObject = Qt::qt_getEnumMetaObject(Qt::Key()); + const auto enumerator = keyMetaObject->enumerator(keyMetaObject->indexOfEnumerator("Key")); text.append(tableRow(i18nc("The code as read from the input device", "Scan code"), event->nativeScanCode())); + text.append(tableRow(i18nc("Key according to Qt", "Qt::Key code"), + enumerator.valueToKey(event->key()))); text.append(tableRow(i18nc("The translated code to an Xkb symbol", "Xkb symbol"), event->nativeVirtualKey())); text.append(tableRow(i18nc("The translated code interpreted as text", "Utf8"), event->text())); text.append(tableRow(i18nc("The currently active modifiers", "Modifiers"), modifiersToString()));