on daa5708 help sign in
68 lines 2.3 kB history raw
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "plugin.h"
18#include <DBusGreeter.h>
19#include <DBusGreeterList.h>
20#include "MockGreeter.h"
21#include "MockUsersModel.h"
22#include <libusermetricsoutput/ColorTheme.h>
23#include <libusermetricsoutput/UserMetrics.h>
24#include <QLightDM/UsersModel>
26#include <QAbstractItemModel>
27#include <QDBusConnection>
28#include <QtQml/qqml.h>
30static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
32 Q_UNUSED(engine)
33 Q_UNUSED(scriptEngine)
35 MockGreeter *greeter = new MockGreeter;
36 new DBusGreeter(greeter, "/");
37 new DBusGreeterList(greeter, "/list");
39 return greeter;
42static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
44 Q_UNUSED(engine)
45 Q_UNUSED(scriptEngine)
46 return new MockUsersModel;
49static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
51 Q_UNUSED(engine)
52 Q_UNUSED(scriptEngine)
53 return UserMetricsOutput::UserMetrics::getInstance();
56void LightDMPlugin::registerTypes(const char *uri)
58 qmlRegisterType<QAbstractItemModel>();
59 qmlRegisterType<UserMetricsOutput::ColorTheme>();
61 Q_ASSERT(uri == QLatin1String("LightDM"));
62 qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType");
63 qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType");
64 qmlRegisterSingletonType<MockGreeter>(uri, 0, 1, "Greeter", greeter_provider);
65 qmlRegisterSingletonType<MockUsersModel>(uri, 0, 1, "Users", users_provider);
66 qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable");
67 qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider);