Add VIS vehicle signal support
[apps/hvac.git] / app / main.cpp
index 38ccfe1..e4f87bf 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2016 The Qt Company Ltd.
+ * Copyright (C) 2022 Konsulko Group
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
-#include <QtAGLExtras/AGLApplication>
-#include <QtQml/QQmlApplicationEngine>
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+#include <QDebug>
 #include <hvac.h>
+#include <vehiclesignals.h>
 
 #include "translator.h"
 
 int main(int argc, char *argv[])
 {
-    AGLApplication app(argc, argv);
-    app.setApplicationName("HVAC");
-    app.setupApplicationRole("hvac");
+       setenv("QT_QUICK_CONTROLS_STYLE", "AGL", 1);
 
-    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");
-    }
+       QGuiApplication app(argc, argv);
 
-    qmlRegisterType<Translator>("Translator", 1, 0, "Translator");
-    app.load(QUrl(QStringLiteral("qrc:/HVAC.qml")));
-    return app.exec();
-}
+       QQmlApplicationEngine engine;
+       VehicleSignalsConfig vsConfig("hvac");
+       engine.rootContext()->setContextProperty("hvac", new HVAC(new VehicleSignals(vsConfig)));
+       qmlRegisterType<Translator>("Translator", 1, 0, "Translator");
+       engine.load(QUrl(QStringLiteral("qrc:/HVAC.qml")));
 
+       return app.exec();
+}