-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
63 lines (55 loc) · 2.3 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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QCursor>
#include <QFileInfo>
#include <QProcess>
// #include <QDir>
// #include <QRegularExpression>
#include <DataProcessor/dataUnpacker.h>
#include <vector>
int main(int argc, char *argv[])
{
//#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
//QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
//#endif
/*argc = 3;
argv[0] = (char*)"Appname";
argv[1] = (char*)"--platform";
argv[2] = (char*)"android:dpiawareness=0";*/
QGuiApplication app(argc, argv);
DataUnpacker unpacker;
QQmlApplicationEngine engine;
QQmlContext * rootContext = engine.rootContext();
rootContext->setContextProperty("backEnd", &unpacker);
// Hide mouse cursor
app.setOverrideCursor(QCursor(Qt::BlankCursor));
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);
engine.load(url);
// run the Python file sync uploader if it's been cloned
{
// we look for file_sync/file_sync_up/main.py in two locations to handle
// different OSs and build systems
QProcess *process = new QProcess();
process->setProcessChannelMode(QProcess::MergedChannels); // show the python process's stdout interleaved
QFileInfo check_file_p1("../backend/file_sync/file_sync_up/main.py");
QFileInfo check_file_p2("./backend/file_sync/file_sync_up/main.py");
if (check_file_p1.exists() && check_file_p1.isFile()) {
process->start("python3", QStringList() << "../backend/file_sync/file_sync_up/main.py");
} else if (check_file_p2.exists() && check_file_p2.isFile()) {
process->start("python3", QStringList() << "./backend/file_sync/file_sync_up/main.py");
} else {
qDebug()<<"\n";
qDebug()<<"WARNING: running without file sync";
qDebug()<<" * Check whether you've cloned all the submodules";
qDebug()<<" * If that didn't work, your build output is probably in a nonstandard directory";
qDebug()<<"\n";
}
}
return app.exec();
}