summaryrefslogtreecommitdiff
path: root/src/hmi/hmi-launcher/main.cpp
blob: 38dadf9dd59e4c985a7b4d8ec8b662ab724ef892 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* @licence app begin@
* SPDX-License-Identifier: MPL-2.0
*
* \copyright Copyright (C) 2013-2014, PCA Peugeot Citroen
*
* \file main.cpp
*
* \brief This file is part of the FSA HMI.
*
* \author Philippe Colliot <philippe.colliot@mpsa.com>
* \author Tanibata, Nobuhiko <NOBUHIKO_TANIBATA@denso.co.jp>
*
* \version 1.0
*
* This Source Code Form is subject to the terms of the
* Mozilla Public License (MPL), v. 2.0.
* If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* For further information see http://www.genivi.org/.
*
* List of changes:
*
* 13-10-2014, Tanibata, Nobuhiko, adaptation to layer management
*
* @licence end@
*/
#include <QtQuick/QQuickView>
#include <QApplication>
#include <QPalette>
#include <QObject>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQuickWindow>
#include <QSurfaceFormat>
#include <QQmlContext>
#include "dbusif.h"
#include "dltif.h"
#include "wheelarea.h"
#include "preference.h"
#include "settings.h"

int main(int argc, char ** argv)
{
    QApplication app(argc, argv);

    // Register component types with QML.
    qmlRegisterType<DBusIf>("lbs.plugin.dbusif", 1, 0, "DBusIf");
    qmlRegisterType<Preference>("lbs.plugin.preference", 1,0, "Preference");
    qmlRegisterType<WheelArea>("lbs.plugin.wheelarea", 1, 0, "WheelArea");
    qmlRegisterType<DLTIf>("lbs.plugin.dltif", 1, 0, "DLTIf");

    //get settings stored into the conf file (in $HOME/.config/navigation/fsa.conf)

    app.setOrganizationName(QString("navigation"));
    app.setApplicationName(QString("fsa"));

    Settings* settings=new Settings;
    settings->setIniCodec("UTF-8");

    int rc = 0;

    QQmlEngine engine;
    engine.rootContext()->setContextProperty("Settings",settings);

    QQmlComponent *component = new QQmlComponent(&engine);

    QPalette pal = app.palette();
    pal.setColor(QPalette::Window, Qt::transparent);
    app.setPalette(pal);

    QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));

    component->loadUrl(QUrl(argv[1]));

    if (!component->isReady() ) {
        qWarning("%s", qPrintable(component->errorString()));
        return -1;
    }

    QQmlContext *context = engine.rootContext();

    QObject *topLevel = component->create();

    QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);

    window->setFlags(Qt::FramelessWindowHint);
    window->setColor(Qt::transparent);

    QSurfaceFormat surfaceFormat = window->requestedFormat();
    window->setFormat(surfaceFormat);
    window->show();

    rc = app.exec();
    delete component;
    return rc;
}