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
qkeyboardmap_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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#ifndef QKEYBOARDMAP_P_H
5#define QKEYBOARDMAP_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qnamespace.h>
19#include <QtCore/qtconfigmacros.h>
20#include <QtCore/qdatastream.h>
21
22QT_BEGIN_NAMESPACE
23
24namespace QKeyboardMap {
25
26 const quint32 FileMagic = 0x514d4150; // 'QMAP'
27
37
38 enum Flags {
39 IsDead = 0x01,
40 IsLetter = 0x02,
41 IsModifier = 0x04,
42 IsSystem = 0x08
43 };
44
54
60
61 enum Modifiers {
62 ModPlain = 0x00,
63 ModShift = 0x01,
64 ModAltGr = 0x02,
65 ModControl = 0x04,
66 ModAlt = 0x08,
67 ModShiftL = 0x10,
68 ModShiftR = 0x20,
69 ModCtrlL = 0x40,
70 ModCtrlR = 0x80
71 // ModCapsShift = 0x100, // not supported!
72 };
73
75 {
76 Qt::KeyboardModifiers qtmod = Qt::NoModifier;
77
78 if (mod & (ModShift | ModShiftL | ModShiftR))
79 qtmod |= Qt::ShiftModifier;
80 if (mod & (ModControl | ModCtrlL | ModCtrlR))
81 qtmod |= Qt::ControlModifier;
82 if (mod & ModAlt)
83 qtmod |= Qt::AltModifier;
84
85 return qtmod;
86 }
87
88}
89
90inline QDataStream &operator>>(QDataStream &ds, QKeyboardMap::Mapping &m)
91{
92 return ds >> m.keycode >> m.unicode >> m.qtcode >> m.modifiers >> m.flags >> m.special;
93}
94
95inline QDataStream &operator<<(QDataStream &ds, const QKeyboardMap::Mapping &m)
96{
97 return ds << m.keycode << m.unicode << m.qtcode << m.modifiers << m.flags << m.special;
98}
99
100inline QDataStream &operator>>(QDataStream &ds, QKeyboardMap::Composing &c)
101{
102 return ds >> c.first >> c.second >> c.result;
103}
104
105inline QDataStream &operator<<(QDataStream &ds, const QKeyboardMap::Composing &c)
106{
107 return ds << c.first << c.second << c.result;
108}
109
110QT_END_NAMESPACE
111
112#endif // QKEYBOARDMAP_P_H
Qt::KeyboardModifiers toQtModifiers(quint8 mod)
const quint32 FileMagic
QDataStream & operator>>(QDataStream &ds, QKeyboardMap::Mapping &m)
QDataStream & operator>>(QDataStream &ds, QKeyboardMap::Composing &c)
QDataStream & operator<<(QDataStream &ds, const QKeyboardMap::Mapping &m)
QDataStream & operator<<(QDataStream &ds, const QKeyboardMap::Composing &c)