diff options
author | Tor Arne Vestbø <[email protected]> | 2023-09-20 23:35:13 +0200 |
---|---|---|
committer | Tor Arne Vestbø <[email protected]> | 2023-10-06 15:48:45 +0200 |
commit | c74cfae7a3a8f446415a483846c74092189af31d (patch) | |
tree | 01427fd7d3d94edd4421af583ea9c9efbf454409 /src/gui/kernel/qplatformkeymapper.cpp | |
parent | d9bb8c0a1702ed345ddacdc0179a43d1dc4722a7 (diff) |
Long live QPlatformKeyMapper!
The QKeyMapper class never got a platform integration companion.
As we might be adding more functionality here in the future, let's
fix that now, instead of adding more hooks directly to the platform
integration class.
The QKeyMapper will soon update its possibleKeys signature to
return QKeyCombination, but for now transform the result.
Change-Id: I88ef498180b2a8a7937a74627b7eb6b5156e872a
Reviewed-by: Liang Qi <[email protected]>
Diffstat (limited to 'src/gui/kernel/qplatformkeymapper.cpp')
-rw-r--r-- | src/gui/kernel/qplatformkeymapper.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformkeymapper.cpp b/src/gui/kernel/qplatformkeymapper.cpp new file mode 100644 index 00000000000..f54e4ff3794 --- /dev/null +++ b/src/gui/kernel/qplatformkeymapper.cpp @@ -0,0 +1,38 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qplatformkeymapper.h" + +#include <private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> + +QT_BEGIN_NAMESPACE + +Q_LOGGING_CATEGORY(lcQpaKeyMapper, "qt.qpa.keymapper") + +QPlatformKeyMapper::~QPlatformKeyMapper() +{ +} + +/* + Should return a list of possible key combinations for the given key event. + + For example, given a US English keyboard layout, the key event Shift+5 + can represent both a "Shift+5" key combination, as well as just "%". +*/ +QList<QKeyCombination> QPlatformKeyMapper::possibleKeyCombinations(const QKeyEvent *event) const +{ + auto *platformIntegration = QGuiApplicationPrivate::platformIntegration(); + QList<int> possibleKeys = platformIntegration->possibleKeys(event); + QList<QKeyCombination> combinations; + for (int key : possibleKeys) + combinations << QKeyCombination::fromCombined(key); + return combinations; +} + +Qt::KeyboardModifiers QPlatformKeyMapper::queryKeyboardModifiers() const +{ + return QGuiApplicationPrivate::platformIntegration()->queryKeyboardModifiers(); +} + +QT_END_NAMESPACE |