Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qkeymapper.cpp
Go to the documentation of this file.
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
4
6
7#include <private/qobject_p.h>
8#include "qkeymapper_p.h"
9
10#include <private/qguiapplication_p.h>
11#include <qpa/qplatformintegration.h>
12#include <qpa/qplatformkeymapper.h>
13
15
16/*!
17 \class QKeyMapper
18 \since 4.2
19 \internal
20
21 \sa QObject
22*/
23
24/*!
25 Constructs a new key mapper.
26*/
27QKeyMapper::QKeyMapper() : QObject()
28{
29}
30
31/*!
32 Destroys the key mapper.
33*/
34QKeyMapper::~QKeyMapper()
35{
36}
37
38QList<QKeyCombination> QKeyMapper::possibleKeys(const QKeyEvent *e)
39{
40 qCDebug(lcQpaKeyMapper).verbosity(3) << "Computing possible key combinations for" << e;
41
42 const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
43 const auto *platformKeyMapper = platformIntegration->keyMapper();
44 QList<QKeyCombination> result = platformKeyMapper->possibleKeyCombinations(e);
45
46 if (result.isEmpty()) {
47 if (e->key() && (e->key() != Qt::Key_unknown))
48 result << e->keyCombination();
49 else if (!e->text().isEmpty())
50 result << (Qt::Key(e->text().at(0).unicode()) | e->modifiers());
51 }
52
53#if QT_CONFIG(shortcut)
54 if (lcQpaKeyMapper().isDebugEnabled()) {
55 qCDebug(lcQpaKeyMapper) << "Resulting possible key combinations:";
56 for (auto keyCombination : result) {
57 auto keySequence = QKeySequence(keyCombination);
58 qCDebug(lcQpaKeyMapper).verbosity(0) << "\t-"
59 << keyCombination << "/" << keySequence << "/"
60 << qUtf8Printable(keySequence.toString(QKeySequence::NativeText));
61 }
62 }
63#endif
64
65 return result;
66}
67
68Q_GLOBAL_STATIC(QKeyMapper, keymapper)
69/*!
70 Returns the pointer to the single instance of QKeyMapper in the application.
71 If none yet exists, the function ensures that one is created.
72*/
73QKeyMapper *QKeyMapper::instance()
74{
75 return keymapper();
76}
77
78void *QKeyMapper::resolveInterface(const char *name, int revision) const
79{
80 Q_UNUSED(name); Q_UNUSED(revision);
81 using namespace QNativeInterface::Private;
82
83#if QT_CONFIG(evdev)
84 QT_NATIVE_INTERFACE_RETURN_IF(QEvdevKeyMapper, QGuiApplicationPrivate::platformIntegration());
85#endif
86
87#if QT_CONFIG(vxworksevdev)
88 QT_NATIVE_INTERFACE_RETURN_IF(QVxKeyMapper, QGuiApplicationPrivate::platformIntegration());
89#endif
90
91 return nullptr;
92}
93
94QT_END_NAMESPACE
95
96#include "moc_qkeymapper_p.cpp"
Combined button and popup list for selecting options.
Q_GLOBAL_STATIC(DefaultRoleNames, qDefaultRoleNames, { { Qt::DisplayRole, "display" }, { Qt::DecorationRole, "decoration" }, { Qt::EditRole, "edit" }, { Qt::ToolTipRole, "toolTip" }, { Qt::StatusTipRole, "statusTip" }, { Qt::WhatsThisRole, "whatsThis" }, }) const QHash< int