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// Qt-Security score:significant reason:default
5
6#ifndef ANDROIDINPUTCONTEXT_H
7#define ANDROIDINPUTCONTEXT_H
8
9#include <qpa/qplatforminputcontext.h>
10#include <functional>
11#include <jni.h>
12#include <qevent.h>
13
14#include <QtCore/qpointer.h>
15#include <QTimer>
16
18
20{
22 enum CapsMode
23 {
24 CAP_MODE_CHARACTERS = 0x00001000,
25 CAP_MODE_SENTENCES = 0x00004000,
26 CAP_MODE_WORDS = 0x00002000
27 };
28
29public:
37
44 Q_DECLARE_FLAGS(HandleModes, HandleMode)
45
63
64public:
68 bool isValid() const override { return true; }
69
70 void setAccessibilityFocusInProgress(bool inProgress) { m_accessibilityFocusInProgress = inProgress; }
71
72 void reset() override;
73 void commit() override;
74 void update(Qt::InputMethodQueries queries) override;
75 void invokeAction(QInputMethod::Action action, int cursorPosition) override;
76 QRectF keyboardRect() const override;
77 bool isAnimating() const override;
80 bool isInputPanelVisible() const override;
81
82 bool isComposing() const;
83 void clear();
84 void setFocusObject(QObject *object) override;
86 void sendShortcut(const QKeySequence &);
87
88 //---------------//
91 jboolean commitText(const QString &text, jint newCursorPosition);
92 jboolean deleteSurroundingText(jint leftLength, jint rightLength);
94 jint getCursorCapsMode(jint reqModes);
95 const ExtractedText &getExtractedText(jint hintMaxChars, jint hintMaxLines, jint flags);
96 QString getSelectedText(jint flags);
97 QString getTextAfterCursor(jint length, jint flags);
98 QString getTextBeforeCursor(jint length, jint flags);
99 jboolean replaceText(jint start, jint end, const QString text, jint newCursorPosition);
100 jboolean setComposingText(const QString &text, jint newCursorPosition);
101 jboolean setComposingRegion(jint start, jint end);
102 jboolean setSelection(jint start, jint end);
104 jboolean cut();
105 jboolean copy();
107 jboolean paste();
108 void reportFullscreenMode(jboolean enabled);
110
111public slots:
115 void handleLocationChanged(int handleId, int x, int y);
116 void touchDown(int x, int y);
117 void longPress(int x, int y);
118 void keyDown();
120
121private slots:
123
124private:
125 bool isImhNoEditMenuSet();
126 bool isImhNoTextHandlesSet();
127 void sendInputMethodEvent(QInputMethodEvent *event);
128 QSharedPointer<QInputMethodQueryEvent> focusObjectInputMethodQuery(Qt::InputMethodQueries queries = Qt::ImQueryAll);
129 bool focusObjectIsComposing() const;
130 void focusObjectStartComposing();
131 bool focusObjectStopComposing();
132
133private:
134 ExtractedText m_extractedText;
135 QString m_composingText;
136 int m_composingTextStart;
137 int m_composingCursor;
138 QMetaObject::Connection m_updateCursorPosConnection;
139 HandleModes m_handleMode;
140 int m_batchEditNestingLevel;
141 QPointer<QObject> m_focusObject;
142 QTimer m_hideCursorHandleTimer;
143 bool m_fullScreenMode;
144 bool m_accessibilityFocusInProgress = false;
145};
146Q_DECLARE_OPERATORS_FOR_FLAGS(QAndroidInputContext::HandleModes)
147QT_END_NAMESPACE
148
149#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.
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.
void setAccessibilityFocusInProgress(bool inProgress)
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
Combined button and popup list for selecting options.