Branch data Line data Source code
1 : : #include <QtGui/QCursor>
2 : : #include <QtGui/QGuiApplication>
3 : : #include <QtQml/QQmlApplicationEngine>
4 : : #include <QtQml/QQmlContext>
5 : : #include <csignal>
6 : :
7 : : #include "src/DataManager.hpp"
8 : :
9 : 0 : void sigHandler(int s) {
10 : 0 : std::signal(s, SIG_DFL);
11 : 0 : qApp->quit();
12 : 0 : }
13 : :
14 : 0 : auto main(int argc, char *argv[]) -> int {
15 : 0 : QGuiApplication app(argc, argv);
16 : :
17 : 0 : QQmlApplicationEngine engine;
18 : 0 : QObject::connect(
19 : : &engine, &QQmlApplicationEngine::objectCreationFailed, &app,
20 : 0 : []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection);
21 : :
22 : 0 : QObject::connect(qApp, &QCoreApplication::aboutToQuit, [&]() {
23 : : // The DataManager's destructor will handle cleanup. No need to repeat it here.
24 : 0 : qDebug() << "Application is quitting";
25 : 0 : });
26 : :
27 : : // adding qml folder to import path
28 : 0 : engine.addImportPath("qrc:/applications/instrument-cluster/qml");
29 : :
30 : : // Registering C++ objects as QML types
31 : 0 : qmlRegisterType<DataManager>("DataManager", 1, 0, "DataManager");
32 : :
33 : : #ifdef SIMULATION_MODE
34 : : engine.rootContext()->setContextProperty("SIMULATION_MODE", QVariant(true));
35 : : #else
36 : 0 : engine.rootContext()->setContextProperty("SIMULATION_MODE", QVariant(false));
37 : 0 : QGuiApplication::setOverrideCursor(QCursor(Qt::BlankCursor));
38 : : #endif
39 : :
40 : 0 : engine.load(QUrl(QStringLiteral("qrc:/applications/instrument-cluster/Main.qml")));
41 : :
42 : 0 : std::signal(SIGINT, sigHandler);
43 : 0 : std::signal(SIGTERM, sigHandler);
44 : 0 : std::signal(SIGSEGV, sigHandler);
45 : 0 : std::signal(SIGABRT, sigHandler);
46 : 0 : return QGuiApplication::exec();
47 : 0 : }
|