summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qplatformkeymapper.cpp
blob: f54e4ff3794ad8f1c9a5dfea9fb1ce8dffa4a0c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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