Add gitlab issue/merge request templates
[apps/launcher.git] / launcher / src / main.cpp
1 // SPDX-License-Identifier: Apache-2.0
2 /*
3  * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH
4  * Copyright (c) 2018 TOYOTA MOTOR CORPORATION
5  * Copyright (C) 2022 Konsulko Group
6  */
7
8 #include <QGuiApplication>
9 #include <QCommandLineParser>
10 #include <QtCore/QUrlQuery>
11 #include <QtGui/QGuiApplication>
12 #include <QtQml/QQmlApplicationEngine>
13 #include <QtQml/QQmlContext>
14 #include <QtQml/qqml.h>
15 #include <QQuickWindow>
16 #include <QThread>
17
18 #include "applicationmodel.h"
19 #include "appinfo.h"
20 #include "AppLauncherClient.h"
21
22 int main(int argc, char *argv[])
23 {
24     QString myname = QString("launcher");
25     QGuiApplication app(argc, argv);
26
27     // necessary to identify correctly by app_id
28     app.setDesktopFileName(myname);
29
30     QQmlApplicationEngine engine;
31
32     AppLauncherClient* applauncher = new AppLauncherClient();
33     QList<QMap<QString, QString>> apps;
34     if (applauncher) {
35         applauncher->listApplications(apps);
36         engine.rootContext()->setContextProperty(QStringLiteral("applauncher"), applauncher);
37         engine.rootContext()->setContextProperty(QStringLiteral("apps_len"), apps.size());
38     } else {
39         qFatal("Could not create AppLauncherClient");
40     }
41
42     ApplicationModel *appmodel = new ApplicationModel();
43     if (appmodel) {
44         appmodel->initAppList(apps);
45         qmlRegisterSingletonType<ApplicationModel>("AppModel", 1, 0, "ApplicationModel",
46                                                    [appmodel](QQmlEngine *, QJSEngine *) -> QObject * { return appmodel; });
47     } else {
48         qFatal("Could not create ApplicationModel");
49     }
50     engine.load(QUrl(QStringLiteral("qrc:/Launcher.qml")));
51
52     return app.exec();
53 }