4#ifndef QOHOSINPUTCONTEXT_H
5#define QOHOSINPUTCONTEXT_H
8#include <qohosinputmethodproxy.h>
9#include <qohosqpaenums.h>
10#include <qpa/qplatforminputcontext.h>
11#include <qpa/qwindowsysteminterface.h>
12#include <QtCore/private/qohoscommon_p.h>
13#include <QtCore/qglobal.h>
14#include <QtCore/qpointer.h>
15#include <QtCore/qsharedpointer.h>
19class QOhosNativeXComponent;
40 void update(Qt::InputMethodQueries queries)
override;
41 void invokeAction(QInputMethod::Action action,
int cursorPosition)
override;
53 bool eventFilter(QObject *obj, QEvent *event)
override;
55 enum class ImConnectionState {
62 std::shared_ptr<
void> imControllerCallbacksHandle;
65 struct PreviewReplaceRange
71 void setImConnectionState(ImConnectionState requestedState);
72 void setImConnectionStateImpl(ImConnectionState requestedState);
73 void dispatchRequestedImStateChange(ImConnectionState requestedState);
75 void updateInputMethodControllerAttributes(
76 Qt::InputMethodHints qtInputMethodHints, Qt::EnterKeyType qtEnterKeyType);
77 void updateOhosCursor(
const QRect &globalCursorRect);
78 void pushTextAroundCursorToProxy();
79 void updateSelection();
80 bool attachToInputMethodController();
81 bool detachFromInputMethodController();
82 void handleRequestedImConnectionState(ImConnectionState requestedState,
bool success);
84 void onCursorRectangleChanged();
85 void handleFocusInEvent(QObject *obj, QFocusEvent *event);
87 void sendInsertedTextToQt(
const std::string &textToInsert);
88 void sendInsertedPreviewTextToQt(
std::string previewText,
int start,
int end);
89 void sendFocusObjectInputMethodEvent(QInputMethodEvent *event);
91 void sendFocusObjectFunctionalKeyEvent(Qt::Key key,
const QString &keyText = {},
int repeatCount = 1);
93 bool queryImEnabled()
const;
94 Qt::InputMethodHints queryInputMethodHints()
const;
95 Qt::EnterKeyType queryEnterKeyType()
const;
96 std::optional<
int> tryQueryCursorPosition()
const;
97 QSharedPointer<QInputMethodQueryEvent> tryQueryFocusObjectInputMethod(Qt::InputMethodQueries queries)
const;
99 QRect m_lastCursorRectangle;
100 QPoint m_lastFocusedWindowPosition;
102 ImConnectionState m_imConnectionState = ImConnectionState::Detached;
103 ImConnectionState m_imConnectionRequestedState = ImConnectionState::Detached;
104 bool m_imConnectionRequestActive =
false;
106 bool m_updateCursorRectangleAfterAttaching =
false;
107 bool m_softwareKeyboardVisible =
false;
109 std::optional<RequestKeyboardReason> m_lastInputTypeToTriggerSoftKeyboard;
112 Qt::InputMethodHints m_qtInputMethodHints;
113 Qt::EnterKeyType m_qtEnterKeyType;
115 std::shared_ptr<JsScopeData> m_jsScopeData;
116 std::shared_ptr<QOhosInputMethodProxy> m_imProxy;
118 QPointer<QObject> m_focusObject;
119 QString m_pendingPreeditText;
120 PreviewReplaceRange m_previewReplaceRange;
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 ®ion) 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.
QtOhosQpa::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)
QtOhosQpa::enums::ohos::inputMethod::Direction Direction
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.
QtOhosQpa::enums::ohos::inputMethod::EnterKeyType EnterKeyType
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.
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.
bool isWindowPcModeEnabled() const
static QOhosSettings & instance()
QOhosSurface * surfaceOrNull() const
void setWindowMask(const QOhosWindowProxy::WindowMask &windowMask)
QtOhosQpa::enums::ohos::window::WindowEventType WindowEventType
QtOhosQpa::enums::ohos::window::RectChangeReason RectChangeReason
QtOhosQpa::enums::ohos::window::AvoidAreaType AvoidAreaType
QtOhosQpa::enums::ohos::window::WindowStatusType WindowStatusType
static QWindowProxyRegistry & instance()
Combined button and popup list for selecting options.
bool shouldClearQtFocusOnSystemFocusLoss(QWindow *windowLosingSystemFocus)
bool anyQtWindowHoldsSystemFocus()
bool isWindowRotatedByTabletScreenRotation(QWindow *window, QOhosWindowProxy::RectChangeOptions rectChangeOptions)
@ TYPE_NAVIGATION_INDICATOR
static QMargins cutoutMarginsForWindow(const QList< QRect > &cutoutRects, const QRect &windowRect)