X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=doc%2Fapi-ref%2Fhtml%2Fdf%2Fd0a%2Fmain_8cpp_source.html;fp=doc%2Fapi-ref%2Fhtml%2Fdf%2Fd0a%2Fmain_8cpp_source.html;h=17a23232f99b24ca6fc1d5de971af579476dd106;hb=b2670af592e664ed304f7df77d84f1964f039636;hp=0000000000000000000000000000000000000000;hpb=ec044f44133cad1d12311345437b13b1a953226e;p=apps%2Fonscreenapp.git diff --git a/doc/api-ref/html/df/d0a/main_8cpp_source.html b/doc/api-ref/html/df/d0a/main_8cpp_source.html new file mode 100644 index 0000000..17a2323 --- /dev/null +++ b/doc/api-ref/html/df/d0a/main_8cpp_source.html @@ -0,0 +1,83 @@ + + + + + + + +OnScreenApp: app/main.cpp Source File + + + + + + + + + +
+
+ + + + + + +
+
OnScreenApp +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
main.cpp
+
+
+Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 #include <QGuiApplication>
18 #include <QCommandLineParser>
19 #include <QtGui/QBitmap>
20 #include <QtGui/QGuiApplication>
21 #include <QtQml/QQmlApplicationEngine>
22 #include <QtQml/QQmlContext>
23 #include <QtQml/qqml.h>
24 #include <QQuickWindow>
25 #include <QtQuickControls2/QQuickStyle>
26 #include <QPixmap>
27 #include <QBitmap>
28 
29 #include "eventhandler.h"
30 
31 using namespace std;
32 
34 
35 int main(int argc, char *argv[])
36 {
37  QGuiApplication app(argc, argv);
38 
39  QCoreApplication::setOrganizationDomain("LinuxFoundation");
40  QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
41  QCoreApplication::setApplicationName("OnScreenApp");
42  QCoreApplication::setApplicationVersion("0.1.0");
43 
44  QQuickStyle::setStyle("AGL");
45 
46  QCommandLineParser parser;
47  parser.addPositionalArgument("port", app.translate("main", "port for binding"));
48  parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
49  parser.addHelpOption();
50  parser.addVersionOption();
51  parser.process(app);
52  QStringList positionalArguments = parser.positionalArguments();
53 
54  int port = 1700;
55  QString token = "wm";
56 
57  if (positionalArguments.length() == 2) {
58  port = positionalArguments.takeFirst().toInt();
59  token = positionalArguments.takeFirst();
60  }
61 
62  HMI_DEBUG("onscreenapp", "port = %d, token = %s", port, token.toStdString().c_str());
63 
64  eventHandler = new EventHandler();
65  eventHandler->init(port, token.toStdString().c_str());
66 
67  QQmlApplicationEngine engine;
68  engine.rootContext()->setContextProperty("eventHandler", eventHandler);
69  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
70  if (engine.rootObjects().isEmpty()) {
71  return -1;
72  }
73 
74  QObject *root = engine.rootObjects().first();
75  QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
76 
77  eventHandler->setQuickWindow(window);
78 
79 // QBitmap bitmap = QPixmap(":/images/HMI_Phone_Back.svg").createHeuristicMask();
80 // window->setMask(QRegion(bitmap));
81 
82 // QImage img(":/images/star.png");
83 // QPixmap pixmap = QPixmap::fromImage(img);
84 // QBitmap mask = pixmap.createHeuristicMask();
85 
86 // if (mask.hasAlphaChannel()) {
87 // qDebug("has alpha");
88 // }
89 
90 // window->setMask(QRegion(mask));
91 
92 // QBitmap bitmap = QPixmap(":/images/HMI_Phone_Back_Heart.svg").createHeuristicMask();
93 // window->setMask(QRegion(bitmap));
94 
95  QObject::connect(eventHandler, SIGNAL(signalOnScreenMessage(QVariant)), window, SLOT(qmlOnScreenMessage(QVariant)));
96  QObject::connect(eventHandler, SIGNAL(signalLoader(QVariant)), window, SLOT(qmlLoader(QVariant)));
97  QObject::connect(eventHandler, SIGNAL(signalSetClearBackgroud()), window, SLOT(qmlSetClearBackgroud()));
98  QObject::connect(eventHandler, SIGNAL(signalSetDefaultBackgroud(QVariant)), window, SLOT(qmlSetDefaultBackground(QVariant)));
99 
100 #if USE_TEST_DISPLAY
101  QObject::connect(window, SIGNAL(frameSwapped()), eventHandler, SLOT(slotActivateSurface()));
102 #endif
103  HMI_DEBUG("onscreenapp", "Launched!");
104 
105  return app.exec();
106 }
107 
#define HMI_DEBUG(prefix, args,...)
Definition: hmi-debug.h:42
+ +
static EventHandler * eventHandler
Definition: main.cpp:33
+ + +
int main(int argc, char *argv[])
Definition: main.cpp:35
+
+ + + +