aboutsummaryrefslogtreecommitdiffstats
path: root/app/main.cpp
blob: b3fd47a4edebe913310e3107d6850755ebb27222 (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
#include <QQmlApplicationEngine>

#include <QtCore/QDebug>
#include <QtCore/QCommandLineParser>
#include <QtCore/QUrlQuery>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlApplicationEngine>
#include <QtQml/QQmlContext>
#include <QtQuick/QQuickWindow>
#include <navigation.h>
#include <vehiclesignals.h>

#include "navigation_client.h"
#include "qcheapruler.hpp"
#include "file_operation.h"

#include "AglShellGrpcClient.h"

int main(int argc, char *argv[])
{
	std::string our_name = "tbtnavi";
	QString graphic_role = QString(our_name.c_str());

	setenv("QT_QUICK_CONTROLS_STYLE", "AGL", 1);

	QGuiApplication app(argc, argv);
	QCoreApplication::setOrganizationDomain("automotivelinux.org");
	QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
	QCoreApplication::setApplicationName(graphic_role);
	QCoreApplication::setApplicationVersion("0.1.0");
	app.setDesktopFileName(graphic_role);

	GrpcClient *client = new GrpcClient();
	client->SetAppOnOutput(our_name, "remoting-remote-1");

	// Load qml
	QQmlApplicationEngine engine;

	qmlRegisterType<QCheapRuler>("com.mapbox.cheap_ruler", 1, 0, "CheapRuler");

	QQmlContext *context = engine.rootContext();

	File_Operation file;
	context->setContextProperty("fileOperation", &file);

	VehicleSignalsConfig vsConfig("tbtnavi");
	VehicleSignals *vs = new VehicleSignals(vsConfig);
	if (!vs) {
		qFatal("Could not create VehicleSignals!");
	}
	context->setContextProperty("VehicleSignals", vs);

	// Give the navigation client it's own vehicle signals connection
	// to simplify state management wrt QML initialization, and keep the
	// notification streams separate.
	Navigation *navigation = new Navigation(new VehicleSignals(vsConfig), false, context);

	engine.load(QUrl(QStringLiteral("qrc:/Main.qml")));

	QObject *root = engine.rootObjects().first();
	new navigation_client(navigation, root->findChild<QObject*>("mapwindow"));

	return app.exec();
}