Warning: That file was not part of the compilation database. It may have many parsing errors.

1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30#ifndef QVIRTUALKEYBOARDINPUTENGINE_H
31#define QVIRTUALKEYBOARDINPUTENGINE_H
32
33#include <QObject>
34#include <QPointer>
35#include <QtVirtualKeyboard/qvirtualkeyboard_global.h>
36
37QT_BEGIN_NAMESPACE
38
39class QVirtualKeyboardInputContext;
40class QVirtualKeyboardSelectionListModel;
41class QVirtualKeyboardAbstractInputMethod;
42class QVirtualKeyboardInputEnginePrivate;
43class QVirtualKeyboardTrace;
44
45class QVIRTUALKEYBOARD_EXPORT QVirtualKeyboardInputEngine : public QObject
46{
47 Q_OBJECT
48 Q_DISABLE_COPY(QVirtualKeyboardInputEngine)
49 Q_DECLARE_PRIVATE(QVirtualKeyboardInputEngine)
50 Q_PROPERTY(Qt::Key activeKey READ activeKey NOTIFY activeKeyChanged)
51 Q_PROPERTY(Qt::Key previousKey READ previousKey NOTIFY previousKeyChanged)
52 Q_PROPERTY(QVirtualKeyboardAbstractInputMethod *inputMethod READ inputMethod WRITE setInputMethod NOTIFY inputMethodChanged)
53 Q_PROPERTY(QList<int> inputModes READ inputModes NOTIFY inputModesChanged)
54 Q_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode NOTIFY inputModeChanged)
55 Q_PROPERTY(QList<int> patternRecognitionModes READ patternRecognitionModes NOTIFY patternRecognitionModesChanged)
56 Q_PROPERTY(QVirtualKeyboardSelectionListModel *wordCandidateListModel READ wordCandidateListModel NOTIFY wordCandidateListModelChanged)
57 Q_PROPERTY(bool wordCandidateListVisibleHint READ wordCandidateListVisibleHint NOTIFY wordCandidateListVisibleHintChanged)
58
59 explicit QVirtualKeyboardInputEngine(QVirtualKeyboardInputContext *parent = nullptr);
60 void init();
61
62public:
63 enum class TextCase {
64 Lower,
65 Upper
66 };
67 Q_ENUM(TextCase)
68
69 enum class InputMode {
70 Latin,
71 Numeric,
72 Dialable,
73 Pinyin,
74 Cangjie,
75 Zhuyin,
76 Hangul,
77 Hiragana,
78 Katakana,
79 FullwidthLatin,
80 Greek,
81 Cyrillic,
82 Arabic,
83 Hebrew,
84 ChineseHandwriting,
85 JapaneseHandwriting,
86 KoreanHandwriting,
87 Thai
88 };
89 Q_ENUM(InputMode)
90
91 enum class PatternRecognitionMode {
92 None,
93 PatternRecognitionDisabled = None,
94 Handwriting,
95 HandwritingRecoginition = Handwriting
96 };
97 Q_ENUM(PatternRecognitionMode)
98
99 enum class ReselectFlag {
100 WordBeforeCursor = 0x1,
101 WordAfterCursor = 0x2,
102 WordAtCursor = WordBeforeCursor | WordAfterCursor
103 };
104 Q_FLAG(ReselectFlag)
105 Q_DECLARE_FLAGS(ReselectFlags, ReselectFlag)
106
107public:
108 ~QVirtualKeyboardInputEngine();
109
110 Q_INVOKABLE bool virtualKeyPress(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers, bool repeat);
111 Q_INVOKABLE void virtualKeyCancel();
112 Q_INVOKABLE bool virtualKeyRelease(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers);
113 Q_INVOKABLE bool virtualKeyClick(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers);
114
115 QVirtualKeyboardInputContext *inputContext() const;
116 Qt::Key activeKey() const;
117 Qt::Key previousKey() const;
118
119 QVirtualKeyboardAbstractInputMethod *inputMethod() const;
120 void setInputMethod(QVirtualKeyboardAbstractInputMethod *inputMethod);
121
122 QList<int> inputModes() const;
123
124 InputMode inputMode() const;
125 void setInputMode(InputMode inputMode);
126
127 QVirtualKeyboardSelectionListModel *wordCandidateListModel() const;
128 bool wordCandidateListVisibleHint() const;
129
130 QList<int> patternRecognitionModes() const;
131 Q_INVOKABLE QVirtualKeyboardTrace *traceBegin(
132 int traceId, PatternRecognitionMode patternRecognitionMode,
133 const QVariantMap &traceCaptureDeviceInfo, const QVariantMap &traceScreenInfo);
134 Q_INVOKABLE bool traceEnd(QVirtualKeyboardTrace *trace);
135
136 Q_INVOKABLE bool reselect(int cursorPosition, const ReselectFlags &reselectFlags);
137 bool clickPreeditText(int cursorPosition);
138
139Q_SIGNALS:
140 void virtualKeyClicked(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers, bool isAutoRepeat);
141 void activeKeyChanged(Qt::Key key);
142 void previousKeyChanged(Qt::Key key);
143 void inputMethodChanged();
144 void inputMethodReset();
145 void inputMethodUpdate();
146 void inputModesChanged();
147 void inputModeChanged();
148 void patternRecognitionModesChanged();
149 void wordCandidateListModelChanged();
150 void wordCandidateListVisibleHintChanged();
151
152private Q_SLOTS:
153 void reset();
154 void update();
155 void shiftChanged();
156 void updateSelectionListModels();
157 void updateInputModes();
158
159protected:
160 void timerEvent(QTimerEvent *timerEvent) override;
161
162private:
163 friend class QVirtualKeyboardInputContext;
164 friend class QVirtualKeyboardInputContextPrivate;
165};
166
167Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qHash(QVirtualKeyboardInputEngine::InputMode key, uint seed = 0) Q_DECL_NOTHROW { return uint(key) ^ seed; }
168Q_DECLARE_OPERATORS_FOR_FLAGS(QVirtualKeyboardInputEngine::ReselectFlags)
169
170QT_END_NAMESPACE
171
172Q_DECLARE_METATYPE(QVirtualKeyboardInputEngine::TextCase)
173Q_DECLARE_METATYPE(QVirtualKeyboardInputEngine::InputMode)
174Q_DECLARE_METATYPE(QVirtualKeyboardInputEngine::PatternRecognitionMode)
175Q_DECLARE_METATYPE(QVirtualKeyboardInputEngine::ReselectFlag)
176
177#endif
178

Warning: That file was not part of the compilation database. It may have many parsing errors.

source code of qtvirtualkeyboard/src/virtualkeyboard/qvirtualkeyboardinputengine.h