on e82caeb help sign in
unity8/plugins/LightDM/plugin.cpp
61 lines 2.1 kB history raw
1/*
2 * Copyright (C) 2012,2013 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 *
16 * Authors: Gerry Boland <gerry.boland@canonical.com>
17 * Michael Terry <michael.terry@canonical.com>
18 */
20#include "plugin.h"
21#include "Greeter.h"
22#include "UsersModel.h"
23#include <libusermetricsoutput/ColorTheme.h>
24#include <libusermetricsoutput/UserMetrics.h>
25#include <QLightDM/UsersModel>
27#include <QtCore/QAbstractItemModel>
28#include <QtQml/qqml.h>
30static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
32 Q_UNUSED(engine)
33 Q_UNUSED(scriptEngine)
34 return new Greeter();
37static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
39 Q_UNUSED(engine)
40 Q_UNUSED(scriptEngine)
41 return new UsersModel();
44static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
46 Q_UNUSED(engine)
47 Q_UNUSED(scriptEngine)
48 return UserMetricsOutput::UserMetrics::getInstance();
51void LightDMPlugin::registerTypes(const char *uri)
53 qmlRegisterType<QAbstractItemModel>();
54 qmlRegisterType<UserMetricsOutput::ColorTheme>();
56 Q_ASSERT(uri == QLatin1String("LightDM"));
57 qmlRegisterSingletonType<Greeter>(uri, 0, 1, "Greeter", greeter_provider);
58 qmlRegisterSingletonType<UsersModel>(uri, 0, 1, "Users", users_provider);
59 qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable");
60 qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider);