-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
76 lines (56 loc) · 2.28 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
56
57
58
59
60
61
62
63
64
65
66
67
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QSettings>
#include <QQmlContext>
#include <QDebug>
#include <QCoreApplication>
#include <QJsonDocument>
#include <QJsonObject>
#include <QScreen>
#include "signal.h"
#include "common.h"
#include "mainviewcontroller.h"
#include "serialcontroller.h"
#include "translator.h"
#include "network.h"
//#include "beeper.h"
#include "gpiopin.h"
#include "backlight.h"
#include "system.h"
#include "myGlobal.h"
#include "myStyle.h"
StyleValues MyStyle;
GlobalValues MyGlobal;
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("MyGlobal", & MyGlobal);
qDebug() << "The global count is => " << MyGlobal.count();
engine.rootContext()->setContextProperty("MyStyle", & MyStyle);
qDebug() << "The style count is => " << MyStyle.count();
SerialController serialController;
/* Need to register before the MainviewController is instantiated */
qmlRegisterType < Network > ("net.reachtech", 1, 0, "Network");
//qmlRegisterType < Beeper > ("sound.reachtech", 1, 0, "Beeper");
qmlRegisterType < GpioPin > ("gpio.reachtech", 1, 0, "GpioPin");
qmlRegisterType < Backlight > ("backlight.reachtech", 1, 0, "Backlight");
qmlRegisterType < System > ("system.reachtech", 1, 0, "System");
QScreen *screen = QGuiApplication::primaryScreen();
QRect screenGeometry = screen->geometry();
MyGlobal.insert("screenWidth", screenGeometry.width());
MyGlobal.insert("screenHeight", screenGeometry.height());
MyGlobal.insert("screenFactor", screenGeometry.height());
qDebug() << "Screen Size is" << MyGlobal.value("screenWidth").toInt() << "x" << MyGlobal.value("screenHeight").toInt();
engine.load(QUrl(QStringLiteral("qrc:/MainScreen.qml")));
if (engine.rootObjects().isEmpty())
return -1;
QObject * topLevel = engine.rootObjects().value(0);
QQuickWindow * window = qobject_cast < QQuickWindow * > (topLevel);
if (window == nullptr) {
qDebug() << "Can't instantiate window";
}
QObject::connect(window, SIGNAL(submitTextField(QString)), & serialController, SLOT(send(QString)));
return app.exec();
}