4#ifndef QOHOSINPUTCONTEXT_H
5#define QOHOSINPUTCONTEXT_H
7#include <qohosinputmethodproxy.h>
8#include <qohosplugincore.h>
9#include <qpa/qplatforminputcontext.h>
10#include <qpa/qwindowsysteminterface.h>
11#include <QtCore/private/qohoscommon_p.h>
12#include <QtCore/qglobal.h>
16class QOhosNativeXComponent;
68 void update(Qt::InputMethodQueries queries)
override;
69 void invokeAction(QInputMethod::Action action,
int cursorPosition)
override;
81 bool eventFilter(QObject *obj, QEvent *event)
override;
83 enum class ImConnectionState {
90 std::shared_ptr<
void> imControllerCallbacksHandle;
93 void setImConnectionState(ImConnectionState requestedState);
94 void setImConnectionStateImpl(ImConnectionState requestedState);
95 void dispatchRequestedImStateChange(ImConnectionState requestedState);
97 void updateInputMethodControllerAttributes(
98 Qt::InputMethodHints qtInputMethodHints, Qt::EnterKeyType qtEnterKeyType);
99 void updateOhosCursor(
const QRect &globalCursorRect);
100 bool attachToInputMethodController();
101 bool detachFromInputMethodController();
102 void handleRequestedImConnectionState(ImConnectionState requestedState,
bool success);
104 void onCursorRectangleChanged();
105 void handleFocusInEvent(QObject *obj, QFocusEvent *event);
107 void sendInsertedTextToQt(
const std::string &textToInsert);
108 void sendInsertedPreviewTextToQt(
std::string previewText);
109 void sendFocusObjectInputMethodEvent(QInputMethodEvent *event);
111 void sendFocusObjectFunctionalKeyEvent(Qt::Key key,
const QChar &keyChar,
int repeatCount = 1);
113 bool queryImEnabled()
const;
114 Qt::InputMethodHints queryInputMethodHints()
const;
115 Qt::EnterKeyType queryEnterKeyType()
const;
117 QSharedPointer<QInputMethodQueryEvent> tryQueryFocusObjectInputMethod(Qt::InputMethodQueries queries)
const;
119 QRect m_lastCursorRectangle;
120 QPoint m_lastFocusedWindowPosition;
122 ImConnectionState m_imConnectionState = ImConnectionState::Detached;
123 ImConnectionState m_imConnectionRequestedState = ImConnectionState::Detached;
124 bool m_imConnectionRequestActive =
false;
126 bool m_updateCursorRectangleAfterAttaching =
false;
127 bool m_softwareKeyboardVisible =
false;
129 QOhosOptional<RequestKeyboardReason> m_lastInputTypeToTriggerSoftKeyboard;
132 Qt::InputMethodHints m_qtInputMethodHints;
133 Qt::EnterKeyType m_qtEnterKeyType;
135 std::shared_ptr<JsScopeData> m_jsScopeData;
136 std::shared_ptr<QOhosInputMethodProxy> m_imProxy;
138 QPointer<QObject> m_focusObject;
139 QString m_pendingPreeditText;
147 static constexpr const char *
fullTypeName =
"@ohos.inputMethod.RequestKeyboardReason";
159 static constexpr const char *
fullTypeName =
"@ohos.inputMethod.TextInputType";
177 static constexpr const char *
fullTypeName =
"@ohos.inputMethod.EnterKeyType";
194 static constexpr const char *
fullTypeName =
"@ohos.inputMethod.Direction";
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
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.
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.
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.
std::enable_if_t< qohosplugincore_h_detail::isQOhosOptional< QOhosInvokeResult< Func, T > >, QOhosInvokeResult< Func, T > > andThen(Func &&func) const
QOhosSurface * surfaceOrNull() const
void setWindowMask(const QOhosWindowProxy::WindowMask &windowMask)
ViewGeometry viewGeometry() const
bool isSubWindowCoveringFullScreen() const
@ TYPE_NAVIGATION_INDICATOR
static QWindowProxyRegistry & instance()
bool isWindowPcModeEnabled()
Combined button and popup list for selecting options.
bool isWindowRotatedByTabletScreenRotation(QWindow *window, QOhosWindowProxy::RectChangeOptions rectChangeOptions)
QOhosRuntimeDeviceTypeAndMode
@ HandheldDeviceWindowPcMode
QOhosRuntimeDeviceTypeAndMode queryQOhosRuntimeDeviceAndMode()