Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
5#include "qguiapplication.h"
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
30
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
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)
85#endif
86
87 return nullptr;
88}
89
91
92#include "moc_qkeymapper_p.cpp"
static QPlatformIntegration * platformIntegration()
The QKeyEvent class describes a key event.
Definition qevent.h:424
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition qevent.cpp:1468
QString text() const
Returns the Unicode text that this key generated.
Definition qevent.h:443
int key() const
Returns the code of the key that was pressed or released.
Definition qevent.h:434
QKeyCombination keyCombination() const
Returns a QKeyCombination object containing both the key() and the modifiers() carried by this event.
Definition qevent.h:439
~QKeyMapper()
Destroys the key mapper.
QKeyMapper()
Constructs a new key mapper.
static QList< QKeyCombination > possibleKeys(const QKeyEvent *e)
The QKeySequence class encapsulates a key sequence as used by shortcuts.
\inmodule QtCore
Definition qobject.h:103
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
Definition qstring.h:1226
Combined button and popup list for selecting options.
@ Key_unknown
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define qCDebug(category,...)
#define QT_NATIVE_INTERFACE_RETURN_IF(NativeInterface, baseType)
GLuint name
GLuint64EXT * result
[6]
#define qUtf8Printable(string)
Definition qstring.h:1535
#define Q_UNUSED(x)