Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qohosinputcontext.h
Go to the documentation of this file.
1// Copyright (C) 2025 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#ifndef QOHOSINPUTCONTEXT_H
5#define QOHOSINPUTCONTEXT_H
6
7#include <qohosenums.h>
8#include <qohosinputmethodproxy.h>
9#include <qohosplugincore.h>
10#include <qpa/qplatforminputcontext.h>
11#include <qpa/qwindowsysteminterface.h>
12#include <QtCore/private/qohoscommon_p.h>
13#include <QtCore/qglobal.h>
14
16
17class QOhosNativeXComponent;
18
20{
22
23public:
25
27
29
31
34 bool isValid() const override { return true; }
35
36 void reset() override;
37 void commit() override;
38 void update(Qt::InputMethodQueries queries) override;
39 void invokeAction(QInputMethod::Action action, int cursorPosition) override;
40 QRectF keyboardRect() const override;
41 bool isAnimating() const override;
44 bool isInputPanelVisible() const override;
45 void setFocusObject(QObject *object) override;
47
48 void setSoftwareKeyboardVisibilityStatus(bool visible);
49 void setLastInputTypeToTriggerSoftKeyboard(RequestKeyboardReason inputType);
50
51 bool eventFilter(QObject *obj, QEvent *event) override;
52private:
53 enum class ImConnectionState {
54 Attached,
55 Detached,
56 };
57
58 struct JsScopeData
59 {
60 std::shared_ptr<void> imControllerCallbacksHandle;
61 };
62
63 void setImConnectionState(ImConnectionState requestedState);
64 void setImConnectionStateImpl(ImConnectionState requestedState);
65 void dispatchRequestedImStateChange(ImConnectionState requestedState);
66 void showTextInput();
67 void updateInputMethodControllerAttributes(
68 Qt::InputMethodHints qtInputMethodHints, Qt::EnterKeyType qtEnterKeyType);
69 void updateOhosCursor(const QRect &globalCursorRect);
70 bool attachToInputMethodController();
71 bool detachFromInputMethodController();
72 void handleRequestedImConnectionState(ImConnectionState requestedState, bool success);
73
74 void onCursorRectangleChanged();
75 void handleFocusInEvent(QObject *obj, QFocusEvent *event);
76
77 void sendInsertedTextToQt(const std::string &textToInsert);
78 void sendInsertedPreviewTextToQt(std::string previewText);
79 void sendFocusObjectInputMethodEvent(QInputMethodEvent *event);
80 void sendCursorMoveToQt(QOhosInputContext::Direction direction);
81 void sendFocusObjectFunctionalKeyEvent(Qt::Key key, const QChar &keyChar, int repeatCount = 1);
82
83 bool queryImEnabled() const;
84 Qt::InputMethodHints queryInputMethodHints() const;
85 Qt::EnterKeyType queryEnterKeyType() const;
86 QOhosOptional<int> tryQueryCursorPosition() const;
87 QSharedPointer<QInputMethodQueryEvent> tryQueryFocusObjectInputMethod(Qt::InputMethodQueries queries) const;
88
89 QRect m_lastCursorRectangle;
90 QPoint m_lastFocusedWindowPosition;
91
92 ImConnectionState m_imConnectionState = ImConnectionState::Detached;
93 ImConnectionState m_imConnectionRequestedState = ImConnectionState::Detached;
94 bool m_imConnectionRequestActive = false;
95
96 bool m_updateCursorRectangleAfterAttaching = false;
97 bool m_softwareKeyboardVisible = false;
98
99 QOhosOptional<RequestKeyboardReason> m_lastInputTypeToTriggerSoftKeyboard;
100
101 bool m_qtImEnabled;
102 Qt::InputMethodHints m_qtInputMethodHints;
103 Qt::EnterKeyType m_qtEnterKeyType;
104
105 std::shared_ptr<JsScopeData> m_jsScopeData;
106 std::shared_ptr<QOhosInputMethodProxy> m_imProxy;
107
108 QPointer<QObject> m_focusObject;
109 QString m_pendingPreeditText;
110};
111
112QT_END_NAMESPACE
113
114#endif // QOHOSINPUTCONTEXT_H
QOhosFloatingWindow(QWindow *window)
~QOhosFloatingWindow() override
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
void setVisible(bool visible) override
Reimplemented in subclasses to show the surface if visible is true, and hide it if visible is false.
bool startSystemMove() override
Reimplement this method to start a system move operation if the system supports it and return true to...
QOhosView * ownedViewOrNull() const override
void onWindowStateChanged(Qt::WindowStates oldWindowState, Qt::WindowStates currentWindowState) override
WId winId() const override
Reimplement in subclasses to return a handle to the native window.
void initialize() override
Called as part of QWindow::create(), after constructing the window.
void onWindowFlagsChanged(Qt::WindowFlags previousWindowFlags, Qt::WindowFlags currentWindowFlags) override
bool windowEvent(QEvent *event) override
Reimplement this method to be able to do any platform specific event handling.
void setGeometry(const QRect &rect) override
This function is called by Qt whenever a window is moved or resized using the QWindow API.
QOhosSurface * ownedSurfaceOrNull() const override
void setMask(const QRegion &region) override
Reimplement to be able to let Qt set the mask of a window.
void lower() override
Reimplement to be able to let Qt lower windows to the bottom of the desktop.
void raise() override
Reimplement to be able to let Qt raise windows to the top of the desktop.
QtOhos::enums::ohos::inputMethod::TextInputType TextInputType
void update(Qt::InputMethodQueries queries) override
Notification on editor updates.
QRectF keyboardRect() const override
This function can be reimplemented to return virtual keyboard rectangle in currently active window co...
void setSoftwareKeyboardVisibilityStatus(bool visible)
void showInputPanel() override
Request to show input panel.
void invokeAction(QInputMethod::Action action, int cursorPosition) override
Called when the word currently being composed in the input item is tapped by the user.
void setLastInputTypeToTriggerSoftKeyboard(RequestKeyboardReason inputType)
void reset() override
Method to be called when input method needs to be reset.
void hideInputPanel() override
Request to hide input panel.
bool isValid() const override
Returns input context validity.
bool eventFilter(QObject *obj, QEvent *event) override
Filters events if this object has been installed as an event filter for the watched object.
bool isInputPanelVisible() const override
Returns input panel visibility status.
QtOhos::enums::ohos::inputMethod::EnterKeyType EnterKeyType
QObject * focusObjectOrNull() const
void setFocusObject(QObject *object) override
This virtual method gets called to notify updated focus to object.
bool isAnimating() const override
This function can be reimplemented to return true whenever input method is animating shown or hidden.
QtOhos::enums::ohos::inputMethod::Direction Direction
static QOhosPlatformIntegration * instance()
void setExposedFromOhos(bool exposed)
void initialize() override
Called as part of QWindow::create(), after constructing the window.
void notifyInputSystemsWindowActiveStatusChanged(bool active)
void requestActivateWindow() override
Reimplement to let Qt be able to request activation/focus for a window.
bool isWindowPcModeEnabled() const
QOhosSurface * surfaceOrNull() const
void setWindowMask(const QOhosWindowProxy::WindowMask &windowMask)
void lower()
bool startMoving()
void raise()
QtOhos::enums::ohos::window::AvoidAreaType AvoidAreaType
QtOhos::enums::ohos::window::RectChangeReason RectChangeReason
QtOhos::enums::ohos::window::WindowEventType WindowEventType
QtOhos::enums::ohos::window::WindowStatusType WindowStatusType
static QWindowProxyRegistry & instance()
Combined button and popup list for selecting options.
bool isWindowRotatedByTabletScreenRotation(QWindow *window, QOhosWindowProxy::RectChangeOptions rectChangeOptions)