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 reset() override;
71 void commit() override;
72 void update(Qt::InputMethodQueries queries) override;
73 void invokeAction(QInputMethod::Action action, int cursorPosition) override;
74 QRectF keyboardRect() const override;
75 bool isAnimating() const override;
78 bool isInputPanelVisible() const override;
79
80 bool isComposing() const;
81 void clear();
82 void setFocusObject(QObject *object) override;
84 void sendShortcut(const QKeySequence &);
85
86 //---------------//
89 jboolean commitText(const QString &text, jint newCursorPosition);
90 jboolean deleteSurroundingText(jint leftLength, jint rightLength);
92 jint getCursorCapsMode(jint reqModes);
93 const ExtractedText &getExtractedText(jint hintMaxChars, jint hintMaxLines, jint flags);
94 QString getSelectedText(jint flags);
95 QString getTextAfterCursor(jint length, jint flags);
96 QString getTextBeforeCursor(jint length, jint flags);
97 jboolean replaceText(jint start, jint end, const QString text, jint newCursorPosition);
98 jboolean setComposingText(const QString &text, jint newCursorPosition);
99 jboolean setComposingRegion(jint start, jint end);
100 jboolean setSelection(jint start, jint end);
102 jboolean cut();
103 jboolean copy();
105 jboolean paste();
106 void reportFullscreenMode(jboolean enabled);
108
109public slots:
113 void handleLocationChanged(int handleId, int x, int y);
114 void touchDown(int x, int y);
115 void longPress(int x, int y);
116 void keyDown();
118
119private slots:
121
122private:
123 bool isImhNoTextHandlesSet();
124 void sendInputMethodEvent(QInputMethodEvent *event);
125 QSharedPointer<QInputMethodQueryEvent> focusObjectInputMethodQuery(Qt::InputMethodQueries queries = Qt::ImQueryAll);
126 bool focusObjectIsComposing() const;
127 void focusObjectStartComposing();
128 bool focusObjectStopComposing();
129
130private:
131 ExtractedText m_extractedText;
132 QString m_composingText;
133 int m_composingTextStart;
134 int m_composingCursor;
135 QMetaObject::Connection m_updateCursorPosConnection;
136 HandleModes m_handleMode;
137 int m_batchEditNestingLevel;
138 QPointer<QObject> m_focusObject;
139 QTimer m_hideCursorHandleTimer;
140 bool m_fullScreenMode;
141};
142Q_DECLARE_OPERATORS_FOR_FLAGS(QAndroidInputContext::HandleModes)
143QT_END_NAMESPACE
144
145#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
Combined button and popup list for selecting options.