on e90dbab help sign in
unity8/plugins/LightDM/plugin.cpp
60 lines 2.0 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 <QLightDM/UsersModel>
24#include "InfographicModel.h"
26#include <QtCore/QAbstractItemModel>
27#include <QtQml>
29static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
31 Q_UNUSED(engine)
32 Q_UNUSED(scriptEngine)
33 return new Greeter();
36static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
38 Q_UNUSED(engine)
39 Q_UNUSED(scriptEngine)
40 return new UsersModel();
43static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
45 Q_UNUSED(engine)
46 Q_UNUSED(scriptEngine)
47 return InfographicModel::getInstance();
50void LightDMPlugin::registerTypes(const char *uri)
52 qmlRegisterType<QAbstractItemModel>();
53 qmlRegisterType<InfographicColorTheme>();
55 Q_ASSERT(uri == QLatin1String("LightDM"));
56 qmlRegisterSingletonType<Greeter>(uri, 0, 1, "Greeter", greeter_provider);
57 qmlRegisterSingletonType<UsersModel>(uri, 0, 1, "Users", users_provider);
58 qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable");
59 qmlRegisterSingletonType<InfographicModel>(uri, 0, 1, "Infographic", infographic_provider);