Changeset View
Changeset View
Standalone View
Standalone View
tests/khotnewstuff-dialog.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | This file is part of KNewStuff2. | ||||
3 | Copyright (c) 2019 Dan Leinir Turthra Jensen <admin@leinir.dk> | ||||
4 | | ||||
5 | This library is free software; you can redistribute it and/or | ||||
6 | modify it under the terms of the GNU Lesser General Public | ||||
7 | License as published by the Free Software Foundation; either | ||||
8 | version 2.1 of the License, or (at your option) any later version. | ||||
9 | | ||||
10 | This library is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | Lesser General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU Lesser General Public | ||||
16 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
17 | */ | ||||
18 | | ||||
19 | #include <KLocalizedString> | ||||
20 | | ||||
21 | #include <QCommandLineParser> | ||||
22 | #include <QCommandLineOption> | ||||
23 | #include <QApplication> | ||||
24 | #include <QQmlApplicationEngine> | ||||
25 | #include <QQmlContext> | ||||
26 | | ||||
27 | #include "engine.h" | ||||
28 | | ||||
29 | int main(int argc, char **argv) | ||||
30 | { | ||||
31 | QApplication app(argc, argv); | ||||
32 | QCoreApplication::setApplicationName(QStringLiteral("khotnewstuff-dialog")); | ||||
33 | QCoreApplication::setApplicationVersion(QStringLiteral("0.1")); | ||||
34 | QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); | ||||
35 | | ||||
36 | QCommandLineParser *parser = new QCommandLineParser; | ||||
37 | parser->addHelpOption(); | ||||
38 | parser->addPositionalArgument(QStringLiteral("knsrcfile"), i18n("The KNSRC file you want to show. If none is passed, we will use khotnewstuff_test.knsrc, which must be installed.")); | ||||
39 | parser->process(app); | ||||
40 | | ||||
41 | QQmlApplicationEngine *appengine = new QQmlApplicationEngine(); | ||||
42 | if (parser->positionalArguments().count() > 0) { | ||||
43 | appengine->rootContext()->setContextProperty(QLatin1String("knsrcfile"), parser->positionalArguments().first()); | ||||
44 | } else { | ||||
45 | appengine->rootContext()->setContextProperty(QLatin1String("knsrcfile"), QString::fromLatin1("%1/khotnewstuff_test.knsrc").arg(QStringLiteral(KNSBUILDDIR))); | ||||
46 | } | ||||
47 | appengine->rootContext()->setContextProperty(QLatin1String("knsrcFilesLocation"), KNSCore::Engine::configSearchLocations().last()); | ||||
48 | | ||||
49 | appengine->load(QUrl::fromLocalFile(QString::fromLatin1("%1/khotnewstuff-dialog-ui/main.qml").arg(QStringLiteral(KNSSRCDIR)))); | ||||
50 | | ||||
51 | return app.exec(); | ||||
52 | } |