c1f951ef004bab3aa794a85cfaee32df4dd4517a
[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 "mainwindow.h"
18 #include <QApplication>
19 #include <QtGui/QGuiApplication>
20 #include <QtQml/QQmlApplicationEngine>
21 #include <QtQml/QQmlContext>
22 #include <QtQml/qqml.h>
23
24 #include "../src2/applicationlauncher.h"
25 #include "../src2/statusbarmodel.h"
26 #include "layouthandler.h"
27 #include "../src2/applicationmodel.h"
28 #include "homescreencontrolinterface.h"
29
30 int main(int argc, char *argv[])
31 {
32     QApplication a(argc, argv);
33
34     // used for application settings (QSettings)
35     QCoreApplication::setOrganizationDomain("LinuxFoundation");
36     QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
37     QCoreApplication::setApplicationName("HomeScreen");
38     QCoreApplication::setApplicationVersion("0.6.0");
39
40     qDebug("%s, v%s", QCoreApplication::applicationName().toStdString().c_str(), QCoreApplication::applicationVersion().toStdString().c_str());
41
42     qDBusRegisterMetaType<AppInfo>();
43     qDBusRegisterMetaType<QList<AppInfo> >();
44
45     qmlRegisterType<ApplicationLauncher>("HomeScreen", 1, 0, "ApplicationLauncher");
46     qmlRegisterType<ApplicationModel>("Home", 1, 0, "ApplicationModel");
47     qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel");
48
49     QQmlApplicationEngine engine;
50
51     LayoutHandler* layoutHandler = new LayoutHandler();
52
53     HomeScreenControlInterface* hsci = new HomeScreenControlInterface();
54     //    QObject::connect(hsci, SIGNAL(newRequestGetAllSurfacesOfProcess(int)), layoutHandler, SLOT(requestGetAllSurfacesOfProcess(int)));
55     QObject::connect(hsci, SIGNAL(newRequestGetSurfaceStatus(int)), layoutHandler, SLOT(requestGetSurfaceStatus(int)));
56     QObject::connect(hsci, SIGNAL(newRequestsToBeVisibleApp(int)), layoutHandler, SLOT(makeMeVisible(int)));
57     QObject::connect(hsci, SIGNAL(newRequestRenderSurfaceToArea(int, int)), layoutHandler, SLOT(requestRenderSurfaceToArea(int,int)));
58     QObject::connect(hsci, SIGNAL(newRequestRenderSurfaceToAreaAllowed(int, int)), layoutHandler, SLOT(requestRenderSurfaceToAreaAllowed(int,int)));
59     QObject::connect(hsci, SIGNAL(newRequestSurfaceIdToFullScreen(int)), layoutHandler, SLOT(requestSurfaceIdToFullScreen(int)));
60
61     engine.rootContext()->setContextProperty("layoutHandler", layoutHandler);
62
63     engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
64
65     return a.exec();
66 }