Home screen translation changes
[staging/HomeScreen.git] / HomeScreen / src / main.cpp
1 /*
2  * Copyright (C) 2016 Mentor Graphics Development (Deutschland) GmbH
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <QGuiApplication>
18 #include <QCommandLineParser>
19 #include <QtGui/QGuiApplication>
20 #include <QtQml/QQmlApplicationEngine>
21 #include <QtQml/QQmlContext>
22 #include <QtQml/qqml.h>
23
24 #include "layouthandler.h"
25 #include "homescreencontrolinterface.h"
26 #include "../src2/applicationlauncher.h"
27 #include "../src2/statusbarmodel.h"
28 #include "../src2/applicationmodel.h"
29 #include "../src2/usermanagement.h"
30
31 void noOutput(QtMsgType, const QMessageLogContext &, const QString &)
32 {
33 }
34
35 int main(int argc, char *argv[])
36 {
37     QGuiApplication a(argc, argv);
38
39     QCoreApplication::setOrganizationDomain("LinuxFoundation");
40     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
41     QCoreApplication::setApplicationName("HomeScreen");
42     QCoreApplication::setApplicationVersion("0.7.0");
43
44     QCommandLineParser parser;
45     parser.setApplicationDescription("AGL HomeScreen - see wwww... for more details");
46     parser.addHelpOption();
47     parser.addVersionOption();
48     QCommandLineOption quietOption(QStringList() << "q" << "quiet",
49         QCoreApplication::translate("main", "Be quiet. No outputs."));
50     parser.addOption(quietOption);
51     parser.process(a);
52
53     if (parser.isSet(quietOption))
54     {
55         qInstallMessageHandler(noOutput);
56     }
57
58     qDBusRegisterMetaType<AppInfo>();
59     qDBusRegisterMetaType<QList<AppInfo> >();
60
61     qmlRegisterType<ApplicationLauncher>("HomeScreen", 1, 0, "ApplicationLauncher");
62     qmlRegisterType<ApplicationModel>("Home", 1, 0, "ApplicationModel");
63     qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel");
64
65     QQmlApplicationEngine engine;
66     LayoutHandler* layoutHandler = new LayoutHandler();
67
68     HomeScreenControlInterface* hsci = new HomeScreenControlInterface();
69     QObject::connect(hsci, SIGNAL(newRequestGetSurfaceStatus(int)), layoutHandler, SLOT(requestGetSurfaceStatus(int)));
70     QObject::connect(hsci, SIGNAL(newRequestsToBeVisibleApp(int)), layoutHandler, SLOT(makeMeVisible(int)));
71     QObject::connect(hsci, SIGNAL(newRequestRenderSurfaceToArea(int, int)), layoutHandler, SLOT(requestRenderSurfaceToArea(int,int)));
72     QObject::connect(hsci, SIGNAL(newRequestRenderSurfaceToAreaAllowed(int, int)), layoutHandler, SLOT(requestRenderSurfaceToAreaAllowed(int,int)));
73     QObject::connect(hsci, SIGNAL(newRequestSurfaceIdToFullScreen(int)), layoutHandler, SLOT(requestSurfaceIdToFullScreen(int)));
74
75     engine.rootContext()->setContextProperty("layoutHandler", layoutHandler);
76
77     engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
78     QObject *home = engine.rootObjects().first()->findChild<QObject *>("Home");
79     QObject *shortcutArea = engine.rootObjects().first()->findChild<QObject *>("ShortcutArea");
80     QObject *statusArea = engine.rootObjects().first()->findChild<QObject *>("StatusArea");
81     UserManagement userManagement(home, shortcutArea, statusArea);
82     Q_UNUSED(userManagement);
83     return a.exec();
84 }