aboutsummaryrefslogtreecommitdiffstats
path: root/sample-qml/main.cpp
blob: 9238a9bf09b584f2f0d4961cb8560401e0defd03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <unistd.h>
#include <vector>
#include <QQmlContext>
#include <libhomescreen.hpp>    // use libhomescreen
#include "calledbyqml.h"


#define FULLSCREEN 1    // assume 1 is "fullscreen"


int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);

    /*  use libhomescreen
        To use libhomescreen, add library path in project file(.pro)
    */
    LibHomeScreen *mp_libHomeScreen;
    mp_libHomeScreen = new LibHomeScreen();

    QQmlApplicationEngine engine;
    CalledByQml call_hsa;
    engine.rootContext()->setContextProperty("hsa",&call_hsa);

    int appcategory = 0 ;

    bool enabled = true;
    enabled = mp_libHomeScreen->renderAppToAreaAllowed(appcategory, FULLSCREEN);
    if(enabled)
    {
        QString target(getenv("AFM_APP_INSTALL_DIR"));
        qDebug("AFM_APP_INSTALL_DIR is " + target.toLatin1());

        if(NULL == target)
        {
            target = ".";
        }

        QString load_path;
        load_path = target + "/imports";
        engine.addImportPath(load_path);
        load_path = target + "/dummyimports";
        engine.addImportPath(load_path);
        load_path = target + "/main.qml";

        engine.load(QUrl(load_path));

        std::vector<int> surfaceIdList;
        int pid = getpid();
        //maybe we can't call this function...
        //surfaceIdList = mp_libHomeScreen->getAllSurfacesOfProcess(pid);
        if(surfaceIdList.empty())
        {
            qDebug("surface list is empty");
        }
        else
        {
            qDebug("surface list is contained");
            // it will be implemented as soon as possible
            //mp_libHomeScreen->renderSurfaceToArea(surfaceIdList.at(0),FULLSCREEN);
        }
    }
    else
    {
        qDebug("renderAppToAreaAllowed is denied");
        delete mp_libHomeScreen;
        return 0;
    }

    app.exec();
    delete mp_libHomeScreen;
    return 0;
}