Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | | - |
20 | | - |
21 | | - |
22 | | - |
23 | | - |
24 | | - |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | #include <qinputmethod.h> | - |
41 | #include <private/qinputmethod_p.h> | - |
42 | #include <qguiapplication.h> | - |
43 | #include <qtimer.h> | - |
44 | #include <qpa/qplatforminputcontext_p.h> | - |
45 | | - |
46 | #include <QDebug> | - |
47 | | - |
48 | QT_BEGIN_NAMESPACE | - |
49 | | - |
50 | | - |
51 | | - |
52 | | - |
53 | QInputMethod::QInputMethod() | - |
54 | : QObject(*new QInputMethodPrivate) | - |
55 | { | - |
56 | } | - |
57 | | - |
58 | | - |
59 | | - |
60 | | - |
61 | QInputMethod::~QInputMethod() | - |
62 | { | - |
63 | } | - |
64 | | - |
65 | | - |
66 | | - |
67 | | - |
68 | | - |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | | - |
76 | | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | QTransform QInputMethod::inputItemTransform() const | - |
82 | { | - |
83 | Q_D(const QInputMethod); | - |
84 | return d->inputItemTransform; | - |
85 | } | - |
86 | | - |
87 | | - |
88 | | - |
89 | | - |
90 | | - |
91 | | - |
92 | void QInputMethod::setInputItemTransform(const QTransform &transform) | - |
93 | { | - |
94 | Q_D(QInputMethod); | - |
95 | if (d->inputItemTransform == transform)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
96 | return; never executed: return; | 0 |
97 | | - |
98 | d->inputItemTransform = transform; | - |
99 | emit cursorRectangleChanged(); | - |
100 | emit anchorRectangleChanged(); | - |
101 | } never executed: end of block | 0 |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | | - |
107 | | - |
108 | | - |
109 | | - |
110 | | - |
111 | QRectF QInputMethod::inputItemRectangle() const | - |
112 | { | - |
113 | Q_D(const QInputMethod); | - |
114 | return d->inputRectangle; | - |
115 | } | - |
116 | | - |
117 | | - |
118 | | - |
119 | | - |
120 | | - |
121 | | - |
122 | | - |
123 | | - |
124 | void QInputMethod::setInputItemRectangle(const QRectF &rect) | - |
125 | { | - |
126 | Q_D(QInputMethod); | - |
127 | d->inputRectangle = rect; | - |
128 | } | - |
129 | | - |
130 | static QRectF QInputMethodinputMethodQueryRectangle_helper(Qt::cursorRectangle()InputMethodQuery imquery, const QTransform &xform) | - |
131 | { | - |
132 | Q_DQRectF r; | - |
133 | ifTRUE | never evaluated | FALSE | never evaluated |
(const QInputMethod);QObject *focusObject = qGuiApp->focusObject();TRUE | never evaluated | FALSE | never evaluated |
| 0 |
| if (!TRUE | never evaluated | FALSE | never evaluated |
focusObject)TRUE | never evaluated | FALSE | never evaluated |
| |
| return QRectF();TRUE | never evaluated | FALSE | never evaluated |
()) {TRUE | never evaluated | FALSE | never evaluated |
| |
134 | QInputMethodQueryEvent query(Qt::ImCursorRectangleimquery); | - |
135 | QGuiApplication::sendEvent(focusObject, &query); | - |
136 | QRectFr = query.value(Qt::ImCursorRectangleimquery).toRectF(); | - |
137 | if (!(r.isValid())TRUE | never evaluated | FALSE | never evaluated |
| 0 |
138 | r = xform.mapRect(r); never executed: r = xform.mapRect(r); | 0 |
139 | } never executed: end of block | 0 |
140 | return r; never executed: return r; | 0 |
141 | } | - |
142 | | - |
143 | | - |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
148 | | - |
149 | | - |
150 | QRectF ();QInputMethod::cursorRectangle() const | - |
151 | { | - |
152 | Q_D(const QInputMethod); | - |
153 | return inputMethodQueryRectangle_helper(Qt::ImCursorRectangle, d->inputItemTransform.mapRect); never executed: return inputMethodQueryRectangle_helper(Qt::ImCursorRectangle, d->inputItemTransform); | 0 |
154 | } | - |
155 | | - |
156 | | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | | - |
162 | | - |
163 | QRectF QInputMethod::anchorRectangle() const | - |
164 | { | - |
165 | Q_D(rconst QInputMethod); | - |
166 | return inputMethodQueryRectangle_helper(Qt::ImAnchorRectangle, d->inputItemTransform never executed: return inputMethodQueryRectangle_helper(Qt::ImAnchorRectangle, d->inputItemTransform); );never executed: return inputMethodQueryRectangle_helper(Qt::ImAnchorRectangle, d->inputItemTransform); | 0 |
167 | } | - |
168 | | - |
169 | | - |
170 | | - |
171 | | - |
172 | | - |
173 | | - |
174 | | - |
175 | | - |
176 | QRectF QInputMethod::keyboardRectangle() const | - |
177 | { | - |
178 | Q_D(const QInputMethod); | - |
179 | QPlatformInputContext *ic = d->platformInputContext(); | - |
180 | if (ic) | - |
181 | return ic->keyboardRect(); | - |
182 | return QRectF(); | - |
183 | } | - |
184 | | - |
185 | | - |
186 | | - |
187 | | - |
188 | | - |
189 | | - |
190 | | - |
191 | | - |
192 | QRectF QInputMethod::inputItemClipRectangle() const | - |
193 | { | - |
194 | Q_D(const QInputMethod); | - |
195 | return inputMethodQueryRectangle_helper(Qt::ImInputItemClipRectangle, d->inputItemTransform); never executed: return inputMethodQueryRectangle_helper(Qt::ImInputItemClipRectangle, d->inputItemTransform); | 0 |
196 | } | - |
197 | | - |
198 | | - |
199 | | - |
200 | | - |
201 | | - |
202 | | - |
203 | | - |
204 | | - |
205 | | - |
206 | void QInputMethod::show() | - |
207 | { | - |
208 | Q_D(QInputMethod); | - |
209 | QPlatformInputContext *ic = d->platformInputContext(); | - |
210 | if (ic) | - |
211 | ic->showInputPanel(); | - |
212 | } | - |
213 | | - |
214 | | - |
215 | | - |
216 | | - |
217 | | - |
218 | | - |
219 | | - |
220 | | - |
221 | void QInputMethod::hide() | - |
222 | { | - |
223 | Q_D(QInputMethod); | - |
224 | QPlatformInputContext *ic = d->platformInputContext(); | - |
225 | if (ic) | - |
226 | ic->hideInputPanel(); | - |
227 | } | - |
228 | | - |
229 | | - |
230 | | - |
231 | | - |
232 | | - |
233 | | - |
234 | | - |
235 | | - |
236 | | - |
237 | | - |
238 | bool QInputMethod::isVisible() const | - |
239 | { | - |
240 | Q_D(const QInputMethod); | - |
241 | QPlatformInputContext *ic = d->platformInputContext(); | - |
242 | if (ic) | - |
243 | return ic->isInputPanelVisible(); | - |
244 | return false; | - |
245 | } | - |
246 | | - |
247 | | - |
248 | | - |
249 | | - |
250 | | - |
251 | | - |
252 | | - |
253 | | - |
254 | void QInputMethod::setVisible(bool visible) | - |
255 | { | - |
256 | visible ? show() : hide(); | - |
257 | } | - |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
262 | | - |
263 | | - |
264 | | - |
265 | | - |
266 | | - |
267 | | - |
268 | | - |
269 | bool QInputMethod::isAnimating() const | - |
270 | { | - |
271 | Q_D(const QInputMethod); | - |
272 | QPlatformInputContext *ic = d->platformInputContext(); | - |
273 | if (ic) | - |
274 | return ic->isAnimating(); | - |
275 | return false; | - |
276 | } | - |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | | - |
282 | QLocale QInputMethod::locale() const | - |
283 | { | - |
284 | Q_D(const QInputMethod); | - |
285 | QPlatformInputContext *ic = d->platformInputContext(); | - |
286 | if (ic) | - |
287 | return ic->locale(); | - |
288 | return QLocale::c(); | - |
289 | } | - |
290 | | - |
291 | | - |
292 | | - |
293 | | - |
294 | | - |
295 | Qt::LayoutDirection QInputMethod::inputDirection() const | - |
296 | { | - |
297 | Q_D(const QInputMethod); | - |
298 | QPlatformInputContext *ic = d->platformInputContext(); | - |
299 | if (ic) | - |
300 | return ic->inputDirection(); | - |
301 | return Qt::LeftToRight; | - |
302 | } | - |
303 | | - |
304 | | - |
305 | | - |
306 | | - |
307 | | - |
308 | | - |
309 | | - |
310 | | - |
311 | | - |
312 | | - |
313 | | - |
314 | | - |
315 | void QInputMethod::update(Qt::InputMethodQueries queries) | - |
316 | { | - |
317 | Q_D(QInputMethod); | - |
318 | | - |
319 | if (queries & Qt::ImEnabled) {TRUE | never evaluated | FALSE | never evaluated |
| 0 |
320 | QObject *focus = qApp->focusObject(); | - |
321 | bool enabled = d->objectAcceptsInputMethod(focus); | - |
322 | QPlatformInputContextPrivate::setInputMethodAccepted(enabled); | - |
323 | } never executed: end of block | 0 |
324 | | - |
325 | QPlatformInputContext *ic = d->platformInputContext(); | - |
326 | if (ic)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
327 | ic->update(queries); never executed: ic->update(queries); | 0 |
328 | | - |
329 | if (queries & Qt::ImCursorRectangle)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
330 | emit cursorRectangleChanged(); never executed: cursorRectangleChanged(); | 0 |
331 | | - |
332 | if (queries & (Qt::ImAnchorRectangle))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
333 | emit anchorRectangleChanged(); never executed: anchorRectangleChanged(); | 0 |
334 | | - |
335 | if (queries & (Qt::ImInputItemClipRectangle))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
336 | emit inputItemClipRectangleChanged never executed: inputItemClipRectangleChanged(); ();never executed: inputItemClipRectangleChanged(); | 0 |
337 | } never executed: end of block | 0 |
338 | | - |
339 | | - |
340 | | - |
341 | | - |
342 | | - |
343 | | - |
344 | | - |
345 | void QInputMethod::reset() | - |
346 | { | - |
347 | Q_D(QInputMethod); | - |
348 | QPlatformInputContext *ic = d->platformInputContext(); | - |
349 | if (ic) | - |
350 | ic->reset(); | - |
351 | } | - |
352 | | - |
353 | | - |
354 | | - |
355 | | - |
356 | | - |
357 | | - |
358 | | - |
359 | | - |
360 | | - |
361 | void QInputMethod::commit() | - |
362 | { | - |
363 | Q_D(QInputMethod); | - |
364 | QPlatformInputContext *ic = d->platformInputContext(); | - |
365 | if (ic) | - |
366 | ic->commit(); | - |
367 | } | - |
368 | | - |
369 | | - |
370 | | - |
371 | | - |
372 | | - |
373 | | - |
374 | | - |
375 | | - |
376 | | - |
377 | | - |
378 | | - |
379 | | - |
380 | | - |
381 | | - |
382 | | - |
383 | | - |
384 | | - |
385 | void QInputMethod::invokeAction(Action a, int cursorPosition) | - |
386 | { | - |
387 | Q_D(QInputMethod); | - |
388 | QPlatformInputContext *ic = d->platformInputContext(); | - |
389 | if (ic) | - |
390 | ic->invokeAction(a, cursorPosition); | - |
391 | } | - |
392 | | - |
393 | bool QInputMethodPrivate::objectAcceptsInputMethod(QObject *object) | - |
394 | { | - |
395 | bool enabled = false; | - |
396 | if (object) { | - |
397 | QInputMethodQueryEvent query(Qt::ImEnabled); | - |
398 | QGuiApplication::sendEvent(object, &query); | - |
399 | enabled = query.value(Qt::ImEnabled).toBool(); | - |
400 | } | - |
401 | | - |
402 | return enabled; | - |
403 | } | - |
404 | | - |
405 | | - |
406 | | - |
407 | | - |
408 | QVariant QInputMethod::queryFocusObject(Qt::InputMethodQuery query, QVariant argument) | - |
409 | { | - |
410 | QVariant retval; | - |
411 | QObject *focusObject = qGuiApp->focusObject(); | - |
412 | if (!focusObject) | - |
413 | return retval; | - |
414 | | - |
415 | bool newMethodWorks = QMetaObject::invokeMethod(focusObject, "inputMethodQuery", | - |
416 | Qt::DirectConnection, | - |
417 | Q_RETURN_ARG(QVariant, retval), | - |
418 | Q_ARG(Qt::InputMethodQuery, query), | - |
419 | Q_ARG(QVariant, argument)); | - |
420 | if (newMethodWorks) | - |
421 | return retval; | - |
422 | | - |
423 | QInputMethodQueryEvent queryEvent(query); | - |
424 | QCoreApplication::sendEvent(focusObject, &queryEvent); | - |
425 | return queryEvent.value(query); | - |
426 | } | - |
427 | | - |
428 | QT_END_NAMESPACE | - |
429 | | - |
430 | #include "moc_qinputmethod.cpp" | - |
| | |