Add beta version to sandbox
[apps/onscreenapp.git] / doc / api-ref / latex / df / d0a / main_8cpp.tex
1 \hypertarget{main_8cpp}{}\section{app/main.cpp File Reference}
2 \label{main_8cpp}\index{app/main.\+cpp@{app/main.\+cpp}}
3 {\ttfamily \#include $<$Q\+Gui\+Application$>$}\newline
4 {\ttfamily \#include $<$Q\+Command\+Line\+Parser$>$}\newline
5 {\ttfamily \#include $<$Qt\+Gui/\+Q\+Bitmap$>$}\newline
6 {\ttfamily \#include $<$Qt\+Gui/\+Q\+Gui\+Application$>$}\newline
7 {\ttfamily \#include $<$Qt\+Qml/\+Q\+Qml\+Application\+Engine$>$}\newline
8 {\ttfamily \#include $<$Qt\+Qml/\+Q\+Qml\+Context$>$}\newline
9 {\ttfamily \#include $<$Qt\+Qml/qqml.\+h$>$}\newline
10 {\ttfamily \#include $<$Q\+Quick\+Window$>$}\newline
11 {\ttfamily \#include $<$Qt\+Quick\+Controls2/\+Q\+Quick\+Style$>$}\newline
12 {\ttfamily \#include $<$Q\+Pixmap$>$}\newline
13 {\ttfamily \#include $<$Q\+Bitmap$>$}\newline
14 {\ttfamily \#include \char`\"{}eventhandler.\+h\char`\"{}}\newline
15 \subsection*{Functions}
16 \begin{DoxyCompactItemize}
17 \item 
18 int \hyperlink{main_8cpp_a0ddf1224851353fc92bfbff6f499fa97}{main} (int argc, char $\ast$argv\mbox{[}$\,$\mbox{]})
19 \end{DoxyCompactItemize}
20 \subsection*{Variables}
21 \begin{DoxyCompactItemize}
22 \item 
23 static \hyperlink{class_event_handler}{Event\+Handler} $\ast$ \hyperlink{main_8cpp_a4f7f516f792f108e8e99e3e23419db13}{event\+Handler}
24 \end{DoxyCompactItemize}
25
26
27 \subsection{Function Documentation}
28 \mbox{\Hypertarget{main_8cpp_a0ddf1224851353fc92bfbff6f499fa97}\label{main_8cpp_a0ddf1224851353fc92bfbff6f499fa97}} 
29 \index{main.\+cpp@{main.\+cpp}!main@{main}}
30 \index{main@{main}!main.\+cpp@{main.\+cpp}}
31 \subsubsection{\texorpdfstring{main()}{main()}}
32 {\footnotesize\ttfamily int main (\begin{DoxyParamCaption}\item[{int}]{argc,  }\item[{char $\ast$}]{argv\mbox{[}$\,$\mbox{]} }\end{DoxyParamCaption})}
33
34
35
36 Definition at line 35 of file main.\+cpp.
37
38
39 \begin{DoxyCode}
40 36 \{
41 37     QGuiApplication app(argc, argv);
42 38 
43 39     QCoreApplication::setOrganizationDomain(\textcolor{stringliteral}{"LinuxFoundation"});
44 40     QCoreApplication::setOrganizationName(\textcolor{stringliteral}{"AutomotiveGradeLinux"});
45 41     QCoreApplication::setApplicationName(\textcolor{stringliteral}{"OnScreenApp"});
46 42     QCoreApplication::setApplicationVersion(\textcolor{stringliteral}{"0.1.0"});
47 43 
48 44     QQuickStyle::setStyle(\textcolor{stringliteral}{"AGL"});
49 45 
50 46     QCommandLineParser parser;
51 47     parser.addPositionalArgument(\textcolor{stringliteral}{"port"}, app.translate(\textcolor{stringliteral}{"main"}, \textcolor{stringliteral}{"port for binding"}));
52 48     parser.addPositionalArgument(\textcolor{stringliteral}{"secret"}, app.translate(\textcolor{stringliteral}{"main"}, \textcolor{stringliteral}{"secret for binding"}));
53 49     parser.addHelpOption();
54 50     parser.addVersionOption();
55 51     parser.process(app);
56 52     QStringList positionalArguments = parser.positionalArguments();
57 53 
58 54     \textcolor{keywordtype}{int} port = 1700;
59 55     QString token = \textcolor{stringliteral}{"wm"};
60 56 
61 57     \textcolor{keywordflow}{if} (positionalArguments.length() == 2) \{
62 58         port = positionalArguments.takeFirst().toInt();
63 59         token = positionalArguments.takeFirst();
64 60     \}
65 61 
66 62     \hyperlink{hmi-debug_8h_a0d26d8b8201011dade787236519711c0}{HMI\_DEBUG}(\textcolor{stringliteral}{"onscreenapp"}, \textcolor{stringliteral}{"port = %d, token = %s"}, port, token.toStdString().c\_str());
67 63 
68 64     \hyperlink{main_8cpp_a4f7f516f792f108e8e99e3e23419db13}{eventHandler} = \textcolor{keyword}{new} \hyperlink{class_event_handler}{EventHandler}();
69 65     eventHandler->init(port, token.toStdString().c\_str());
70 66 
71 67     QQmlApplicationEngine engine;
72 68     engine.rootContext()->setContextProperty(\textcolor{stringliteral}{"eventHandler"}, eventHandler);
73 69     engine.load(QUrl(QStringLiteral(\textcolor{stringliteral}{"qrc:/main.qml"})));
74 70     \textcolor{keywordflow}{if} (engine.rootObjects().isEmpty()) \{
75 71         \textcolor{keywordflow}{return} -1;
76 72     \}
77 73 
78 74     QObject *root = engine.rootObjects().first();
79 75     QQuickWindow *window = qobject\_cast<QQuickWindow *>(root);
80 76 
81 77     eventHandler->setQuickWindow(window);
82 78 
83 79 \textcolor{comment}{//    QBitmap bitmap = QPixmap(":/images/HMI\_Phone\_Back.svg").createHeuristicMask();}
84 80 \textcolor{comment}{//    window->setMask(QRegion(bitmap));}
85 81 
86 82 \textcolor{comment}{//    QImage img(":/images/star.png");}
87 83 \textcolor{comment}{//    QPixmap pixmap = QPixmap::fromImage(img);}
88 84 \textcolor{comment}{//    QBitmap mask = pixmap.createHeuristicMask();}
89 85 
90 86 \textcolor{comment}{//    if (mask.hasAlphaChannel()) \{}
91 87 \textcolor{comment}{//        qDebug("has alpha");}
92 88 \textcolor{comment}{//    \}}
93 89 
94 90 \textcolor{comment}{//    window->setMask(QRegion(mask));}
95 91 
96 92 \textcolor{comment}{//    QBitmap bitmap = QPixmap(":/images/HMI\_Phone\_Back\_Heart.svg").createHeuristicMask();}
97 93 \textcolor{comment}{//    window->setMask(QRegion(bitmap));}
98 94 
99 95     QObject::connect(eventHandler, SIGNAL(signalOnScreenMessage(QVariant)), window, SLOT(qmlOnScreenMessage
100       (QVariant)));
101 96     QObject::connect(eventHandler, SIGNAL(signalLoader(QVariant)), window, SLOT(qmlLoader(QVariant)));
102 97     QObject::connect(eventHandler, SIGNAL(signalSetClearBackgroud()), window, SLOT(qmlSetClearBackgroud()))
103       ;
104 98     QObject::connect(eventHandler, SIGNAL(signalSetDefaultBackgroud(QVariant)), window, SLOT(
105       qmlSetDefaultBackground(QVariant)));
106 99 
107 100 \textcolor{preprocessor}{#if USE\_TEST\_DISPLAY}
108 101     QObject::connect(window, SIGNAL(frameSwapped()), eventHandler, SLOT(slotActivateSurface()));
109 102 \textcolor{preprocessor}{#endif}
110 103     \hyperlink{hmi-debug_8h_a0d26d8b8201011dade787236519711c0}{HMI\_DEBUG}(\textcolor{stringliteral}{"onscreenapp"}, \textcolor{stringliteral}{"Launched!"});
111 104 
112 105     \textcolor{keywordflow}{return} app.exec();
113 106 \}
114 \end{DoxyCode}
115
116
117 \subsection{Variable Documentation}
118 \mbox{\Hypertarget{main_8cpp_a4f7f516f792f108e8e99e3e23419db13}\label{main_8cpp_a4f7f516f792f108e8e99e3e23419db13}} 
119 \index{main.\+cpp@{main.\+cpp}!event\+Handler@{event\+Handler}}
120 \index{event\+Handler@{event\+Handler}!main.\+cpp@{main.\+cpp}}
121 \subsubsection{\texorpdfstring{event\+Handler}{eventHandler}}
122 {\footnotesize\ttfamily \hyperlink{class_event_handler}{Event\+Handler}$\ast$ event\+Handler\hspace{0.3cm}{\ttfamily [static]}}
123
124
125
126 Definition at line 33 of file main.\+cpp.
127