| 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 | |
| 8 | QT_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 | |
| 21 | QQuickInputMethod::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 | |
| 40 | void QQuickInputMethod::commit() |
| 41 | { |
| 42 | QGuiApplication::inputMethod()->commit(); |
| 43 | } |
| 44 | void QQuickInputMethod::hide() |
| 45 | { |
| 46 | QGuiApplication::inputMethod()->hide(); |
| 47 | } |
| 48 | void QQuickInputMethod::invokeAction(QInputMethod::Action a, int cursorPosition) |
| 49 | { |
| 50 | QGuiApplication::inputMethod()->invokeAction(a, cursorPosition); |
| 51 | } |
| 52 | void QQuickInputMethod::reset() |
| 53 | { |
| 54 | QGuiApplication::inputMethod()->reset(); |
| 55 | } |
| 56 | void QQuickInputMethod::show() |
| 57 | { |
| 58 | QGuiApplication::inputMethod()->show(); |
| 59 | } |
| 60 | void QQuickInputMethod::update(Qt::InputMethodQueries queries) |
| 61 | { |
| 62 | QGuiApplication::inputMethod()->update(queries); |
| 63 | } |
| 64 | |
| 65 | QRectF QQuickInputMethod::anchorRectangle() const |
| 66 | { |
| 67 | return QGuiApplication::inputMethod()->cursorRectangle(); |
| 68 | } |
| 69 | QRectF QQuickInputMethod::cursorRectangle() const |
| 70 | { |
| 71 | return QGuiApplication::inputMethod()->cursorRectangle(); |
| 72 | } |
| 73 | Qt::LayoutDirection QQuickInputMethod::inputDirection() const |
| 74 | { |
| 75 | return QGuiApplication::inputMethod()->inputDirection(); |
| 76 | } |
| 77 | QRectF QQuickInputMethod::inputItemClipRectangle() const |
| 78 | { |
| 79 | return QGuiApplication::inputMethod()->inputItemClipRectangle(); |
| 80 | } |
| 81 | |
| 82 | QRectF QQuickInputMethod::inputItemRectangle() const |
| 83 | { |
| 84 | return QGuiApplication::inputMethod()->inputItemRectangle(); |
| 85 | } |
| 86 | void QQuickInputMethod::setInputItemRectangle(const QRectF &rect) |
| 87 | { |
| 88 | QGuiApplication::inputMethod()->setInputItemRectangle(rect); |
| 89 | } |
| 90 | |
| 91 | QTransform QQuickInputMethod::inputItemTransform() const |
| 92 | { |
| 93 | return QGuiApplication::inputMethod()->inputItemTransform(); |
| 94 | } |
| 95 | void QQuickInputMethod::setInputItemTransform(const QTransform &transform) |
| 96 | { |
| 97 | QGuiApplication::inputMethod()->setInputItemTransform(transform); |
| 98 | } |
| 99 | |
| 100 | bool QQuickInputMethod::isAnimating() const |
| 101 | { |
| 102 | return QGuiApplication::inputMethod()->isAnimating(); |
| 103 | } |
| 104 | |
| 105 | bool QQuickInputMethod::isVisible() const |
| 106 | { |
| 107 | return QGuiApplication::inputMethod()->isVisible(); |
| 108 | } |
| 109 | void QQuickInputMethod::setVisible(bool visible) |
| 110 | { |
| 111 | QGuiApplication::inputMethod()->setVisible(visible); |
| 112 | } |
| 113 | |
| 114 | QRectF QQuickInputMethod::keyboardRectangle() const |
| 115 | { |
| 116 | return QGuiApplication::inputMethod()->keyboardRectangle(); |
| 117 | } |
| 118 | QLocale QQuickInputMethod::locale() const |
| 119 | { |
| 120 | return QGuiApplication::inputMethod()->locale(); |
| 121 | } |
| 122 | |
| 123 | QT_END_NAMESPACE |
| 124 | |
| 125 | #include "moc_qquickinputmethod_p.cpp" |
| 126 | |