KNewStuff

main.cpp
1 /*
2  This file is part of KNewStuff2.
3  SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7 
8 #include "knsrcmodel.h"
9 
10 #include "engine.h"
11 
12 #include <KLocalizedString>
13 
14 #include <QCommandLineParser>
15 #include <QCommandLineOption>
16 #include <QApplication>
17 #include <QQmlApplicationEngine>
18 #include <QQmlContext>
19 
20 int main(int argc, char **argv)
21 {
22  QApplication app(argc, argv);
23  QCoreApplication::setApplicationName(QStringLiteral("knewstuff-dialog"));
24  QCoreApplication::setApplicationVersion(QStringLiteral("1.0"));
25  QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
26  KLocalizedString::setApplicationDomain("knewstuff-dialog");
27 
29  parser->addHelpOption();
30  parser->addPositionalArgument(QStringLiteral("knsrcfile"), i18n("The KNSRC file you want to show. If none is passed, you will be presented with a dialog which lets you switch between all the config files installed into the systemwide knsrc file location, which on your system is: %1", KNSCore::Engine::configSearchLocations().last()));
31  parser->process(app);
32 
34  qmlRegisterType<KNSRCModel>("org.kde.newstuff.tools.dialog", 1, 0, "KNSRCModel");
35  appengine->rootContext()->setContextProperty(QStringLiteral("knsrcFilesLocation"), KNSCore::Engine::configSearchLocations().last());
36 
37  if (parser->positionalArguments().count() > 0) {
38  appengine->rootContext()->setContextProperty(QStringLiteral("knsrcfile"), parser->positionalArguments().first());
39  appengine->load(QStringLiteral("qrc:/qml/dialog.qml"));
40  } else {
41  appengine->load(QStringLiteral("qrc:/qml/main.qml"));
42  }
43 
44  return app.exec();
45 }
QStringList positionalArguments() const const
void addPositionalArgument(const QString &name, const QString &description, const QString &syntax)
static void setApplicationDomain(const char *domain)
void setOrganizationDomain(const QString &orgDomain)
int count(const T &value) const const
void setApplicationVersion(const QString &version)
QCommandLineOption addHelpOption()
void setContextProperty(const QString &name, QObject *value)
T & first()
QQmlContext * rootContext() const const
void process(const QStringList &arguments)
QString i18n(const char *text, const TYPE &arg...)
void load(const QUrl &url)
static QStringList configSearchLocations(bool includeFallbackLocations=false)
Get a list of all the locations which will be used when searching for knsrc files, in the order in which the search will occur.
Definition: engine.cpp:944
void setApplicationName(const QString &application)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 25 2021 22:47:27 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.