summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMarius Vlad <marius.vlad@collabora.com>2020-01-22 01:18:44 +0200
committerMarius Vlad <marius.vlad@collabora.com>2020-06-24 17:15:49 +0300
commit8e822732230d9a0498cd581dd5bb53bfa7e029a1 (patch)
tree3b84f229b1ed16339c6d8cf597467fb61e5664e7 /app
parent611a430a2457eed24cee182c073189653c55a793 (diff)
app/: Avoid any AGL wrappers and use plain Qt
Removes homescreen/windowmanger requirements from config Bug-AGL: SPEC-3447 Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Change-Id: I99a2221e44d04a06b8d3cf412b22e0204a9c89a5
Diffstat (limited to 'app')
-rw-r--r--app/app.pro4
-rw-r--r--app/main.cpp67
2 files changed, 50 insertions, 21 deletions
diff --git a/app/app.pro b/app/app.pro
index d032417..f4ab212 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -1,5 +1,5 @@
TARGET = hvac
-QT = quick qml aglextras
+QT = quick qml websockets
HEADERS += \
translator.h
@@ -7,7 +7,7 @@ HEADERS += \
SOURCES = main.cpp \
translator.cpp
-CONFIG += link_pkgconfig
+CONFIG += c++11 link_pkgconfig
PKGCONFIG += qtappfw-hvac
CONFIG(release, debug|release) {
diff --git a/app/main.cpp b/app/main.cpp
index 38ccfe1..94b46ad 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -14,30 +14,59 @@
* limitations under the License.
*/
-#include <QtAGLExtras/AGLApplication>
+#include <QtGui/QGuiApplication>
+#include <QDebug>
+#include <QUrlQuery>
+#include <QCommandLineParser>
#include <QtQml/QQmlApplicationEngine>
#include <hvac.h>
+#include <QtQml/QQmlContext>
#include "translator.h"
int main(int argc, char *argv[])
{
- AGLApplication app(argc, argv);
- app.setApplicationName("HVAC");
- app.setupApplicationRole("hvac");
-
- QQmlApplicationEngine *engine = app.getQmlApplicationEngine();
- QQmlContext *context = engine->rootContext();
- QVariant v = context->contextProperty(QStringLiteral("bindingAddress"));
- if(v.canConvert(QMetaType::QUrl)) {
- QUrl bindingAddress = v.toUrl();
- context->setContextProperty("hvac", new HVAC(bindingAddress));
- } else {
- qCritical("Cannot find bindingAddress property in context, SignalComposer unavailable");
- }
-
- qmlRegisterType<Translator>("Translator", 1, 0, "Translator");
- app.load(QUrl(QStringLiteral("qrc:/HVAC.qml")));
- return app.exec();
-}
+ setenv("QT_QPA_PLATFORM", "wayland", 1);
+ int port;
+ QString token;
+
+ QCommandLineParser parser;
+ QGuiApplication app(argc, argv);
+
+ 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) {
+ port = positionalArguments.takeFirst().toInt();
+ token = positionalArguments.takeFirst();
+ qInfo() << "setting port:" << port << ", token:" << token;
+ } else {
+ qInfo() << "Need to specify port and token";
+ exit(EXIT_FAILURE);
+ }
+ QUrl bindingAddress;
+ bindingAddress.setScheme(QStringLiteral("ws"));
+ bindingAddress.setHost(QStringLiteral("localhost"));
+ bindingAddress.setPort(port);
+ bindingAddress.setPath(QStringLiteral("/api"));
+
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("token"), token);
+ bindingAddress.setQuery(query);
+
+ QQmlApplicationEngine engine;
+ engine.rootContext()->setContextProperty("bindingAddress", bindingAddress);
+ engine.rootContext()->setContextProperty("hvac", new HVAC(bindingAddress));
+ qmlRegisterType<Translator>("Translator", 1, 0, "Translator");
+ engine.load(QUrl(QStringLiteral("qrc:/HVAC.qml")));
+
+ return app.exec();
+}