aboutsummaryrefslogtreecommitdiffstats
path: root/app/main.cpp
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2018-07-02 15:38:32 +0200
committerLoïc Collignon <loic.collignon@iot.bzh>2018-07-10 19:21:41 +0200
commitc56b75f6511015edb4417df81d97aa6181e5480e (patch)
tree81fc62d2d341b518b1f9639c3eb862b67c4252c1 /app/main.cpp
parentaf3fc263d66cb981e2ca159109d8c2edf1b89e09 (diff)
Allow to build and run on native linux host
Make libhomescreen and libmanager dependencies optional so that you can build, run and debug on a native linux host, to allow faster development. Change-Id: Ice0b7e196e9a88dc7f0f8e9894eb9091c6ba566e Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
Diffstat (limited to 'app/main.cpp')
-rw-r--r--app/main.cpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/app/main.cpp b/app/main.cpp
index 9c6339f..60b2951 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -30,8 +30,12 @@
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
#include <QQuickWindow>
+#ifndef NATIVE_BUILD
#include <libhomescreen.hpp>
#include <qlibwindowmanager.h>
+#else
+#include <QScreen>
+#endif
#include "mixer.h"
int main(int argc, char *argv[])
@@ -50,7 +54,7 @@ int main(int argc, char *argv[])
parser.process(app);
QStringList positionalArguments = parser.positionalArguments();
- qmlRegisterType<Mixer>("Mixer", 1, 0, "Mixer");
+ qmlRegisterType<Mixer>("Mixer", 1, 0, "Mixer");
QQmlApplicationEngine engine;
if (positionalArguments.length() == 2) {
@@ -68,6 +72,7 @@ int main(int argc, char *argv[])
context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
std::string token = secret.toStdString();
+#ifndef NATIVE_BUILD
LibHomeScreen* hs = new LibHomeScreen();
QLibWindowmanager* qwm = new QLibWindowmanager();
@@ -100,14 +105,30 @@ int main(int argc, char *argv[])
}
}
});
-
+#endif
engine.load(QUrl(QStringLiteral("qrc:/Mixer.qml")));
// Find the instantiated model QObject and connect the signals/slots
- QList<QObject *> mobjs = engine.rootObjects();
+ QList<QObject*> mobjs = engine.rootObjects();
+ if (mobjs.empty())
+ {
+ qDebug() << "[ERROR] Failed to load QML!";
+ return -1;
+ }
- QQuickWindow *window = qobject_cast<QQuickWindow *>(mobjs.first());
- QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface()));
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(mobjs.first());
+#ifdef NATIVE_BUILD
+ window->setFlags(window->flags() & ~Qt::FramelessWindowHint); // Remove the borderless flag
+ window->setHeight(QGuiApplication::primaryScreen()->geometry().height());
+#else
+ QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface()));
+#endif
}
+ else
+ {
+ qDebug() << "[ERROR] No port and token specified!";
+ return -1;
+ }
+
return app.exec();
}