1/****************************************************************************
2**
3** Copyright (C) 2018 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#include "qtquickvirtualkeyboardplugin.h"
31
32#include <QtVirtualKeyboard/qvirtualkeyboardinputcontext.h>
33#include <QtVirtualKeyboard/qvirtualkeyboardinputengine.h>
34#include <QtVirtualKeyboard/private/qvirtualkeyboardinputcontext_p.h>
35#include <QtVirtualKeyboard/private/shifthandler_p.h>
36#include <QtVirtualKeyboard/private/inputmethod_p.h>
37#include <QtVirtualKeyboard/qvirtualkeyboardselectionlistmodel.h>
38#include <QtVirtualKeyboard/private/enterkeyaction_p.h>
39#include <QtVirtualKeyboard/private/enterkeyactionattachedtype_p.h>
40#include <QtVirtualKeyboard/qvirtualkeyboardtrace.h>
41#include <QtVirtualKeyboard/private/shadowinputcontext_p.h>
42#include <QtVirtualKeyboard/private/qvirtualkeyboard_staticplugin_p.h>
43
44QT_BEGIN_NAMESPACE
45
46using namespace QtVirtualKeyboard;
47
48static QObject *createInputContextModule(QQmlEngine *engine, QJSEngine *scriptEngine)
49{
50 Q_UNUSED(engine)
51 Q_UNUSED(scriptEngine)
52 return new QVirtualKeyboardInputContext();
53}
54
55void QtQuickVirtualKeyboardPlugin::registerTypes(const char *uri)
56{
57#if defined(QT_STATICPLUGIN)
58 Q_VKB_IMPORT_PLUGIN(QtQuick2Plugin)
59 Q_VKB_IMPORT_PLUGIN(QtQuick2WindowPlugin)
60 Q_VKB_IMPORT_PLUGIN(QtQuickLayoutsPlugin)
61 Q_VKB_IMPORT_PLUGIN(QmlFolderListModelPlugin)
62 Q_VKB_IMPORT_PLUGIN(QtQuickVirtualKeyboardSettingsPlugin)
63 Q_VKB_IMPORT_PLUGIN(QtQuickVirtualKeyboardStylesPlugin)
64#endif
65
66 qmlRegisterSingletonType<QVirtualKeyboardInputContext>(uri, versionMajor: 1, versionMinor: 0, typeName: "InputContext", callback: createInputContextModule);
67 qmlRegisterSingletonType<QVirtualKeyboardInputContext>(uri, versionMajor: 2, versionMinor: 0, typeName: "InputContext", callback: createInputContextModule);
68 qmlRegisterUncreatableType<QVirtualKeyboardInputContextPrivate>(uri, versionMajor: 1, versionMinor: 0, qmlName: "InputContextPrivate", reason: QLatin1String("Cannot create input context private"));
69 qmlRegisterUncreatableType<QVirtualKeyboardInputEngine>(uri, versionMajor: 1, versionMinor: 0, qmlName: "InputEngine", reason: QLatin1String("Cannot create input method engine"));
70 qmlRegisterUncreatableType<QVirtualKeyboardInputEngine>(uri, versionMajor: 2, versionMinor: 0, qmlName: "InputEngine", reason: QLatin1String("Cannot create input method engine"));
71 qRegisterMetaType<ShiftHandler *>(typeName: "ShiftHandler*");
72 qmlRegisterUncreatableType<ShiftHandler>(uri, versionMajor: 1, versionMinor: 0, qmlName: "ShiftHandler", reason: QLatin1String("Cannot create shift handler"));
73 qmlRegisterUncreatableType<ShiftHandler>(uri, versionMajor: 2, versionMinor: 0, qmlName: "ShiftHandler", reason: QLatin1String("Cannot create shift handler"));
74 qmlRegisterUncreatableType<QVirtualKeyboardSelectionListModel>(uri, versionMajor: 1, versionMinor: 0, qmlName: "SelectionListModel", reason: QLatin1String("Cannot create selection list model"));
75 qmlRegisterUncreatableType<QVirtualKeyboardSelectionListModel>(uri, versionMajor: 2, versionMinor: 0, qmlName: "SelectionListModel", reason: QLatin1String("Cannot create selection list model"));
76 qmlRegisterUncreatableType<QVirtualKeyboardAbstractInputMethod>(uri, versionMajor: 1, versionMinor: 0, qmlName: "AbstractInputMethod", reason: QLatin1String("Cannot create abstract input method"));
77 qmlRegisterUncreatableType<QVirtualKeyboardAbstractInputMethod>(uri, versionMajor: 2, versionMinor: 0, qmlName: "AbstractInputMethod", reason: QLatin1String("Cannot create abstract input method"));
78 qmlRegisterType<InputMethod>(uri, versionMajor: 1, versionMinor: 0, qmlName: "InputMethod");
79 qmlRegisterType<InputMethod>(uri, versionMajor: 2, versionMinor: 0, qmlName: "InputMethod");
80 qmlRegisterAnonymousType<EnterKeyActionAttachedType>(uri, versionMajor: 1);
81 qmlRegisterAnonymousType<EnterKeyActionAttachedType>(uri, versionMajor: 2);
82 qmlRegisterType<EnterKeyAction>(uri, versionMajor: 1, versionMinor: 0, qmlName: "EnterKeyAction");
83 qmlRegisterType<EnterKeyAction>(uri, versionMajor: 2, versionMinor: 0, qmlName: "EnterKeyAction");
84 qmlRegisterType<QVirtualKeyboardTrace>(uri, versionMajor: 2, versionMinor: 0, qmlName: "Trace");
85 qmlRegisterType<QVirtualKeyboardTrace>(uri, versionMajor: 2, versionMinor: 4, qmlName: "Trace");
86 qRegisterMetaType<ShadowInputContext *>(typeName: "ShadowInputContext*");
87 qmlRegisterUncreatableType<ShadowInputContext>(uri, versionMajor: 2, versionMinor: 2, qmlName: "ShadowInputContext", reason: QLatin1String("Cannot create shadow input context"));
88
89 const QString path(QStringLiteral("qrc:///QtQuick/VirtualKeyboard/content/"));
90 qmlRegisterType(url: QUrl(path + QLatin1String("InputPanel.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "InputPanel");
91 qmlRegisterType(url: QUrl(path + QLatin1String("InputPanel.qml")), uri, versionMajor: 1, versionMinor: 2, qmlName: "InputPanel");
92 qmlRegisterType(url: QUrl(path + QLatin1String("InputPanel.qml")), uri, versionMajor: 1, versionMinor: 3, qmlName: "InputPanel");
93 qmlRegisterType(url: QUrl(path + QLatin1String("InputPanel.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "InputPanel");
94 qmlRegisterType(url: QUrl(path + QLatin1String("InputPanel.qml")), uri, versionMajor: 2, versionMinor: 1, qmlName: "InputPanel");
95 qmlRegisterType(url: QUrl(path + QLatin1String("InputPanel.qml")), uri, versionMajor: 2, versionMinor: 2, qmlName: "InputPanel");
96 qmlRegisterType(url: QUrl(path + QLatin1String("InputPanel.qml")), uri, versionMajor: 2, versionMinor: 3, qmlName: "InputPanel");
97 qmlRegisterType(url: QUrl(path + QLatin1String("InputPanel.qml")), uri, versionMajor: 2, versionMinor: 4, qmlName: "InputPanel");
98 qmlRegisterType(url: QUrl(path + QLatin1String("HandwritingInputPanel.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "HandwritingInputPanel");
99 const QString componentsPath = path + QStringLiteral("components/");
100 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("AlternativeKeys.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "AlternativeKeys");
101 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("AlternativeKeys.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "AlternativeKeys");
102 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("BackspaceKey.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "BackspaceKey");
103 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("BackspaceKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "BackspaceKey");
104 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("BaseKey.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "BaseKey");
105 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("BaseKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "BaseKey");
106 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("ChangeLanguageKey.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "ChangeLanguageKey");
107 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("ChangeLanguageKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "ChangeLanguageKey");
108 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("CharacterPreviewBubble.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "CharacterPreviewBubble");
109 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("CharacterPreviewBubble.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "CharacterPreviewBubble");
110 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("EnterKey.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "EnterKey");
111 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("EnterKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "EnterKey");
112 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("FillerKey.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "FillerKey");
113 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("FillerKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "FillerKey");
114 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("HideKeyboardKey.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "HideKeyboardKey");
115 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("HideKeyboardKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "HideKeyboardKey");
116 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("KeyboardColumn.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "KeyboardColumn");
117 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("KeyboardColumn.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "KeyboardColumn");
118 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("KeyboardLayout.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "KeyboardLayout");
119 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("KeyboardLayout.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "KeyboardLayout");
120 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("KeyboardLayoutLoader.qml")), uri, versionMajor: 1, versionMinor: 1, qmlName: "KeyboardLayoutLoader");
121 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("KeyboardLayoutLoader.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "KeyboardLayoutLoader");
122 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("Keyboard.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "Keyboard");
123 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("Keyboard.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "Keyboard");
124 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("KeyboardRow.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "KeyboardRow");
125 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("KeyboardRow.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "KeyboardRow");
126 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("Key.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "Key");
127 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("Key.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "Key");
128 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("ModeKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "ModeKey");
129 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("MultiSoundEffect.qml")), uri, versionMajor: 1, versionMinor: 1, qmlName: "MultiSoundEffect");
130 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("MultiSoundEffect.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "MultiSoundEffect");
131 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("MultitapInputMethod.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "MultitapInputMethod");
132 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("MultitapInputMethod.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "MultitapInputMethod");
133 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("NumberKey.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "NumberKey");
134 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("NumberKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "NumberKey");
135 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("ShiftKey.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "ShiftKey");
136 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("ShiftKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "ShiftKey");
137 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("SpaceKey.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "SpaceKey");
138 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("SpaceKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "SpaceKey");
139 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("SymbolModeKey.qml")), uri, versionMajor: 1, versionMinor: 0, qmlName: "SymbolModeKey");
140 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("SymbolModeKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "SymbolModeKey");
141 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("HandwritingModeKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "HandwritingModeKey");
142 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("TraceInputArea.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "TraceInputArea");
143 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("TraceInputKey.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "TraceInputKey");
144 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("WordCandidatePopupList.qml")), uri, versionMajor: 2, versionMinor: 0, qmlName: "WordCandidatePopupList");
145 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("PopupList.qml")), uri, versionMajor: 2, versionMinor: 3, qmlName: "PopupList");
146 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("SelectionControl.qml")), uri, versionMajor: 2, versionMinor: 1, qmlName: "SelectionControl");
147 qmlRegisterType(url: QUrl(componentsPath + QLatin1String("InputModeKey.qml")), uri, versionMajor: 2, versionMinor: 3, qmlName: "InputModeKey");
148
149 // Auto-increment the import to stay in sync with ALL future QtQuick minor versions
150 qmlRegisterModule(uri, versionMajor: 2, QT_VERSION_MINOR);
151}
152
153QT_END_NAMESPACE
154

source code of qtvirtualkeyboard/src/import/qtquickvirtualkeyboardplugin.cpp