2 * Copyright (C) 2016 The Qt Company Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <QtCore/QDebug>
18 #include <QtCore/QCommandLineParser>
19 #include <QtCore/QUrlQuery>
20 #include <QtGui/QGuiApplication>
21 #include <QtQml/QQmlApplicationEngine>
22 #include <QtQml/QQmlContext>
23 #include <QtQuickControls2/QQuickStyle>
25 #ifdef HAVE_LIBHOMESCREEN
26 #include <libhomescreen.hpp>
29 int main(int argc, char *argv[])
31 #ifdef HAVE_LIBHOMESCREEN
32 LibHomeScreen libHomeScreen;
34 if (!libHomeScreen.renderAppToAreaAllowed(0, 1)) {
35 qWarning() << "renderAppToAreaAllowed is denied";
40 QGuiApplication app(argc, argv);
41 app.setApplicationName(QStringLiteral("HVAC"));
42 app.setApplicationVersion(QStringLiteral("0.1.0"));
43 app.setOrganizationDomain(QStringLiteral("automotivelinux.org"));
44 app.setOrganizationName(QStringLiteral("AutomotiveGradeLinux"));
46 QQuickStyle::setStyle("AGL");
48 QCommandLineParser parser;
49 parser.addPositionalArgument("port", app.translate("main", "port for binding"));
50 parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
51 parser.addHelpOption();
52 parser.addVersionOption();
54 QStringList positionalArguments = parser.positionalArguments();
57 QQmlApplicationEngine engine;
58 if (positionalArguments.length() == 2) {
59 int port = positionalArguments.takeFirst().toInt();
60 QString secret = positionalArguments.takeFirst();
62 bindingAddress.setScheme(QStringLiteral("ws"));
63 bindingAddress.setHost(QStringLiteral("localhost"));
64 bindingAddress.setPort(port);
65 bindingAddress.setPath(QStringLiteral("/api"));
67 query.addQueryItem(QStringLiteral("token"), secret);
68 bindingAddress.setQuery(query);
69 QQmlContext *context = engine.rootContext();
70 context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
72 engine.load(QUrl(QStringLiteral("qrc:/HVAC.qml")));