Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qplatforminputcontext.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 | #include "qplatforminputcontext.h" | - | ||||||
35 | #include <qguiapplication.h> | - | ||||||
36 | #include <QRect> | - | ||||||
37 | #include "private/qkeymapper_p.h" | - | ||||||
38 | #include <qpa/qplatforminputcontext_p.h> | - | ||||||
39 | - | |||||||
40 | QT_BEGIN_NAMESPACE | - | ||||||
41 | - | |||||||
42 | /*! | - | ||||||
43 | \class QPlatformInputContext | - | ||||||
44 | \since 5.0 | - | ||||||
45 | \internal | - | ||||||
46 | \preliminary | - | ||||||
47 | \ingroup qpa | - | ||||||
48 | \brief The QPlatformInputContext class abstracts the input method dependent data and composing state. | - | ||||||
49 | - | |||||||
50 | An input method is responsible for inputting complex text that cannot | - | ||||||
51 | be inputted via simple keymap. It converts a sequence of input | - | ||||||
52 | events (typically key events) into a text string through the input | - | ||||||
53 | method specific converting process. The class of the processes are | - | ||||||
54 | widely ranging from simple finite state machine to complex text | - | ||||||
55 | translator that pools a whole paragraph of a text with text | - | ||||||
56 | editing capability to perform grammar and semantic analysis. | - | ||||||
57 | - | |||||||
58 | To abstract such different input method specific intermediate | - | ||||||
59 | information, Qt offers the QPlatformInputContext as base class. The | - | ||||||
60 | concept is well known as 'input context' in the input method | - | ||||||
61 | domain. An input context is created for a text widget in response | - | ||||||
62 | to a demand. It is ensured that an input context is prepared for | - | ||||||
63 | an input method before input to a text widget. | - | ||||||
64 | - | |||||||
65 | QPlatformInputContext provides an interface the actual input methods | - | ||||||
66 | can derive from by reimplementing methods. | - | ||||||
67 | - | |||||||
68 | \sa QInputMethod | - | ||||||
69 | */ | - | ||||||
70 | - | |||||||
71 | /*! | - | ||||||
72 | \internal | - | ||||||
73 | */ | - | ||||||
74 | QPlatformInputContext::QPlatformInputContext() | - | ||||||
75 | : QObject(*(new QPlatformInputContextPrivate)) | - | ||||||
76 | { | - | ||||||
77 | } never executed: end of block | 0 | ||||||
78 | - | |||||||
79 | /*! | - | ||||||
80 | \internal | - | ||||||
81 | */ | - | ||||||
82 | QPlatformInputContext::~QPlatformInputContext() | - | ||||||
83 | { | - | ||||||
84 | } | - | ||||||
85 | - | |||||||
86 | /*! | - | ||||||
87 | Returns input context validity. Deriving implementations should return true. | - | ||||||
88 | */ | - | ||||||
89 | bool QPlatformInputContext::isValid() const | - | ||||||
90 | { | - | ||||||
91 | return false; never executed: return false; | 0 | ||||||
92 | } | - | ||||||
93 | - | |||||||
94 | /*! | - | ||||||
95 | Returns whether the implementation supports \a capability. | - | ||||||
96 | \internal | - | ||||||
97 | \since 5.4 | - | ||||||
98 | */ | - | ||||||
99 | bool QPlatformInputContext::hasCapability(Capability capability) const | - | ||||||
100 | { | - | ||||||
101 | Q_UNUSED(capability) | - | ||||||
102 | return true; never executed: return true; | 0 | ||||||
103 | } | - | ||||||
104 | - | |||||||
105 | /*! | - | ||||||
106 | Method to be called when input method needs to be reset. Called by QInputMethod::reset(). | - | ||||||
107 | No further QInputMethodEvents should be sent as response. | - | ||||||
108 | */ | - | ||||||
109 | void QPlatformInputContext::reset() | - | ||||||
110 | { | - | ||||||
111 | } | - | ||||||
112 | - | |||||||
113 | void QPlatformInputContext::commit() | - | ||||||
114 | { | - | ||||||
115 | } | - | ||||||
116 | - | |||||||
117 | /*! | - | ||||||
118 | Notification on editor updates. Called by QInputMethod::update(). | - | ||||||
119 | */ | - | ||||||
120 | void QPlatformInputContext::update(Qt::InputMethodQueries) | - | ||||||
121 | { | - | ||||||
122 | } | - | ||||||
123 | - | |||||||
124 | /*! | - | ||||||
125 | Called when when the word currently being composed in input item is tapped by | - | ||||||
126 | the user. Input methods often use this information to offer more word | - | ||||||
127 | suggestions to the user. | - | ||||||
128 | */ | - | ||||||
129 | void QPlatformInputContext::invokeAction(QInputMethod::Action action, int cursorPosition) | - | ||||||
130 | { | - | ||||||
131 | Q_UNUSED(cursorPosition) | - | ||||||
132 | // Default behavior for simple ephemeral input contexts. Some | - | ||||||
133 | // complex input contexts should not be reset here. | - | ||||||
134 | if (action == QInputMethod::Click)
| 0 | ||||||
135 | reset(); never executed: reset(); | 0 | ||||||
136 | } never executed: end of block | 0 | ||||||
137 | - | |||||||
138 | /*! | - | ||||||
139 | This function can be reimplemented to filter input events. | - | ||||||
140 | Return true if the event has been consumed. Otherwise, the unfiltered event will | - | ||||||
141 | be forwarded to widgets as ordinary way. Although the input events have accept() | - | ||||||
142 | and ignore() methods, leave it untouched. | - | ||||||
143 | */ | - | ||||||
144 | bool QPlatformInputContext::filterEvent(const QEvent *event) | - | ||||||
145 | { | - | ||||||
146 | Q_UNUSED(event) | - | ||||||
147 | return false; never executed: return false; | 0 | ||||||
148 | } | - | ||||||
149 | - | |||||||
150 | /*! | - | ||||||
151 | This function can be reimplemented to return virtual keyboard rectangle in currently active | - | ||||||
152 | window coordinates. Default implementation returns invalid rectangle. | - | ||||||
153 | */ | - | ||||||
154 | QRectF QPlatformInputContext::keyboardRect() const | - | ||||||
155 | { | - | ||||||
156 | return QRectF(); never executed: return QRectF(); | 0 | ||||||
157 | } | - | ||||||
158 | - | |||||||
159 | /*! | - | ||||||
160 | Active QPlatformInputContext is responsible for providing keyboardRectangle property to QInputMethod. | - | ||||||
161 | In addition of providing the value in keyboardRect function, it also needs to call this emit | - | ||||||
162 | function whenever the property changes. | - | ||||||
163 | */ | - | ||||||
164 | void QPlatformInputContext::emitKeyboardRectChanged() | - | ||||||
165 | { | - | ||||||
166 | emit QGuiApplication::inputMethod()->keyboardRectangleChanged(); | - | ||||||
167 | } never executed: end of block | 0 | ||||||
168 | - | |||||||
169 | /*! | - | ||||||
170 | This function can be reimplemented to return true whenever input method is animating | - | ||||||
171 | shown or hidden. Default implementation returns \c false. | - | ||||||
172 | */ | - | ||||||
173 | bool QPlatformInputContext::isAnimating() const | - | ||||||
174 | { | - | ||||||
175 | return false; never executed: return false; | 0 | ||||||
176 | } | - | ||||||
177 | - | |||||||
178 | /*! | - | ||||||
179 | Active QPlatformInputContext is responsible for providing animating property to QInputMethod. | - | ||||||
180 | In addition of providing the value in isAnimation function, it also needs to call this emit | - | ||||||
181 | function whenever the property changes. | - | ||||||
182 | */ | - | ||||||
183 | void QPlatformInputContext::emitAnimatingChanged() | - | ||||||
184 | { | - | ||||||
185 | emit QGuiApplication::inputMethod()->animatingChanged(); | - | ||||||
186 | } never executed: end of block | 0 | ||||||
187 | - | |||||||
188 | /*! | - | ||||||
189 | Request to show input panel. | - | ||||||
190 | */ | - | ||||||
191 | void QPlatformInputContext::showInputPanel() | - | ||||||
192 | { | - | ||||||
193 | } | - | ||||||
194 | - | |||||||
195 | /*! | - | ||||||
196 | Request to hide input panel. | - | ||||||
197 | */ | - | ||||||
198 | void QPlatformInputContext::hideInputPanel() | - | ||||||
199 | { | - | ||||||
200 | } | - | ||||||
201 | - | |||||||
202 | /*! | - | ||||||
203 | Returns input panel visibility status. Default implementation returns \c false. | - | ||||||
204 | */ | - | ||||||
205 | bool QPlatformInputContext::isInputPanelVisible() const | - | ||||||
206 | { | - | ||||||
207 | return false; never executed: return false; | 0 | ||||||
208 | } | - | ||||||
209 | - | |||||||
210 | /*! | - | ||||||
211 | Active QPlatformInputContext is responsible for providing visible property to QInputMethod. | - | ||||||
212 | In addition of providing the value in isInputPanelVisible function, it also needs to call this emit | - | ||||||
213 | function whenever the property changes. | - | ||||||
214 | */ | - | ||||||
215 | void QPlatformInputContext::emitInputPanelVisibleChanged() | - | ||||||
216 | { | - | ||||||
217 | emit QGuiApplication::inputMethod()->visibleChanged(); | - | ||||||
218 | } never executed: end of block | 0 | ||||||
219 | - | |||||||
220 | QLocale QPlatformInputContext::locale() const | - | ||||||
221 | { | - | ||||||
222 | return qt_keymapper_private()->keyboardInputLocale; never executed: return qt_keymapper_private()->keyboardInputLocale; | 0 | ||||||
223 | } | - | ||||||
224 | - | |||||||
225 | void QPlatformInputContext::emitLocaleChanged() | - | ||||||
226 | { | - | ||||||
227 | emit QGuiApplication::inputMethod()->localeChanged(); | - | ||||||
228 | } never executed: end of block | 0 | ||||||
229 | - | |||||||
230 | Qt::LayoutDirection QPlatformInputContext::inputDirection() const | - | ||||||
231 | { | - | ||||||
232 | return qt_keymapper_private()->keyboardInputDirection; never executed: return qt_keymapper_private()->keyboardInputDirection; | 0 | ||||||
233 | } | - | ||||||
234 | - | |||||||
235 | void QPlatformInputContext::emitInputDirectionChanged(Qt::LayoutDirection newDirection) | - | ||||||
236 | { | - | ||||||
237 | emit QGuiApplication::inputMethod()->inputDirectionChanged(newDirection); | - | ||||||
238 | } never executed: end of block | 0 | ||||||
239 | - | |||||||
240 | /*! | - | ||||||
241 | This virtual method gets called to notify updated focus to \a object. | - | ||||||
242 | \warning Input methods must not call this function directly. | - | ||||||
243 | */ | - | ||||||
244 | void QPlatformInputContext::setFocusObject(QObject *object) | - | ||||||
245 | { | - | ||||||
246 | Q_UNUSED(object) | - | ||||||
247 | } never executed: end of block | 0 | ||||||
248 | - | |||||||
249 | /*! | - | ||||||
250 | Returns \c true if current focus object supports input method events. | - | ||||||
251 | */ | - | ||||||
252 | bool QPlatformInputContext::inputMethodAccepted() const | - | ||||||
253 | { | - | ||||||
254 | return QPlatformInputContextPrivate::s_inputMethodAccepted; never executed: return QPlatformInputContextPrivate::s_inputMethodAccepted; | 0 | ||||||
255 | } | - | ||||||
256 | - | |||||||
257 | bool QPlatformInputContextPrivate::s_inputMethodAccepted = false; | - | ||||||
258 | - | |||||||
259 | void QPlatformInputContextPrivate::setInputMethodAccepted(bool accepted) | - | ||||||
260 | { | - | ||||||
261 | QPlatformInputContextPrivate::s_inputMethodAccepted = accepted; | - | ||||||
262 | } never executed: end of block | 0 | ||||||
263 | - | |||||||
264 | - | |||||||
265 | QT_END_NAMESPACE | - | ||||||
Source code | Switch to Preprocessed file |