1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #include "plugin.h" |
5 | #include <QtVirtualKeyboard/private/platforminputcontext_p.h> |
6 | #include <QLoggingCategory> |
7 | #if defined(Q_OS_WIN) |
8 | #include <qt_windows.h> |
9 | #endif |
10 | |
11 | QT_BEGIN_NAMESPACE |
12 | |
13 | using namespace QtVirtualKeyboard; |
14 | |
15 | Q_LOGGING_CATEGORY(qlcVirtualKeyboard, "qt.virtualkeyboard") |
16 | |
17 | static const char pluginName[] = "qtvirtualkeyboard"; |
18 | static const char inputMethodEnvVarName[] = "QT_IM_MODULE"; |
19 | |
20 | QStringList QVirtualKeyboardPlugin::keys() const |
21 | { |
22 | return QStringList(QLatin1String(pluginName)); |
23 | } |
24 | |
25 | QPlatformInputContext *QVirtualKeyboardPlugin::create(const QString &system, const QStringList ¶mList) |
26 | { |
27 | Q_UNUSED(paramList); |
28 | |
29 | if (!qEnvironmentVariableIsSet(varName: inputMethodEnvVarName) || qgetenv(varName: inputMethodEnvVarName) != pluginName) |
30 | return nullptr; |
31 | |
32 | if (system.compare(s1: system, s2: QLatin1String(pluginName), cs: Qt::CaseInsensitive) != 0) |
33 | return nullptr; |
34 | |
35 | #if defined(Q_OS_WIN) |
36 | // QTBUG-93042 |
37 | ImmDisableIME(0); |
38 | #endif |
39 | |
40 | PlatformInputContext *platformInputContext = new PlatformInputContext(); |
41 | |
42 | return platformInputContext; |
43 | } |
44 | |
45 | QT_END_NAMESPACE |
46 |