hvac: switch to libqtappfw access for websocket data
[apps/hvac.git] / app / main.cpp
index b2133f7..38ccfe1 100644 (file)
  * limitations under the License.
  */
 
-#include <QtCore/QDebug>
-#include <QtGui/QGuiApplication>
+#include <QtAGLExtras/AGLApplication>
 #include <QtQml/QQmlApplicationEngine>
-#include <QtQuickControls2/QQuickStyle>
+#include <hvac.h>
 
-#ifdef HAVE_LIBHOMESCREEN
-#include <libhomescreen.hpp>
-#endif
+#include "translator.h"
 
 int main(int argc, char *argv[])
 {
-#ifdef HAVE_LIBHOMESCREEN
-    LibHomeScreen libHomeScreen;
-
-    if (!libHomeScreen.renderAppToAreaAllowed(0, 1)) {
-        qWarning() << "renderAppToAreaAllowed is denied";
-        return -1;
+    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");
     }
-#endif
-
-    QGuiApplication app(argc, argv);
-
-    QQuickStyle::setStyle("AGL");
-
-    QQmlApplicationEngine engine;
-    engine.load(QUrl(QStringLiteral("qrc:/HVAC.qml")));
 
+    qmlRegisterType<Translator>("Translator", 1, 0, "Translator");
+    app.load(QUrl(QStringLiteral("qrc:/HVAC.qml")));
     return app.exec();
 }