-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
48 lines (40 loc) · 1.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
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtQml/QQmlContext>
#include <QtCore/QDebug>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
//get video/audio source URL from application "-url file:///home/root..." argument
QUrl source;
QStringList args = app.arguments();
bool sourceIsUrl = false;
for (int i = 1; i < args.size(); ++i) {
const QByteArray arg = args.at(i).toUtf8();
if (arg.startsWith('-')) {
if ("-url" == arg) {
sourceIsUrl = true;
} else {
qDebug() << "Option" << arg << "ignored";
}
} else {
if ((sourceIsUrl == true) && arg.startsWith("file:///") )
source = arg;
else
qDebug() << "Argument ignored! Please use \"-url file:///home/root/...\"";
}
}
qDebug() << source;
/*
QUrl url;
if (sourceIsUrl) {
url = source;
}
qDebug() << url; */
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("mysource", source);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}