1// Copyright (C) 2022 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#include "qquickinputmethod_p.h"
5
6#include <QtGui/qguiapplication.h>
7
8QT_BEGIN_NAMESPACE
9
10/*!
11 \qmltype InputMethod
12 \inqmlmodule QtQuick
13
14 \brief Provides access to \l QInputMethod for QML applications.
15
16 The InputMethod singleton allows access to application's \l QInputMethod object
17 and all its properties and slots. See the \l QInputMethod documentation for
18 further details.
19*/
20
21QQuickInputMethod::QQuickInputMethod(QObject *parent) : QObject(parent)
22{
23 QInputMethod *inputMethod = QGuiApplication::inputMethod();
24 connect(sender: inputMethod, signal: &QInputMethod::anchorRectangleChanged, context: this,
25 slot: &QQuickInputMethod::anchorRectangleChanged);
26 connect(sender: inputMethod, signal: &QInputMethod::animatingChanged, context: this,
27 slot: &QQuickInputMethod::animatingChanged);
28 connect(sender: inputMethod, signal: &QInputMethod::cursorRectangleChanged, context: this,
29 slot: &QQuickInputMethod::cursorRectangleChanged);
30 connect(sender: inputMethod, signal: &QInputMethod::inputDirectionChanged, context: this,
31 slot: &QQuickInputMethod::inputDirectionChanged);
32 connect(sender: inputMethod, signal: &QInputMethod::inputItemClipRectangleChanged, context: this,
33 slot: &QQuickInputMethod::inputItemClipRectangleChanged);
34 connect(sender: inputMethod, signal: &QInputMethod::keyboardRectangleChanged, context: this,
35 slot: &QQuickInputMethod::keyboardRectangleChanged);
36 connect(sender: inputMethod, signal: &QInputMethod::localeChanged, context: this, slot: &QQuickInputMethod::localeChanged);
37 connect(sender: inputMethod, signal: &QInputMethod::visibleChanged, context: this, slot: &QQuickInputMethod::visibleChanged);
38}
39
40void QQuickInputMethod::commit()
41{
42 QGuiApplication::inputMethod()->commit();
43}
44void QQuickInputMethod::hide()
45{
46 QGuiApplication::inputMethod()->hide();
47}
48void QQuickInputMethod::invokeAction(QInputMethod::Action a, int cursorPosition)
49{
50 QGuiApplication::inputMethod()->invokeAction(a, cursorPosition);
51}
52void QQuickInputMethod::reset()
53{
54 QGuiApplication::inputMethod()->reset();
55}
56void QQuickInputMethod::show()
57{
58 QGuiApplication::inputMethod()->show();
59}
60void QQuickInputMethod::update(Qt::InputMethodQueries queries)
61{
62 QGuiApplication::inputMethod()->update(queries);
63}
64
65QRectF QQuickInputMethod::anchorRectangle() const
66{
67 return QGuiApplication::inputMethod()->cursorRectangle();
68}
69QRectF QQuickInputMethod::cursorRectangle() const
70{
71 return QGuiApplication::inputMethod()->cursorRectangle();
72}
73Qt::LayoutDirection QQuickInputMethod::inputDirection() const
74{
75 return QGuiApplication::inputMethod()->inputDirection();
76}
77QRectF QQuickInputMethod::inputItemClipRectangle() const
78{
79 return QGuiApplication::inputMethod()->inputItemClipRectangle();
80}
81
82QRectF QQuickInputMethod::inputItemRectangle() const
83{
84 return QGuiApplication::inputMethod()->inputItemRectangle();
85}
86void QQuickInputMethod::setInputItemRectangle(const QRectF &rect)
87{
88 QGuiApplication::inputMethod()->setInputItemRectangle(rect);
89}
90
91QTransform QQuickInputMethod::inputItemTransform() const
92{
93 return QGuiApplication::inputMethod()->inputItemTransform();
94}
95void QQuickInputMethod::setInputItemTransform(const QTransform &transform)
96{
97 QGuiApplication::inputMethod()->setInputItemTransform(transform);
98}
99
100bool QQuickInputMethod::isAnimating() const
101{
102 return QGuiApplication::inputMethod()->isAnimating();
103}
104
105bool QQuickInputMethod::isVisible() const
106{
107 return QGuiApplication::inputMethod()->isVisible();
108}
109void QQuickInputMethod::setVisible(bool visible)
110{
111 QGuiApplication::inputMethod()->setVisible(visible);
112}
113
114QRectF QQuickInputMethod::keyboardRectangle() const
115{
116 return QGuiApplication::inputMethod()->keyboardRectangle();
117}
118QLocale QQuickInputMethod::locale() const
119{
120 return QGuiApplication::inputMethod()->locale();
121}
122
123QT_END_NAMESPACE
124
125#include "moc_qquickinputmethod_p.cpp"
126

source code of qtdeclarative/src/quick/util/qquickinputmethod.cpp