2
* This file is part of system-settings
4
* Copyright (C) 2016 Canonical Ltd.
6
* This program is free software: you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License version 3, as published
8
* by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranties of
12
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13
* PURPOSE. See the GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License along
16
* with this program. If not, see <http://www.gnu.org/licenses/>.
24
#include "MockUpdateManager.h"
25
#include "MockUpdateModel.h"
26
#include "MockSystemImage.h"
30
static QObject *siSingletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
33
Q_UNUSED(scriptEngine)
34
return new MockSystemImage;
37
static QObject *umSingletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
40
Q_UNUSED(scriptEngine)
41
return new MockUpdateManager;
44
void BackendPlugin::registerTypes(const char *uri)
46
Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.Update"));
47
qmlRegisterSingletonType<MockUpdateManager>(uri, 1, 0, "UpdateManager", umSingletonProvider);
48
qmlRegisterUncreatableType<Update>(uri, 1, 0, "Update", "Used for enums only.");
49
qmlRegisterSingletonType<MockSystemImage>(uri, 1, 0, "SystemImage", siSingletonProvider);
50
qRegisterMetaType<MockUpdateModel*>("UpdateModel*");
51
qRegisterMetaType<MockUpdateModelFilter*>("UpdateModelFilter*");
54
void BackendPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
56
QQmlExtensionPlugin::initializeEngine(engine, uri);
57
QQmlContext* context = engine->rootContext();
58
auto utils = new SystemSettings::Utilities;
59
context->setContextProperty("Utilities", utils);
60
context->setContextProperty("showAllUI", true);
61
context->setContextProperty("pluginOptions", QVariantMap());