aboutsummaryrefslogtreecommitdiffstats
path: root/app/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'app/main.cpp')
-rw-r--r--app/main.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/app/main.cpp b/app/main.cpp
index 41b5892..76efbbf 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -17,10 +17,13 @@
*/
#include <QGuiApplication>
+#include <QtCore/QCommandLineParser>
+#include <QtCore/QUrlQuery>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlContext>
#include <QtQml/QQmlApplicationEngine>
#include <QtQml/qqml.h>
+#include <QDebug>
#include "mixer.hpp"
#include "audiorole.hpp"
@@ -30,9 +33,38 @@ int main(int argc, char *argv[])
QGuiApplication app(argc, argv);
app.setDesktopFileName("mixer");
- QQmlApplicationEngine engine;
- qmlRegisterType<Mixer>("Mixer", 1, 0, "Mixer");
- engine.load(QUrl(QStringLiteral("qrc:/Mixer.qml")));
+ QQmlApplicationEngine engine;
+ QQmlContext *context = engine.rootContext();
+
+ QCommandLineParser parser;
+ parser.addPositionalArgument("port", app.translate("main", "port for binding"));
+ parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.process(app);
+ QStringList positionalArguments = parser.positionalArguments();
+
+ if (positionalArguments.length() == 2) {
+ int port = positionalArguments.takeFirst().toInt();
+ QString secret = positionalArguments.takeFirst();
+
+ QUrl bindingAddress;
+ QUrlQuery query;
+
+ bindingAddress.setScheme(QStringLiteral("ws"));
+ bindingAddress.setHost(QStringLiteral("localhost"));
+ bindingAddress.setPort(port);
+ bindingAddress.setPath(QStringLiteral("/api"));
+
+
+ query.addQueryItem(QStringLiteral("token"), secret);
+ bindingAddress.setQuery(query);
+ context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
+
+ qmlRegisterType<Mixer>("Mixer", 1, 0, "Mixer");
+ }
+
+ engine.load(QUrl(QStringLiteral("qrc:/Mixer.qml")));
return app.exec();
}