/src/qtbase/src/gui/kernel/qkeymapper.cpp
Line | Count | Source |
1 | | // Copyright (C) 2016 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 | | // Qt-Security score:significant reason:default |
4 | | |
5 | | |
6 | | #include "qguiapplication.h" |
7 | | |
8 | | #include <private/qobject_p.h> |
9 | | #include "qkeymapper_p.h" |
10 | | |
11 | | #include <private/qguiapplication_p.h> |
12 | | #include <qpa/qplatformintegration.h> |
13 | | #include <qpa/qplatformkeymapper.h> |
14 | | |
15 | | QT_BEGIN_NAMESPACE |
16 | | |
17 | | /*! |
18 | | \class QKeyMapper |
19 | | \since 4.2 |
20 | | \internal |
21 | | |
22 | | \sa QObject |
23 | | */ |
24 | | |
25 | | /*! |
26 | | Constructs a new key mapper. |
27 | | */ |
28 | 0 | QKeyMapper::QKeyMapper() : QObject() |
29 | 0 | { |
30 | 0 | } |
31 | | |
32 | | /*! |
33 | | Destroys the key mapper. |
34 | | */ |
35 | | QKeyMapper::~QKeyMapper() |
36 | 0 | { |
37 | 0 | } |
38 | | |
39 | | QList<QKeyCombination> QKeyMapper::possibleKeys(const QKeyEvent *e) |
40 | 0 | { |
41 | 0 | qCDebug(lcQpaKeyMapper).verbosity(3) << "Computing possible key combinations for" << e; |
42 | |
|
43 | 0 | const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration(); |
44 | 0 | const auto *platformKeyMapper = platformIntegration->keyMapper(); |
45 | 0 | QList<QKeyCombination> result = platformKeyMapper->possibleKeyCombinations(e); |
46 | |
|
47 | 0 | if (result.isEmpty()) { |
48 | 0 | if (e->key() && (e->key() != Qt::Key_unknown)) |
49 | 0 | result << e->keyCombination(); |
50 | 0 | else if (!e->text().isEmpty()) |
51 | 0 | result << (Qt::Key(e->text().at(0).unicode()) | e->modifiers()); |
52 | 0 | } |
53 | |
|
54 | 0 | #if QT_CONFIG(shortcut) |
55 | 0 | if (lcQpaKeyMapper().isDebugEnabled()) { |
56 | 0 | qCDebug(lcQpaKeyMapper) << "Resulting possible key combinations:"; |
57 | 0 | for (auto keyCombination : result) { |
58 | 0 | auto keySequence = QKeySequence(keyCombination); |
59 | 0 | qCDebug(lcQpaKeyMapper).verbosity(0) << "\t-" |
60 | 0 | << keyCombination << "/" << keySequence << "/" |
61 | 0 | << qUtf8Printable(keySequence.toString(QKeySequence::NativeText)); |
62 | 0 | } |
63 | 0 | } |
64 | 0 | #endif |
65 | |
|
66 | 0 | return result; |
67 | 0 | } |
68 | | |
69 | | Q_GLOBAL_STATIC(QKeyMapper, keymapper) |
70 | | /*! |
71 | | Returns the pointer to the single instance of QKeyMapper in the application. |
72 | | If none yet exists, the function ensures that one is created. |
73 | | */ |
74 | | QKeyMapper *QKeyMapper::instance() |
75 | 0 | { |
76 | 0 | return keymapper(); |
77 | 0 | } |
78 | | |
79 | | void *QKeyMapper::resolveInterface(const char *name, int revision) const |
80 | 0 | { |
81 | 0 | Q_UNUSED(name); Q_UNUSED(revision); |
82 | 0 | using namespace QNativeInterface::Private; |
83 | |
|
84 | 0 | #if QT_CONFIG(evdev) |
85 | 0 | QT_NATIVE_INTERFACE_RETURN_IF(QEvdevKeyMapper, QGuiApplicationPrivate::platformIntegration()); |
86 | 0 | #endif |
87 | |
|
88 | | #if QT_CONFIG(vxworksevdev) |
89 | | QT_NATIVE_INTERFACE_RETURN_IF(QVxKeyMapper, QGuiApplicationPrivate::platformIntegration()); |
90 | | #endif |
91 | |
|
92 | 0 | return nullptr; |
93 | 0 | } |
94 | | |
95 | | QT_END_NAMESPACE |
96 | | |
97 | | #include "moc_qkeymapper_p.cpp" |