Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
46 {
48
49 void clear()
50 {
51 partialEndOffset = partialStartOffset = selectionEnd = selectionStart = startOffset = -1;
52 text.clear();
53 }
54
61 };
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;
75 void showInputPanel() override;
76 void hideInputPanel() override;
77 bool isInputPanelVisible() const override;
78
79 bool isComposing() const;
80 void clear();
81 void setFocusObject(QObject *object) override;
82 void sendShortcut(const QKeySequence &);
83
84 //---------------//
85 jboolean beginBatchEdit();
86 jboolean endBatchEdit();
87 jboolean commitText(const QString &text, jint newCursorPosition);
88 jboolean deleteSurroundingText(jint leftLength, jint rightLength);
89 jboolean finishComposingText();
90 jint getCursorCapsMode(jint reqModes);
91 const ExtractedText &getExtractedText(jint hintMaxChars, jint hintMaxLines, jint flags);
95 jboolean setComposingText(const QString &text, jint newCursorPosition);
96 jboolean setComposingRegion(jint start, jint end);
97 jboolean setSelection(jint start, jint end);
98 jboolean selectAll();
99 jboolean cut();
100 jboolean copy();
101 jboolean copyURL();
102 jboolean paste();
103 void reportFullscreenMode(jboolean enabled);
104 jboolean fullscreenMode();
105
106public slots:
107 void safeCall(const std::function<void()> &func, Qt::ConnectionType conType = Qt::BlockingQueuedConnection);
110 void handleLocationChanged(int handleId, int x, int y);
111 void touchDown(int x, int y);
112 void longPress(int x, int y);
113 void keyDown();
115
116private slots:
117 void showInputPanelLater(Qt::ApplicationState);
118
119private:
120 bool isImhNoTextHandlesSet();
121 void sendInputMethodEvent(QInputMethodEvent *event);
122 QSharedPointer<QInputMethodQueryEvent> focusObjectInputMethodQuery(Qt::InputMethodQueries queries = Qt::ImQueryAll);
123 bool focusObjectIsComposing() const;
124 void focusObjectStartComposing();
125 bool focusObjectStopComposing();
126
127private:
128 ExtractedText m_extractedText;
129 QString m_composingText;
130 int m_composingTextStart;
131 int m_composingCursor;
132 QMetaObject::Connection m_updateCursorPosConnection;
133 HandleModes m_handleMode;
134 int m_batchEditNestingLevel;
135 QPointer<QObject> m_focusObject;
136 QTimer m_hideCursorHandleTimer;
137 bool m_fullScreenMode;
138};
139Q_DECLARE_OPERATORS_FOR_FLAGS(QAndroidInputContext::HandleModes)
141
142#endif // ANDROIDINPUTCONTEXT_H
jboolean setSelection(jint start, jint end)
void safeCall(const std::function< void()> &func, Qt::ConnectionType conType=Qt::BlockingQueuedConnection)
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.
jboolean setComposingText(const QString &text, jint newCursorPosition)
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 commitText(const QString &text, jint newCursorPosition)
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.
The QInputMethodEvent class provides parameters for input method events.
Definition qevent.h:625
Action
Indicates the kind of action performed by the user.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
\inmodule QtCore Represents a handle to a signal-slot (or signal-functor) connection.
\inmodule QtCore
Definition qobject.h:103
The QPlatformInputContext class abstracts the input method dependent data and composing state.
\inmodule QtCore\reentrant
Definition qrect.h:484
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
void clear()
Clears the contents of the string and makes it null.
Definition qstring.h:1252
\inmodule QtCore
Definition qtimer.h:20
QString text
Combined button and popup list for selecting options.
@ ImQueryAll
ApplicationState
Definition qnamespace.h:262
ConnectionType
@ BlockingQueuedConnection
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
GLint GLint GLint GLint GLint x
[0]
GLuint GLuint end
GLenum GLuint GLenum GLsizei length
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLbitfield flags
GLuint start
GLint y
struct _cl_event * event
GLenum func
Definition qopenglext.h:663
#define Q_OBJECT
#define slots