1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qplatformkeymapper.h"
5
6#include <private/qguiapplication_p.h>
7#include <qpa/qplatformintegration.h>
8
9QT_BEGIN_NAMESPACE
10
11Q_LOGGING_CATEGORY(lcQpaKeyMapper, "qt.qpa.keymapper")
12
13QPlatformKeyMapper::~QPlatformKeyMapper()
14{
15}
16
17/*
18 Should return a list of possible key combinations for the given key event.
19
20 For example, given a US English keyboard layout, the key event Shift+5
21 can represent both a "Shift+5" key combination, as well as just "%".
22*/
23QList<QKeyCombination> QPlatformKeyMapper::possibleKeyCombinations(const QKeyEvent *event) const
24{
25 auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
26 QList<int> possibleKeys = platformIntegration->possibleKeys(event);
27 QList<QKeyCombination> combinations;
28 for (int key : possibleKeys)
29 combinations << QKeyCombination::fromCombined(combined: key);
30 return combinations;
31}
32
33Qt::KeyboardModifiers QPlatformKeyMapper::queryKeyboardModifiers() const
34{
35 return QGuiApplicationPrivate::platformIntegration()->queryKeyboardModifiers();
36}
37
38QT_END_NAMESPACE
39

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtbase/src/gui/kernel/qplatformkeymapper.cpp