File indexing completed on 2024-06-23 05:28:19

0001 /*
0002     Copyright (C) 2012  David Edmundson <kde@davidedmundson.co.uk>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Lesser General Public
0006     License as published by the Free Software Foundation; either
0007     version 2.1 of the License, or (at your option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012     Lesser General Public License for more details.
0013 
0014     You should have received a copy of the GNU Lesser General Public
0015     License along with this library; if not, write to the Free Software
0016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0017 */
0018 
0019 
0020 #include "qmlplugin.h"
0021 
0022 #include <QtDeclarative/QDeclarativeItem>
0023 #include <QtDeclarative/QDeclarativeEngine>
0024 #include <QtDeclarative/QDeclarativeContext>
0025 
0026 #include <QDebug>
0027 
0028 #include <QLightDM/Power>
0029 
0030 #include "sessionsmodel.h"
0031 #include "usersmodel.h"
0032 #include "screensmodel.h"
0033 #include "fakegreeter.h"
0034 #include "configwrapper.h"
0035 
0036 void QmlPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) {
0037     Q_UNUSED(uri)
0038 
0039     if (engine->rootContext()->contextProperty("greeter").isNull()) {
0040         engine->rootContext()->setContextProperty("greeter", new FakeGreeter(0));
0041     }
0042 
0043     if (engine->rootContext()->contextProperty("config").isNull()) {
0044         KUrl configPath(engine->baseUrl());
0045         configPath.setPath(configPath.path() + "/main.xml");
0046         engine->rootContext()->setContextProperty(QLatin1String("config"), new ConfigWrapper(configPath));
0047     }
0048 }
0049 
0050 void QmlPlugin::registerTypes(const char *uri)
0051 {
0052     qmlRegisterType<SessionsModel> (uri, 0, 1, "SessionsModel");
0053     qmlRegisterType<UsersModel> (uri, 0, 1, "UsersModel");
0054     qmlRegisterType<ScreensModel> (uri, 0, 1, "ScreensModel");
0055     
0056     qmlRegisterType<QLightDM::PowerInterface> (uri, 0, 1, "Power");
0057 }
0058 
0059 Q_EXPORT_PLUGIN2(klightdm, QmlPlugin);