forked from Riflio/SVG2QML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
64 lines (49 loc) · 1.85 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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QSurfaceFormat>
#include <QQmlContext>
#include <QCommandLineParser>
#include "appcore.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QSurfaceFormat format;
format.setSamples(8);
QSurfaceFormat::setDefaultFormat(format);
QCommandLineParser parser;
parser.setApplicationDescription("SVG to QML converter.");
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument("source", QCoreApplication::translate("main", "Source svg file."));
parser.addPositionalArgument("destination", QCoreApplication::translate("main", "Destination qml file."));
parser.process(app);
const QStringList args = parser.positionalArguments();
QString source = "";
QString dest = "";
if ( args.count()>1 ) {
source = args[0];
dest = args[1];
} else {
#ifdef Q_OS_WIN
source = "Z:/SVG2QML/tests/test_bezier1.svg";
dest = "Z:/SVG2QML/tests/test1_QML.qml";
#else
source = "/home/pavelk/Projects/SVG2QML/SVG2QML/examples/buttons1.svg";
dest = "/home/pavelk/Projects/SVG2QML/SVG2QML/examples/buttons1.qml";
#endif
}
AppCore * appCore = new AppCore(nullptr);
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("appCore", QVariant::fromValue(appCore));
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);
//-- GO GO GO
appCore->go(source, dest);
return app.exec();
}