-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
42 lines (34 loc) · 1.03 KB
/
main.cpp
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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <csignal>
#include "DashDriver.h"
#include "utils.h"
void sigHandler(int sig) {
qInfo() << "SIGNAL" << sig;
QCoreApplication::exit(0);
}
int main(int argc, char *argv[]) {
qInfo() << "enter main";
int rc = 0;
try {
DashDriver::staticInit();
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
qmlRegisterType<Pfc>("rxdash", 1, 0, "Pfc");
qmlRegisterType<DashDriver>("rxdash", 1, 0, "DashDriver");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
signal(SIGINT, sigHandler);
signal(SIGTERM, sigHandler);
rc = app.exec();
} catch (const std::exception& ex) {
qCritical() << "main: exception:" << ex.what();
} catch (...) {
qCritical() << "main: unknown exception";
}
qInfo() << "exit";
if (rc == DashDriver::RC_POWEROFF) {
ut::osPowerOff();
}
return rc;
}