aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2020-05-29 17:57:33 +0300
committerMarius Vlad <marius.vlad@collabora.com>2020-06-24 18:13:15 +0300
commit18abf43ba645b46b0d6c5245e8282e2d6db40332 (patch)
treeac0bef263ce9e754d0b2607177effe868eec75cf
parente0abfb8c769536cec9db9e78fff6dd93754dcd7a (diff)
bindingAdress Bug-AGL: SPEC-3447 Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Change-Id: I5afeecdbfc9d0272d9231d7d4c19334c1ce6d9cc
-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();
}