This repository has been archived by the owner on Aug 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·87 lines (68 loc) · 2.09 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <QGuiApplication>
#include <QQuickView>
#include <QQmlContext>
#include <QFontDatabase>
#include <QQuickItem>
#include "Keyboard/keyboard.h"
#include "Rendering/fborenderer.h"
#include "Printer/printer.h"
#include "Misc/filebrowser.h"
#include "Misc/globalsettings.h"
#include "Misc/qtsettings.h"
#include <QFile>
#include <QString>
#include <QDebug>
#include <iostream>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
#ifdef ANDROID
#define FILECOUNT 3
QString* names = new QString[FILECOUNT];
names[0] = "bin.stl";
names[1] = "cube.vsh";
names[2] = "cube.fsh";
for (uint8_t i = 0; i < FILECOUNT; i++)
{
QFile dfile("assets:/" + names[i]);
if (dfile.exists())
{
QString name = "./" + names[i];
dfile.copy(name);
QFile::setPermissions(name, QFile::ReadOwner);
}
}
delete[] names;
#endif
// Initialize
GlobalSettings::LoadSettings();
GlobalPrinter.Connect();
qmlRegisterType<FBORenderer>("FBORenderer", 1, 0, "Renderer");
QFontDatabase database;
database.addApplicationFont(":/nevis.ttf");
QQuickView view;
Keyboard keyboard(&view);
view.rootContext()->setContextProperty("keyboard", &keyboard);
FileBrowser fb;
view.rootContext()->setContextProperty("fileBrowser", &fb);
view.rootContext()->setContextProperty("settings", &qtSettings);
view.rootContext()->setContextProperty("printer", &GlobalPrinter);
#ifdef ROTATE_SCREEN
#define ROOTQML "qrc:/Rotated.qml"
std::cout << "Running rotated" << std::endl;
#else
#define ROOTQML "qrc:/MainScreen.qml"
#endif
view.setSource(QUrl(QStringLiteral(ROOTQML)));
QObject *root = view.rootObject();
QObject *qmlKeyboard = root->findChild<QObject*>("keyboard");
keyboard.setQmlKeyboard(qobject_cast<QQuickItem*>(qmlKeyboard));
view.show();
//GlobalSettings::InfillLineDistance.Set(31.0f);
//GlobalSettings::BedLength.Set(200.0f);
auto result = app.exec();
// Finialize
GlobalSettings::StopSavingLoop();
GlobalSettings::SaveSettings();
return result;
}