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
qandroidinputcontext.h
Go to the documentation of this file.
1// Copyright (C) 2012 BogDan Vatra <bogdan@kde.org>
2// Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef ANDROIDINPUTCONTEXT_H
6#define ANDROIDINPUTCONTEXT_H
7
8#include <qpa/qplatforminputcontext.h>
9#include <functional>
10#include <jni.h>
11#include <qevent.h>
12
13#include <QtCore/qpointer.h>
14#include <QTimer>
15
17
19{
21 enum CapsMode
22 {
23 CAP_MODE_CHARACTERS = 0x00001000,
24 CAP_MODE_SENTENCES = 0x00004000,
25 CAP_MODE_WORDS = 0x00002000
26 };
27
28public:
36
43 Q_DECLARE_FLAGS(HandleModes, HandleMode)
44
62
63public:
67 bool isValid() const override { return true; }
68
69 void reset() override;
70 void commit() override;
71 void update(Qt::InputMethodQueries queries) override;
72 void invokeAction(QInputMethod::Action action, int cursorPosition) override;
73 QRectF keyboardRect() const override;
74 bool isAnimating() const override;
77 bool isInputPanelVisible() const override;
78
79 bool isComposing() const;
80 void clear();
81 void setFocusObject(QObject *object) override;
83 void sendShortcut(const QKeySequence &);
84
85 //---------------//
88 jboolean commitText(const QString &text, jint newCursorPosition);
89 jboolean deleteSurroundingText(jint leftLength, jint rightLength);
91 jint getCursorCapsMode(jint reqModes);
92 const ExtractedText &getExtractedText(jint hintMaxChars, jint hintMaxLines, jint flags);
93 QString getSelectedText(jint flags);
94 QString getTextAfterCursor(jint length, jint flags);
95 QString getTextBeforeCursor(jint length, jint flags);
96 jboolean replaceText(jint start, jint end, const QString text, jint newCursorPosition);
97 jboolean setComposingText(const QString &text, jint newCursorPosition);
98 jboolean setComposingRegion(jint start, jint end);
99 jboolean setSelection(jint start, jint end);
101 jboolean cut();
102 jboolean copy();
104 jboolean paste();
105 void reportFullscreenMode(jboolean enabled);
107
108public slots:
112 void handleLocationChanged(int handleId, int x, int y);
113 void touchDown(int x, int y);
114 void longPress(int x, int y);
115 void keyDown();
117
118private slots:
120
121private:
122 bool isImhNoTextHandlesSet();
123 void sendInputMethodEvent(QInputMethodEvent *event);
124 QSharedPointer<QInputMethodQueryEvent> focusObjectInputMethodQuery(Qt::InputMethodQueries queries = Qt::ImQueryAll);
125 bool focusObjectIsComposing() const;
126 void focusObjectStartComposing();
127 bool focusObjectStopComposing();
128
129private:
130 ExtractedText m_extractedText;
131 QString m_composingText;
132 int m_composingTextStart;
133 int m_composingCursor;
134 QMetaObject::Connection m_updateCursorPosConnection;
135 HandleModes m_handleMode;
136 int m_batchEditNestingLevel;
137 QPointer<QObject> m_focusObject;
138 QTimer m_hideCursorHandleTimer;
139 bool m_fullScreenMode;
140};
141Q_DECLARE_OPERATORS_FOR_FLAGS(QAndroidInputContext::HandleModes)
142QT_END_NAMESPACE
143
144#endif // ANDROIDINPUTCONTEXT_H
jboolean setSelection(jint start, jint end)
bool isValid() const override
Returns input context validity.
jint getCursorCapsMode(jint reqModes)
QString getSelectedText(jint flags)
bool isAnimating() const override
This function can be reimplemented to return true whenever input method is animating shown or hidden.
QString getTextAfterCursor(jint length, jint flags)
void reportFullscreenMode(jboolean enabled)
QRectF keyboardRect() const override
This function can be reimplemented to return virtual keyboard rectangle in currently active window co...
void reset() override
Method to be called when input method needs to be reset.
void hideInputPanel() override
Request to hide input panel.
void setFocusObject(QObject *object) override
This virtual method gets called to notify updated focus to object.
jboolean setComposingRegion(jint start, jint end)
static QAndroidInputContext * androidInputContext()
void update(Qt::InputMethodQueries queries) override
Notification on editor updates.
QString getTextBeforeCursor(jint length, jint flags)
void sendShortcut(const QKeySequence &)
void invokeAction(QInputMethod::Action action, int cursorPosition) override
Called when the word currently being composed in the input item is tapped by the user.
jboolean deleteSurroundingText(jint leftLength, jint rightLength)
void handleLocationChanged(int handleId, int x, int y)
void showInputPanel() override
Request to show input panel.
const ExtractedText & getExtractedText(jint hintMaxChars, jint hintMaxLines, jint flags)
bool isInputPanelVisible() const override
Returns input panel visibility status.
QPlatformFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
void initialize() override
Performs initialization steps that depend on having an event dispatcher available.
QPlatformInputContext * inputContext() const override
Returns the platforms input context.
QStringList themeNames() const override
QPlatformNativeInterface * nativeInterface() const override
void setScreenSize(int width, int height)
void setPhysicalSize(int width, int height)
bool hasCapability(QPlatformIntegration::Capability cap) const override
void setTouchDevice(QPointingDevice *touchDevice)
QPlatformClipboard * clipboard() const override
Accessor for the platform integration's clipboard.
static void updateColorScheme(Qt::ColorScheme colorScheme)
Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override
QAndroidPlatformIntegration(const QStringList &paramList)
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
QVariant styleHint(StyleHint hint) const override
static void setScreenOrientation(Qt::ScreenOrientation currentOrientation, Qt::ScreenOrientation nativeOrientation)
QPlatformServices * services() const override
void customEvent(QEvent *event) override
This event handler can be reimplemented in a subclass to receive custom events.
void * nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override
void * nativeResourceForIntegration(const QByteArray &resource) override
std::shared_ptr< AndroidStyle > m_androidStyle