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> 35 int main(
int argc,
char *argv[])
37 QGuiApplication app(argc, argv);
39 QCoreApplication::setOrganizationDomain(
"LinuxFoundation");
40 QCoreApplication::setOrganizationName(
"AutomotiveGradeLinux");
41 QCoreApplication::setApplicationName(
"OnScreenApp");
42 QCoreApplication::setApplicationVersion(
"0.1.0");
44 QQuickStyle::setStyle(
"AGL");
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();
52 QStringList positionalArguments = parser.positionalArguments();
57 if (positionalArguments.length() == 2) {
58 port = positionalArguments.takeFirst().toInt();
59 token = positionalArguments.takeFirst();
62 HMI_DEBUG(
"onscreenapp",
"port = %d, token = %s", port, token.toStdString().c_str());
65 eventHandler->init(port, token.toStdString().c_str());
67 QQmlApplicationEngine engine;
68 engine.rootContext()->setContextProperty(
"eventHandler", eventHandler);
69 engine.load(QUrl(QStringLiteral(
"qrc:/main.qml")));
70 if (engine.rootObjects().isEmpty()) {
74 QObject *root = engine.rootObjects().first();
75 QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
77 eventHandler->setQuickWindow(window);
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)));
101 QObject::connect(window, SIGNAL(frameSwapped()), eventHandler, SLOT(slotActivateSurface()));
#define HMI_DEBUG(prefix, args,...)
static EventHandler * eventHandler
int main(int argc, char *argv[])