~unity-team/unity8/ota9.5

« back to all changes in this revision

Viewing changes to plugins/LightDM/plugin.cpp

  • Committer: Michał Sawicz
  • Date: 2013-06-05 22:03:08 UTC
  • Revision ID: michal.sawicz@canonical.com-20130605220308-yny8fv3futtr04fg
Inital unity8 commit.

Previous history can be found at https://code.launchpad.net/~unity-team/unity/phablet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
19
 
 
20
#include "plugin.h"
 
21
#include "Greeter.h"
 
22
#include "UsersModel.h"
 
23
#include <QLightDM/UsersModel>
 
24
#include "InfographicModel.h"
 
25
 
 
26
#include <QtCore/QAbstractItemModel>
 
27
#include <QtQml>
 
28
 
 
29
static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
 
30
{
 
31
    Q_UNUSED(engine)
 
32
    Q_UNUSED(scriptEngine)
 
33
    return new Greeter();
 
34
}
 
35
 
 
36
static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
 
37
{
 
38
    Q_UNUSED(engine)
 
39
    Q_UNUSED(scriptEngine)
 
40
    return new UsersModel();
 
41
}
 
42
 
 
43
static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
 
44
{
 
45
    Q_UNUSED(engine)
 
46
    Q_UNUSED(scriptEngine)
 
47
    return InfographicModel::getInstance();
 
48
}
 
49
 
 
50
void LightDMPlugin::registerTypes(const char *uri)
 
51
{
 
52
    qmlRegisterType<QAbstractItemModel>();
 
53
    qmlRegisterType<InfographicColorTheme>();
 
54
 
 
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);
 
60
}