Debian Codegraph @

src/imports/Components/plugin/plugin.cpp

raw
1 /*
2 * Copyright 2016 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17 #include "plugin.h"
18
19 #include <QtQml/QQmlEngine>
20 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
21 #include <LomiriToolkit-Qt6/lomiritoolkitmodule.h>
22 #else
23 #include <LomiriToolkit/lomiritoolkitmodule.h>
24 #endif
25 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
26 #include <LomiriGestures-Qt6/lomirigesturesmodule.h>
27 #else
28 #include <LomiriGestures/lomirigesturesmodule.h>
29 #endif
30
31 LomiriComponentsPlugin::~LomiriComponentsPlugin()
32 {
33 UT_PREPEND_NAMESPACE(LomiriToolkitModule)::undefineModule();
34 UG_PREPEND_NAMESPACE(LomiriGesturesModule)::undefineModule();
35 }
36
37 void LomiriComponentsPlugin::registerTypes(const char *uri)
38 {
39 Q_ASSERT(uri == QLatin1String("Lomiri.Components"));
40 Q_UNUSED(uri);
41
42 UG_PREPEND_NAMESPACE(LomiriGesturesModule)::defineModule(uri);
43 UT_PREPEND_NAMESPACE(LomiriToolkitModule)::defineModule(uri);
44 }
45
46 void LomiriComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
47 {
48 /*
49 * QQmlExtensionPlugin::baseUrl() is deprecated in Qt 6.3, but we still use
50 * it to locate private .qml files.
51 * FIXME: find a way to not use baseUrl(). Preferably when we stop
52 * supporting Qt 5?
53 *
54 * See: https://github.com/qt/qtdeclarative/commit/a5404b2cb624a4d42f29da0a1c093384474d022e
55 */
56 QT_WARNING_PUSH
57 QT_WARNING_DISABLE_DEPRECATED
58
59 UT_PREPEND_NAMESPACE(LomiriToolkitModule)::initializeModule(engine, baseUrl());
60
61 QT_WARNING_POP
62
63 QQmlExtensionPlugin::initializeEngine(engine, uri);
64 }