Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qkeymapper.cpp |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||||||||
2 | ** | - | ||||||||||||
3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
5 | ** | - | ||||||||||||
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
7 | ** | - | ||||||||||||
8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
9 | ** Commercial License Usage | - | ||||||||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
16 | ** | - | ||||||||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
25 | ** | - | ||||||||||||
26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
29 | ** | - | ||||||||||||
30 | ** $QT_END_LICENSE$ | - | ||||||||||||
31 | ** | - | ||||||||||||
32 | ****************************************************************************/ | - | ||||||||||||
33 | - | |||||||||||||
34 | - | |||||||||||||
35 | #include "qguiapplication.h" | - | ||||||||||||
36 | - | |||||||||||||
37 | #include <private/qobject_p.h> | - | ||||||||||||
38 | #include "qkeymapper_p.h" | - | ||||||||||||
39 | - | |||||||||||||
40 | #include <private/qguiapplication_p.h> | - | ||||||||||||
41 | #include <qpa/qplatformintegration.h> | - | ||||||||||||
42 | - | |||||||||||||
43 | QT_BEGIN_NAMESPACE | - | ||||||||||||
44 | - | |||||||||||||
45 | /*! | - | ||||||||||||
46 | \class QKeyMapper | - | ||||||||||||
47 | \since 4.2 | - | ||||||||||||
48 | \internal | - | ||||||||||||
49 | - | |||||||||||||
50 | \sa QObject | - | ||||||||||||
51 | */ | - | ||||||||||||
52 | - | |||||||||||||
53 | /*! | - | ||||||||||||
54 | Constructs a new key mapper. | - | ||||||||||||
55 | */ | - | ||||||||||||
56 | QKeyMapper::QKeyMapper() | - | ||||||||||||
57 | : QObject(*new QKeyMapperPrivate, 0) | - | ||||||||||||
58 | { | - | ||||||||||||
59 | } never executed: end of block | 0 | ||||||||||||
60 | - | |||||||||||||
61 | /*! | - | ||||||||||||
62 | Destroys the key mapper. | - | ||||||||||||
63 | */ | - | ||||||||||||
64 | QKeyMapper::~QKeyMapper() | - | ||||||||||||
65 | { | - | ||||||||||||
66 | } | - | ||||||||||||
67 | - | |||||||||||||
68 | QList<int> QKeyMapper::possibleKeys(QKeyEvent *e) | - | ||||||||||||
69 | { | - | ||||||||||||
70 | QList<int> result; | - | ||||||||||||
71 | - | |||||||||||||
72 | if (!e->nativeScanCode()) {
| 0 | ||||||||||||
73 | if (e->key() && (e->key() != Qt::Key_unknown))
| 0 | ||||||||||||
74 | result << int(e->key() + e->modifiers()); never executed: result << int(e->key() + e->modifiers()); | 0 | ||||||||||||
75 | else if (!e->text().isEmpty())
| 0 | ||||||||||||
76 | result << int(e->text().at(0).unicode() + e->modifiers()); never executed: result << int(e->text().at(0).unicode() + e->modifiers()); | 0 | ||||||||||||
77 | return result; never executed: return result; | 0 | ||||||||||||
78 | } | - | ||||||||||||
79 | - | |||||||||||||
80 | return instance()->d_func()->possibleKeys(e); never executed: return instance()->d_func()->possibleKeys(e); | 0 | ||||||||||||
81 | } | - | ||||||||||||
82 | - | |||||||||||||
83 | extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // in qapplication_*.cpp | - | ||||||||||||
84 | void QKeyMapper::changeKeyboard() | - | ||||||||||||
85 | { | - | ||||||||||||
86 | instance()->d_func()->clearMappings(); | - | ||||||||||||
87 | - | |||||||||||||
88 | // ## TODO: Support KeyboardLayoutChange on QPA | - | ||||||||||||
89 | #if 0 | - | ||||||||||||
90 | // inform all toplevel widgets of the change | - | ||||||||||||
91 | QEvent e(QEvent::KeyboardLayoutChange); | - | ||||||||||||
92 | QWidgetList list = QApplication::topLevelWidgets(); | - | ||||||||||||
93 | for (int i = 0; i < list.size(); ++i) { | - | ||||||||||||
94 | QWidget *w = list.at(i); | - | ||||||||||||
95 | qt_sendSpontaneousEvent(w, &e); | - | ||||||||||||
96 | } | - | ||||||||||||
97 | #endif | - | ||||||||||||
98 | } never executed: end of block | 0 | ||||||||||||
99 | - | |||||||||||||
100 | Q_GLOBAL_STATIC(QKeyMapper, keymapper) never executed: end of block never executed: guard.store(QtGlobalStatic::Destroyed); never executed: return &holder.value;
| 0 | ||||||||||||
101 | /*! | - | ||||||||||||
102 | Returns the pointer to the single instance of QKeyMapper in the application. | - | ||||||||||||
103 | If none yet exists, the function ensures that one is created. | - | ||||||||||||
104 | */ | - | ||||||||||||
105 | QKeyMapper *QKeyMapper::instance() | - | ||||||||||||
106 | { | - | ||||||||||||
107 | return keymapper(); never executed: return keymapper(); | 0 | ||||||||||||
108 | } | - | ||||||||||||
109 | - | |||||||||||||
110 | QKeyMapperPrivate *qt_keymapper_private() | - | ||||||||||||
111 | { | - | ||||||||||||
112 | return QKeyMapper::instance()->d_func(); never executed: return QKeyMapper::instance()->d_func(); | 0 | ||||||||||||
113 | } | - | ||||||||||||
114 | - | |||||||||||||
115 | QKeyMapperPrivate::QKeyMapperPrivate() | - | ||||||||||||
116 | { | - | ||||||||||||
117 | keyboardInputLocale = QLocale::system(); | - | ||||||||||||
118 | keyboardInputDirection = keyboardInputLocale.textDirection(); | - | ||||||||||||
119 | } never executed: end of block | 0 | ||||||||||||
120 | - | |||||||||||||
121 | QKeyMapperPrivate::~QKeyMapperPrivate() | - | ||||||||||||
122 | { | - | ||||||||||||
123 | // clearMappings(); | - | ||||||||||||
124 | } | - | ||||||||||||
125 | - | |||||||||||||
126 | void QKeyMapperPrivate::clearMappings() | - | ||||||||||||
127 | { | - | ||||||||||||
128 | } | - | ||||||||||||
129 | - | |||||||||||||
130 | QList<int> QKeyMapperPrivate::possibleKeys(QKeyEvent *e) | - | ||||||||||||
131 | { | - | ||||||||||||
132 | QList<int> result = QGuiApplicationPrivate::platformIntegration()->possibleKeys(e); | - | ||||||||||||
133 | if (!result.isEmpty())
| 0 | ||||||||||||
134 | return result; never executed: return result; | 0 | ||||||||||||
135 | - | |||||||||||||
136 | if (e->key() && (e->key() != Qt::Key_unknown))
| 0 | ||||||||||||
137 | result << int(e->key() + e->modifiers()); never executed: result << int(e->key() + e->modifiers()); | 0 | ||||||||||||
138 | else if (!e->text().isEmpty())
| 0 | ||||||||||||
139 | result << int(e->text().at(0).unicode() + e->modifiers()); never executed: result << int(e->text().at(0).unicode() + e->modifiers()); | 0 | ||||||||||||
140 | return result; never executed: return result; | 0 | ||||||||||||
141 | } | - | ||||||||||||
142 | - | |||||||||||||
143 | QT_END_NAMESPACE | - | ||||||||||||
Source code | Switch to Preprocessed file |