* limitations under the License.
*/
-#include <QUrlQuery>
#include <QQmlContext>
-#include <QtCore/QDebug>
#include <QtCore/QCommandLineParser>
-#include <QtCore/QUrlQuery>
#include <QtGui/QGuiApplication>
#include <QtQml/QQmlContext>
#include <QtQml/QQmlApplicationEngine>
#include "eventhandler.h"
-static EventHandler* eventHandler;
int main(int argc, char *argv[])
{
app.setOrganizationDomain(QStringLiteral("automotivelinux.org"));
app.setOrganizationName(QStringLiteral("AutomotiveGradeLinux"));
- //QQuickStyle::setStyle("AGL");
+ QQuickStyle::setStyle("AGL");
QCommandLineParser parser;
parser.addPositionalArgument("port", app.translate("main", "port for binding"));
QStringList positionalArguments = parser.positionalArguments();
QQmlApplicationEngine engine;
- QQmlContext *context = engine.rootContext();
- QUrl bindingAddress;
int port = 0;
QString secret;
if (positionalArguments.length() == 2) {
port = positionalArguments.takeFirst().toInt();
secret = positionalArguments.takeFirst();
- bindingAddress.setScheme(QStringLiteral("ws"));
- bindingAddress.setHost(QStringLiteral("localhost"));
- bindingAddress.setPort(port);
- bindingAddress.setPath(QStringLiteral("/api"));
- QUrlQuery query;
- query.addQueryItem(QStringLiteral("token"), secret);
- bindingAddress.setQuery(query);
- context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
- } else {
- context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
}
- eventHandler = new EventHandler();
+ EventHandler *eventHandler = new EventHandler();
eventHandler->init(port, secret.toStdString().c_str());
engine.rootContext()->setContextProperty("eventHandler", eventHandler);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ if (engine.rootObjects().isEmpty()) {
+ HMI_DEBUG(APP_ID, "Fatal Error, rootObject is empty!");
+ return -1;
+ }
+
QObject *root = engine.rootObjects().first();
QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
-
QObject::connect(eventHandler, SIGNAL(signalOnReplyShowWindow(QVariant)), window, SLOT(qmlOnReplyShowWindow(QVariant)));
eventHandler->setQuickWindow(window);