diff options
-rw-r--r-- | src/aglextras/aglextras.pro | 2 | ||||
-rw-r--r-- | src/aglextras/configure.json | 16 | ||||
-rw-r--r-- | src/aglextras/hmi/aglapplication.cpp | 67 | ||||
-rw-r--r-- | src/aglextras/hmi/aglapplication.h | 6 | ||||
-rw-r--r-- | src/aglextras/hmi/aglapplication_p.h | 15 |
5 files changed, 62 insertions, 44 deletions
diff --git a/src/aglextras/aglextras.pro b/src/aglextras/aglextras.pro index 24028a9..8811e2a 100644 --- a/src/aglextras/aglextras.pro +++ b/src/aglextras/aglextras.pro @@ -1,7 +1,7 @@ TARGET = QtAGLExtras QT += quick -QT += core-private +QT += gui-private include(hmi/hmi.pri) diff --git a/src/aglextras/configure.json b/src/aglextras/configure.json index 513c237..a3d4511 100644 --- a/src/aglextras/configure.json +++ b/src/aglextras/configure.json @@ -31,6 +31,14 @@ } }, + "tests": { + "wgtpkg-pack": { + "label": "wgtpkg-pack", + "type": "files", + "files": [ "wgtpkg-pack" ] + } + }, + "features": { "libhomescreen": { "label": "LibHomeScreen", @@ -46,6 +54,11 @@ "label": "AGL HMI Framework", "condition": "features.libhomescreen && features.libwindowmanager", "output": [ "feature", "privateFeature" ] + }, + "wgtpkg-pack": { + "label": "wgtpkg-pack", + "condition": "tests.wgtpkg-pack", + "output": [ "feature", "publicFeature" ] } }, @@ -58,7 +71,8 @@ "entries": [ "libhomescreen", "libwindowmanager", - "agl_hmi_framework" + "agl_hmi_framework", + "wgtpkg-pack" ] } ] diff --git a/src/aglextras/hmi/aglapplication.cpp b/src/aglextras/hmi/aglapplication.cpp index 986448a..112e110 100644 --- a/src/aglextras/hmi/aglapplication.cpp +++ b/src/aglextras/hmi/aglapplication.cpp @@ -28,9 +28,9 @@ QT_BEGIN_NAMESPACE -AGLApplicationPrivate::AGLApplicationPrivate (AGLApplication *app) - : binding_address(new QUrl) - , engine(new QQmlApplicationEngine(app)) +AGLApplicationPrivate::AGLApplicationPrivate (int &argc, char **argv, int flags) + : QGuiApplicationPrivate (argc, argv, flags) + , engine(nullptr) { ; } @@ -40,14 +40,18 @@ AGLApplicationPrivate::~AGLApplicationPrivate (void) ; } -AGLApplication::AGLApplication (int& argc, char** argv) - : QGuiApplication(argc, argv), - d_ptr(new AGLApplicationPrivate(this)) +AGLApplication::AGLApplication (int& argc, char** argv, int _internal) + : QGuiApplication(*new AGLApplicationPrivate(argc, argv, _internal)) { + Q_D(AGLApplication); + d->init(); + setApplicationVersion(QStringLiteral("4.99.5")); setOrganizationDomain(QStringLiteral("automotivelinux.org")); setOrganizationName(QStringLiteral("AutomotiveGradeLinux")); + d->engine = new QQmlApplicationEngine(this); + QCommandLineParser parser; parser.addPositionalArgument(QLatin1String("port"), translate("main", "port for binding")); @@ -58,41 +62,36 @@ AGLApplication::AGLApplication (int& argc, char** argv) parser.process(*this); QStringList positionalArguments = parser.positionalArguments(); - if (positionalArguments.length() < 2) { - return; - } - - d_ptr->port = positionalArguments.takeFirst().toInt(); - d_ptr->secret = positionalArguments.takeFirst(); - - d_ptr->binding_address->setScheme(QStringLiteral("ws")); - d_ptr->binding_address->setHost(QStringLiteral("localhost")); - d_ptr->binding_address->setPort(d_ptr->port); - d_ptr->binding_address->setPath(QStringLiteral("/api")); + if (positionalArguments.length() == 2) { + d->port = positionalArguments.takeFirst().toInt(); + d->secret = positionalArguments.takeFirst(); - QUrlQuery query; - query.addQueryItem(QStringLiteral("token"), d_ptr->secret); - d_ptr->binding_address->setQuery(query); + d->binding_address.setScheme(QStringLiteral("ws")); + d->binding_address.setHost(QStringLiteral("localhost")); + d->binding_address.setPort(d->port); + d->binding_address.setPath(QStringLiteral("/api")); - if (!d_ptr->engine) { - qDebug("Cannot initialize QML Engine"); - exit(EXIT_FAILURE); + QUrlQuery query; + query.addQueryItem(QStringLiteral("token"), d->secret); + d->binding_address.setQuery(query); } - d_ptr->engine->rootContext()->setContextProperty(QStringLiteral("bindingAddress"), - *d_ptr->binding_address); + d->engine->rootContext()->setContextProperty(QStringLiteral("bindingAddress"), + d->binding_address); } void AGLApplication::load (const QUrl &url) { - d_ptr->engine->load(url); + Q_D(AGLApplication); + d->engine->load(url); } void AGLApplication::load (const QString &filePath) { - d_ptr->engine->load(filePath); + Q_D(AGLApplication); + d->engine->load(filePath); } QQmlApplicationEngine* @@ -103,18 +102,20 @@ AGLApplication::getQmlApplicationEngine() const { int AGLApplication::exec (void) { - if (d_ptr->wmclient) { - d_ptr->wmclient->attach(d_ptr->engine); + Q_D(AGLApplication); + if (d->wmclient) { + d->wmclient->attach(d->engine); } return QGuiApplication::exec(); } void AGLApplication::setupApplicationRole (const QString &role) { - d_ptr->wmclient = new AGLWmClient(role, d_ptr->port, d_ptr->secret); - d_ptr->screen_info = new AGLScreenInfo(this, d_ptr->wmclient->get_scale_factor()); - d_ptr->engine->rootContext()->setContextProperty(QStringLiteral("screenInfo"), - d_ptr->screen_info); + Q_D(AGLApplication); + d->wmclient = new AGLWmClient(role, d->port, d->secret); + d->screen_info = new AGLScreenInfo(this, d->wmclient->get_scale_factor()); + d->engine->rootContext()->setContextProperty(QStringLiteral("screenInfo"), + d->screen_info); } QT_END_NAMESPACE diff --git a/src/aglextras/hmi/aglapplication.h b/src/aglextras/hmi/aglapplication.h index 9c08972..fbc031c 100644 --- a/src/aglextras/hmi/aglapplication.h +++ b/src/aglextras/hmi/aglapplication.h @@ -33,7 +33,7 @@ class AGLEXTRAS_EXPORT AGLApplication : public QGuiApplication Q_OBJECT public: - AGLApplication (int& argc, char** argv); + AGLApplication (int& argc, char** argv, int = ApplicationFlags); void setupApplicationRole(const QString& role); @@ -45,8 +45,8 @@ public: int exec (void); private: - friend class AGLApplicationPrivate; - QSharedPointer<AGLApplicationPrivate> d_ptr; + Q_DISABLE_COPY(AGLApplication) + Q_DECLARE_PRIVATE(AGLApplication) }; class AGLScreenInfo : public QObject diff --git a/src/aglextras/hmi/aglapplication_p.h b/src/aglextras/hmi/aglapplication_p.h index 6cc1880..84859bd 100644 --- a/src/aglextras/hmi/aglapplication_p.h +++ b/src/aglextras/hmi/aglapplication_p.h @@ -18,26 +18,29 @@ #ifndef AGLAPPLICATION_P_H #define AGLAPPLICATION_P_H +#include "private/qguiapplication_p.h" +#include "aglapplication.h" +#include <QtCore/QUrl> + QT_BEGIN_NAMESPACE -class QUrl; + class QQmlApplicationEngine; class AGLWmClient; -class AGLApplication; class AGLScreenInfo; -class AGLApplicationPrivate +class AGLApplicationPrivate : public QGuiApplicationPrivate { + Q_DECLARE_PUBLIC(AGLApplication) public: - explicit AGLApplicationPrivate (AGLApplication *app); + explicit AGLApplicationPrivate (int &argc, char **argv, int flags); ~AGLApplicationPrivate (void); private: int port = -1; QString secret; - QUrl* binding_address; + QUrl binding_address; QQmlApplicationEngine *engine; AGLWmClient* wmclient; AGLScreenInfo* screen_info; - friend class AGLApplication; }; QT_END_NAMESPACE |