-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
55 lines (45 loc) · 1.71 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
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <QDebug>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "lib/ParamPart_PCSide/parampart_pcs.h"
#include "clock.h"
#include "mixer.h"
#include "serialx.h"
#include "slotmaster.h"
#include "tmanager.h"
#include "tstatustable.h"
#define LAYOUT_COLOR_MAIN1 #f9842d
int main(int argc, char* argv[]) {
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QQmlContext* context = engine.rootContext();
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(
&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject* obj, const QUrl& objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
},
Qt::QueuedConnection);
// Objects initialization
Clock clocky;
TStatusTable gtable;
Mixer mixer(>able);
SerialX serial;
ParamPart Reader;
SlotMaster SlotM(&mixer);
TManager Manager(&Reader, &SlotM, &mixer, &serial, >able, &clocky); // Push pointers of main objects to Manager object
serial.InstallToManager(&Manager); // Connect callback pointer to Manager from serial.
// Give access to main objects from QML
context->setContextProperty("gtable", >able);
context->setContextProperty("serial", &serial);
context->setContextProperty("clocky", &clocky);
context->setContextProperty("mixer", &mixer);
context->setContextProperty("slotmaster", &SlotM);
context->setContextProperty("manager", &Manager);
engine.load(url);
serial.begin("ttyUSB0", 9600); // Connect serial port
return app.exec();
}