diff options
author | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-11-14 13:01:56 +0900 |
---|---|---|
committer | zheng_wenlong <wenlong_zheng@nexty-ele.com> | 2018-11-14 13:01:56 +0900 |
commit | 36fe083c39bef0a17328f008d4935a562efa123b (patch) | |
tree | 2aeff4166711be57aa79cad0bf9b74f0468f5dd0 /demo3/vertical/restriction/app | |
parent | 990474de8e93bf295e2aa65610c5298c4faac364 (diff) |
Add restriction for vertical modeneedlefish_13.93.0needlefish/13.93.0marlin_12.93.0marlin_12.92.0marlin_12.91.0marlin_12.90.1marlin_12.90.0marlin/12.93.0marlin/12.92.0marlin/12.91.0marlin/12.90.1marlin/12.90.0lamprey_11.92.0lamprey_11.91.0lamprey/11.92.0lamprey/11.91.0koi_10.93.0koi_10.92.0koi_10.91.0koi/10.93.0koi/10.92.0koi/10.91.0jellyfish_9.99.4jellyfish_9.99.3jellyfish_9.99.2jellyfish_9.99.1jellyfish/9.99.4jellyfish/9.99.3jellyfish/9.99.2jellyfish/9.99.1icefish_8.99.5icefish_8.99.4icefish_8.99.3icefish_8.99.2icefish_8.99.1icefish/8.99.5icefish/8.99.4icefish/8.99.3icefish/8.99.2icefish/8.99.1halibut_8.0.6halibut_8.0.5halibut_8.0.4halibut_8.0.3halibut_8.0.2halibut_8.0.1halibut_8.0.0halibut_7.99.3halibut_7.99.2halibut_7.99.1halibut_7.90.0halibut/8.0.6halibut/8.0.5halibut/8.0.4halibut/8.0.3halibut/8.0.2halibut/8.0.1halibut/8.0.0halibut/7.99.3halibut/7.99.2halibut/7.99.1halibut/7.90.0guppy_6.99.4guppy_6.99.3guppy_6.99.2guppy_6.99.1guppy/6.99.4guppy/6.99.3guppy/6.99.2guppy/6.99.19.99.49.99.39.99.29.99.18.99.58.99.48.99.38.99.28.99.18.0.68.0.58.0.48.0.38.0.28.0.18.0.07.99.37.99.27.99.17.90.06.99.46.99.36.99.26.99.113.93.012.93.012.92.012.91.012.90.112.90.011.92.011.91.010.93.010.92.010.91.0halibut
This applciation is used to display restriction text,
When car is running and videoplayer is showing.
Change-Id: If8f287cd129638ccc0c87d03cc9dc7c53953f916
Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com>
Diffstat (limited to 'demo3/vertical/restriction/app')
-rw-r--r-- | demo3/vertical/restriction/app/app.pri | 13 | ||||
-rw-r--r-- | demo3/vertical/restriction/app/app.pro | 17 | ||||
-rw-r--r-- | demo3/vertical/restriction/app/images/black_normal.png | bin | 0 -> 9809 bytes | |||
-rw-r--r-- | demo3/vertical/restriction/app/images/black_split.png | bin | 0 -> 5011 bytes | |||
-rw-r--r-- | demo3/vertical/restriction/app/main.cpp | 107 | ||||
-rw-r--r-- | demo3/vertical/restriction/app/main.qml | 67 | ||||
-rw-r--r-- | demo3/vertical/restriction/app/main.qrc | 7 | ||||
-rw-r--r-- | demo3/vertical/restriction/app/pkg-config_wrapper.sh | 6 |
8 files changed, 217 insertions, 0 deletions
diff --git a/demo3/vertical/restriction/app/app.pri b/demo3/vertical/restriction/app/app.pri new file mode 100644 index 0000000..c3b1fd1 --- /dev/null +++ b/demo3/vertical/restriction/app/app.pri @@ -0,0 +1,13 @@ +TEMPLATE = app +QMAKE_LFLAGS += "-Wl,--hash-style=gnu -Wl,--as-needed" + +load(configure) +qtCompileTest(libhomescreen) + +config_libhomescreen { + CONFIG += link_pkgconfig + PKGCONFIG += homescreen + DEFINES += HAVE_LIBHOMESCREEN +} + +DESTDIR = $${OUT_PWD}/../package/root/bin diff --git a/demo3/vertical/restriction/app/app.pro b/demo3/vertical/restriction/app/app.pro new file mode 100644 index 0000000..22c9b00 --- /dev/null +++ b/demo3/vertical/restriction/app/app.pro @@ -0,0 +1,17 @@ +###################################################################### +# Automatically generated by qmake (3.1) Tue Apr 24 05:31:07 2018 +###################################################################### + +TARGET = restriction +INCLUDEPATH += . + +QT = quickcontrols2 + +CONFIG += link_pkgconfig +PKGCONFIG += libhomescreen qlibwindowmanager + +# Input +SOURCES += main.cpp +RESOURCES += main.qrc + +include(app.pri)
\ No newline at end of file diff --git a/demo3/vertical/restriction/app/images/black_normal.png b/demo3/vertical/restriction/app/images/black_normal.png Binary files differnew file mode 100644 index 0000000..378798a --- /dev/null +++ b/demo3/vertical/restriction/app/images/black_normal.png diff --git a/demo3/vertical/restriction/app/images/black_split.png b/demo3/vertical/restriction/app/images/black_split.png Binary files differnew file mode 100644 index 0000000..9ce95ed --- /dev/null +++ b/demo3/vertical/restriction/app/images/black_split.png diff --git a/demo3/vertical/restriction/app/main.cpp b/demo3/vertical/restriction/app/main.cpp new file mode 100644 index 0000000..92f1c5f --- /dev/null +++ b/demo3/vertical/restriction/app/main.cpp @@ -0,0 +1,107 @@ + +#include <QtQml/qqml.h> +#include <qlibwindowmanager.h> +#include <QQuickWindow> +#include <QtCore/QCommandLineParser> +#include <QtCore/QDebug> +#include <QtCore/QDir> +#include <QtCore/QStandardPaths> +#include <QtCore/QUrlQuery> +#include <QtGui/QGuiApplication> +#include <QtQml/QQmlApplicationEngine> +#include <QtQml/QQmlContext> +#include <QtQuickControls2/QQuickStyle> +#include <libhomescreen.hpp> + +int main(int argc, char* argv[]) { + QString role = QString("Restriction"); + + QGuiApplication app(argc, argv); + + QQuickStyle::setStyle("AGL"); + + QQmlApplicationEngine engine; + + QCommandLineParser parser; + parser.addPositionalArgument("port", + app.translate("main", "port for binding")); + parser.addPositionalArgument("secret", + app.translate("main", "secret for binding")); + parser.addHelpOption(); + parser.addVersionOption(); + parser.process(app); + QStringList positionalArguments = parser.positionalArguments(); + + if (positionalArguments.length() == 2) { + int port = positionalArguments.takeFirst().toInt(); + QString secret = positionalArguments.takeFirst(); + QUrl bindingAddress; + bindingAddress.setScheme(QStringLiteral("ws")); + bindingAddress.setHost(QStringLiteral("localhost")); + bindingAddress.setPort(port); + bindingAddress.setPath(QStringLiteral("/api")); + QUrlQuery query; + query.addQueryItem(QStringLiteral("token"), secret); + bindingAddress.setQuery(query); + + std::string token = secret.toStdString(); + LibHomeScreen* hs = new LibHomeScreen(); + QLibWindowmanager* qwm = new QLibWindowmanager(); + + if (qwm->init(port, secret) != 0) { + exit(EXIT_FAILURE); + } + // Request a surface as described in layers.json windowmanager’s file + if (qwm->requestSurface(role) != 0) { + exit(EXIT_FAILURE); + } + // Create an event callback against an event type. Here a lambda is + // called when SyncDraw event occurs + qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, + [qwm, role](json_object* object) { + fprintf(stderr, "Surface got syncDraw!\n"); + qwm->endDraw(role); + }); + + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + QObject* root = engine.rootObjects().first(); + + // HomeScreen + hs->init(port, token.c_str()); + + // release restriction + hs->set_event_handler( + LibHomeScreen::Event_ReleaseRestriction, + [qwm, role, root](json_object* object) { + json_object* areaJ = nullptr; + if (json_object_object_get_ex(object, "area", &areaJ)) { + QString area(QLatin1String(json_object_get_string(areaJ))); + + QMetaObject::invokeMethod(root, "hideImage"); + + // qwm->releaseWR(role, area); + qwm->deactivateSurface(role); + } + }); + + // allocate restriction + hs->set_event_handler( + LibHomeScreen::Event_AllocateRestriction, + [qwm, role, root](json_object* object) { + json_object* areaJ = nullptr; + if (json_object_object_get_ex(object, "area", &areaJ)) { + QString area(QLatin1String(json_object_get_string(areaJ))); + qDebug() + << "Surface got Event_AllocateRestriction " << area; + + QMetaObject::invokeMethod(root, "showImage", + Q_ARG(QVariant, area)); + + // qwm->allocateWR(role, area); + qwm->activateSurface(role, area.prepend("restriction.")); + } + }); + } + + return app.exec(); +}
\ No newline at end of file diff --git a/demo3/vertical/restriction/app/main.qml b/demo3/vertical/restriction/app/main.qml new file mode 100644 index 0000000..15369cf --- /dev/null +++ b/demo3/vertical/restriction/app/main.qml @@ -0,0 +1,67 @@ +import QtQuick 2.6 +import QtQuick.Controls 2.0 + +ApplicationWindow { + id: root + + color: "#00000000" + + Label { + id: message + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: 20 + font.pixelSize: 75 + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: "white" + text: "Only the video’s sound will be available while driving." + } + + background : Image { + id: backgroundImg + anchors.fill: parent + anchors.topMargin: 0 + anchors.bottomMargin: 0 + + visible: true + fillMode: Image.Stretch + source: 'images/black_normal.png' + + state: "begin" + states: [ + State { + name: "begin" + PropertyChanges { target: backgroundImg; opacity: 0.25 } + }, + State { + name: "end" + PropertyChanges { target: backgroundImg; opacity: 0.75 } + } + ] + + transitions: [ + Transition { + from: "begin"; to: "end" + PropertyAnimation {target: backgroundImg; properties: "opacity"; duration: 2000} + } + ] + } + + function showImage(area) { + if (area === 'normal') { + backgroundImg.source = 'images/black_normal.png' + } else { + backgroundImg.source = 'images/black_split.png' + } + backgroundImg.state = "end" + } + + + function hideImage() { + backgroundImg.state = "begin" + } +} diff --git a/demo3/vertical/restriction/app/main.qrc b/demo3/vertical/restriction/app/main.qrc new file mode 100644 index 0000000..c9f6449 --- /dev/null +++ b/demo3/vertical/restriction/app/main.qrc @@ -0,0 +1,7 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + <file>images/black_normal.png</file> + <file>images/black_split.png</file> + </qresource> +</RCC> diff --git a/demo3/vertical/restriction/app/pkg-config_wrapper.sh b/demo3/vertical/restriction/app/pkg-config_wrapper.sh new file mode 100644 index 0000000..02ed39b --- /dev/null +++ b/demo3/vertical/restriction/app/pkg-config_wrapper.sh @@ -0,0 +1,6 @@ +#!/bin/sh +PKG_CONFIG_SYSROOT_DIR=/opt/sdk/sysroots/aarch64-agl-linux +export PKG_CONFIG_SYSROOT_DIR +PKG_CONFIG_LIBDIR=/opt/sdk/sysroots/aarch64-agl-linux/usr/lib/pkgconfig:/opt/sdk/sysroots/aarch64-agl-linux/usr/share/pkgconfig +export PKG_CONFIG_LIBDIR +exec pkg-config "$@" |