-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.cpp
47 lines (41 loc) · 1.36 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
#include <QCommandLineParser>
#include <QFile>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
app.setOrganizationName("machinekoder.com");
app.setOrganizationDomain("machinekoder.com");
app.setApplicationName("LiveCodingExample");
app.setApplicationDisplayName("Live Coding Example");
QCommandLineParser parser;
parser.setApplicationDescription("Live Coding Example");
parser.addHelpOption();
#ifdef QT_DEBUG
QCommandLineOption forceOption(QStringList() << "l" << "live",
QCoreApplication::translate("live", "Start live coding mode."));
parser.addOption(forceOption);
#endif
parser.process(app);
QString fileName = QStringLiteral("main.qml");
#ifdef QT_DEBUG
if (parser.isSet(forceOption)) {
fileName = QStringLiteral("live.qml");
}
#endif
QQmlApplicationEngine engine;
engine.addImportPath(QStringLiteral("."));
engine.addImportPath(QStringLiteral("qrc:/"));
QFile file(QStringLiteral("./") + fileName);
if (file.exists()) {
engine.load(QStringLiteral("./") + fileName);
}
else {
engine.load(QUrl(QStringLiteral("qrc:/") + fileName));
}
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}