summaryrefslogtreecommitdiffstats
path: root/app/main.cpp
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-01-22 20:25:47 +0200
commit2afae8c55678cf070ee1a41137be48019ea4872c (patch)
tree2db169a414592d92e9806331cf8573c87349fd71 /app/main.cpp
parent3a06bfdba8bc3e521d23c59e4c8e12101df175ce (diff)
app/: Avoid any AGL wrappers and use plain Qt
Removes homescreen/windowmanger requirements from config Signed-off-by: Marius Vlad <marius.vlad@collabora.com> Change-Id: I99a2221e44d04a06b8d3cf412b22e0204a9c89a5
Diffstat (limited to 'app/main.cpp')
-rw-r--r--app/main.cpp55
1 files changed, 47 insertions, 8 deletions
diff --git a/app/main.cpp b/app/main.cpp
index 2fac9ae..6fe54a5 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -14,18 +14,57 @@
* limitations under the License.
*/
-#include <QtAGLExtras/AGLApplication>
+#include <QtGui/QGuiApplication>
+#include <QDebug>
+#include <QUrlQuery>
+#include <QCommandLineParser>
#include <QtQml/QQmlApplicationEngine>
+#include <QtQml/QQmlContext>
#include "translator.h"
int main(int argc, char *argv[])
{
- AGLApplication app(argc, argv);
- app.setApplicationName("HVAC");
- app.setupApplicationRole("hvac");
- 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);
+ qmlRegisterType<Translator>("Translator", 1, 0, "Translator");
+ engine.load(QUrl(QStringLiteral("qrc:/HVAC.qml")));
+
+ return app.exec();
+}