diff options
author | Scott Murray <scott.murray@konsulko.com> | 2020-09-23 16:57:33 -0400 |
---|---|---|
committer | Scott Murray <scott.murray@konsulko.com> | 2020-09-29 22:39:14 +0000 |
commit | efa39aef73f111868fe6b0494d8c560526e1b913 (patch) | |
tree | a7ade90a97905daf1f6f1f0d95f079774f4dd317 /app | |
parent | a873c59f0eadccbea829c33d1287434a96b16175 (diff) |
Fix signal-composer integrationjellyfish_10.0.3jellyfish_10.0.2jellyfish_10.0.1jellyfish/10.0.3jellyfish/10.0.2jellyfish/10.0.110.0.310.0.210.0.1jellyfish
Copy command-line parsing from hvac application to replace what
was being done by the now removed QtAGLExtras code, this allows
correctly instantiating the signal-composer object from qtappfw
again.
Bug-AGL: SPEC-3602
Signed-off-by: Scott Murray <scott.murray@konsulko.com>
Change-Id: I0ec7f75af814d67fa0b4f431450e437fddf57e11
(cherry picked from commit 05753692843e225d2370c63857334d2f675ed003)
Diffstat (limited to 'app')
-rw-r--r-- | app/main.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/app/main.cpp b/app/main.cpp index 2eef1b0..6fe44d3 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -19,6 +19,8 @@ #include <QtQml/QQmlApplicationEngine> #include <QtQml/QQmlContext> #include <QtGui/QGuiApplication> +#include <QtCore/QCommandLineParser> +#include <QtCore/QUrlQuery> #include <signalcomposer.h> #include "translator.h" @@ -27,15 +29,32 @@ int main(int argc, char *argv[]) QGuiApplication app(argc, argv); app.setDesktopFileName("dashboard"); + 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) { + exit(EXIT_FAILURE); + } + + int port = positionalArguments.takeFirst().toInt(); + QString secret = positionalArguments.takeFirst(); + QUrlQuery query; + query.addQueryItem(QStringLiteral("token"), secret); + + QUrl bindingAddress; + bindingAddress.setScheme(QStringLiteral("ws")); + bindingAddress.setHost(QStringLiteral("localhost")); + bindingAddress.setPort(port); + bindingAddress.setPath(QStringLiteral("/api")); + bindingAddress.setQuery(query); + QQmlApplicationEngine engine; QQmlContext *context = engine.rootContext(); - QVariant v = context->contextProperty(QStringLiteral("bindingAddress")); - if(v.canConvert(QMetaType::QUrl)) { - QUrl bindingAddress = v.toUrl(); - context->setContextProperty("SignalComposer", new SignalComposer(bindingAddress, context)); - } else { - qCritical("Cannot find bindingAddress property in context, SignalComposer unavailable"); - } + context->setContextProperty("SignalComposer", new SignalComposer(bindingAddress, context)); qmlRegisterType<Translator>("Translator", 1, 0, "Translator"); engine.load(QUrl(QStringLiteral("qrc:/Dashboard.qml"))); return app.exec(); |