Launch navigation@0.1 when pressing NAVIGATION button
[staging/HomeScreen.git] / sample-qml / main.cpp
1 #include <QGuiApplication>
2 #include <QQmlApplicationEngine>
3 #include <unistd.h>
4 #include <vector>
5 #include <QQmlContext>
6 #include <libhomescreen.hpp>    // use libhomescreen
7 #include "calledbyqml.h"
8
9
10 #define FULLSCREEN 1    // assume 1 is "fullscreen"
11
12
13 int main(int argc, char *argv[])
14 {
15     QGuiApplication app(argc, argv);
16
17     /*  use libhomescreen
18         To use libhomescreen, add library path in project file(.pro)
19     */
20     LibHomeScreen *mp_libHomeScreen;
21     mp_libHomeScreen = new LibHomeScreen();
22
23     QQmlApplicationEngine engine;
24     CalledByQml call_hsa;
25     engine.rootContext()->setContextProperty("hsa",&call_hsa);
26
27     int appcategory = 0 ;
28
29     bool enabled = true;
30     enabled = mp_libHomeScreen->renderAppToAreaAllowed(appcategory, FULLSCREEN);
31     if(enabled)
32     {
33         engine.addImportPath(QStringLiteral(":/imports"));
34         engine.addImportPath(QStringLiteral(":/dummyimports"));
35
36         engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
37
38         std::vector<int> surfaceIdList;
39         int pid = getpid();
40         //maybe we can't call this function...
41         //surfaceIdList = mp_libHomeScreen->getAllSurfacesOfProcess(pid);
42         if(surfaceIdList.empty())
43         {
44             qDebug("surface list is empty");
45         }
46         else
47         {
48             qDebug("surface list is contained");
49             // it will be implemented as soon as possible
50             //mp_libHomeScreen->renderSurfaceToArea(surfaceIdList.at(0),FULLSCREEN);
51         }
52     }
53     else
54     {
55         qDebug("renderAppToAreaAllowed is denied");
56         delete mp_libHomeScreen;
57         return 0;
58     }
59
60     app.exec();
61     delete mp_libHomeScreen;
62     return 0;
63 }