qkeymapper.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qkeymapper.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
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-
43QT_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*/-
56QKeyMapper::QKeyMapper()-
57 : QObject(*new QKeyMapperPrivate, 0)-
58{-
59}
never executed: end of block
0
60-
61/*!-
62 Destroys the key mapper.-
63*/-
64QKeyMapper::~QKeyMapper()-
65{-
66}-
67-
68QList<int> QKeyMapper::possibleKeys(QKeyEvent *e)-
69{-
70 QList<int> result;-
71-
72 if (!e->nativeScanCode()) {
!e->nativeScanCode()Description
TRUEnever evaluated
FALSEnever evaluated
0
73 if (e->key() && (e->key() != Qt::Key_unknown))
e->key()Description
TRUEnever evaluated
FALSEnever evaluated
(e->key() != Qt::Key_unknown)Description
TRUEnever evaluated
FALSEnever evaluated
0
74 result << int(e->key() + e->modifiers());
never executed: result << int(e->key() + e->modifiers());
0
75 else if (!e->text().isEmpty())
!e->text().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
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-
83extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // in qapplication_*.cpp-
84void 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-
100Q_GLOBAL_STATIC(QKeyMapper, keymapper)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
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*/-
105QKeyMapper *QKeyMapper::instance()-
106{-
107 return keymapper();
never executed: return keymapper();
0
108}-
109-
110QKeyMapperPrivate *qt_keymapper_private()-
111{-
112 return QKeyMapper::instance()->d_func();
never executed: return QKeyMapper::instance()->d_func();
0
113}-
114-
115QKeyMapperPrivate::QKeyMapperPrivate()-
116{-
117 keyboardInputLocale = QLocale::system();-
118 keyboardInputDirection = keyboardInputLocale.textDirection();-
119}
never executed: end of block
0
120-
121QKeyMapperPrivate::~QKeyMapperPrivate()-
122{-
123 // clearMappings();-
124}-
125-
126void QKeyMapperPrivate::clearMappings()-
127{-
128}-
129-
130QList<int> QKeyMapperPrivate::possibleKeys(QKeyEvent *e)-
131{-
132 QList<int> result = QGuiApplicationPrivate::platformIntegration()->possibleKeys(e);-
133 if (!result.isEmpty())
!result.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
134 return result;
never executed: return result;
0
135-
136 if (e->key() && (e->key() != Qt::Key_unknown))
e->key()Description
TRUEnever evaluated
FALSEnever evaluated
(e->key() != Qt::Key_unknown)Description
TRUEnever evaluated
FALSEnever evaluated
0
137 result << int(e->key() + e->modifiers());
never executed: result << int(e->key() + e->modifiers());
0
138 else if (!e->text().isEmpty())
!e->text().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
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-
143QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9