From 5b530ac0e2ec4abe54a2c64274b36b480ed13e25 Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Wed, 21 Nov 2018 11:05:40 +0900 Subject: change camera size --- app/CameraControl.qml | 35 ++++++++++++++++++++++++++++++++--- app/app.pro | 2 +- app/main.cpp | 13 ++----------- app/main.qml | 26 ++++++++++++++------------ package/config.xml | 6 +++--- package/package.pro | 2 +- sample/camapp_git.bb | 21 --------------------- sample/camera_git.bb | 18 ++++++++++++++++++ 8 files changed, 71 insertions(+), 52 deletions(-) delete mode 100644 sample/camapp_git.bb create mode 100644 sample/camera_git.bb diff --git a/app/CameraControl.qml b/app/CameraControl.qml index 4e0b94d..eb9b6af 100644 --- a/app/CameraControl.qml +++ b/app/CameraControl.qml @@ -20,10 +20,10 @@ import QtQuick.Controls 2.0 RowLayout { property var device - property var listWH + property var ratio: 4/3 property var number: [] property var fps: ["10", "20", "30", "40", "50", "60"] - property var resolution: listWH ? ["320*240", "640*480", "1280*720", "1920*1080"] : ["320*240"] + property var resolution: ["320*240", "640*480", "1280*720", "1920*1080"] property var models: [number, fps, resolution] property real back: 1 property bool switchstatus: true @@ -31,7 +31,7 @@ RowLayout { Repeater { id: info - model: ["No.:", "FPS:", "W*H:"] + model: ["No:", "FPS:", "W*H:"] delegate: RowLayout{ Label { id: label @@ -107,6 +107,29 @@ RowLayout { } background: Image { source: "images/camera/camerainfo_bg.svg" } + onCurrentIndexChanged: + if(cameraswitch.checked && device){ + var dNo = info.itemAt(0).children[1].currentText + var dFps = info.itemAt(1).children[1].currentText + var dRes = info.itemAt(2).children[1].currentText + if (index === 0){ + dNo = number[listview.currentIndex] + } + if (index === 1){ + dFps = fps[listview.currentIndex] + } + if (index === 2){ + dRes = resolution[listview.currentIndex] + if(listview.currentIndex === 0 || listview.currentIndex === 1){ + ratio = 4/3 + } + else{ + ratio = 16/9 + } + } + device.stop() + device.start(dNo, dFps, dRes) + } } } } @@ -115,6 +138,12 @@ RowLayout { enabled: switchstatus checked: switchChecked onCheckedChanged: { + if (info.itemAt(2).children[1].currentText === "320*240" || info.itemAt(2).children[1].currentText === "640*480"){ + ratio = 4/3 + } + else{ + ratio = 16/9 + } if (checked && device){ device.start(info.itemAt(0).children[1].currentText, info.itemAt(1).children[1].currentText, info.itemAt(2).children[1].currentText) }else if (!checked && device){ diff --git a/app/app.pro b/app/app.pro index b9d7bc5..8dfa093 100644 --- a/app/app.pro +++ b/app/app.pro @@ -1,4 +1,4 @@ -TARGET = camapp +TARGET = camera QT = quickcontrols2 equals(QT_ARCH, "arm") { diff --git a/app/main.cpp b/app/main.cpp index 6fd928d..c92f251 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) { - QString myname = QString("camapp"); + QString myname = QString("camera"); QGuiApplication app(argc, argv); app.setApplicationName(myname); @@ -101,16 +101,7 @@ int main(int argc, char *argv[]) hs->init(port, token.c_str()); // Set the event handler for Event_TapShortcut which will activate the surface for windowmanager hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [qwm, myname](json_object *object){ - json_object *appnameJ = nullptr; - if(json_object_object_get_ex(object, "application_name", &appnameJ)) - { - const char *appname = json_object_get_string(appnameJ); - if(QString::compare(myname, appname, Qt::CaseInsensitive) == 0) - { - qDebug("Surface %s got tapShortcut\n", appname); - qwm->activateSurface(myname); - } - } + qwm->activateSurface(myname); }); #endif engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); diff --git a/app/main.qml b/app/main.qml index 9710c99..0641efe 100644 --- a/app/main.qml +++ b/app/main.qml @@ -26,19 +26,12 @@ ApplicationWindow { width: 1920 height: 720 - CameraControl { - id:cameracontrol - listWH: true - device: camdev_device - width: root.width - height:80 - } - Camera { id: camdev_device - width: root.width - height: root.height - cameracontrol.height - anchors.top: cameracontrol.bottom + anchors.horizontalCenter: parent.horizontalCenter + width: height * cameracontrol.ratio + height: root.height + anchors.top: parent.top onIsrunningChanged: { camerabg.visible = !isrunning } @@ -52,8 +45,17 @@ ApplicationWindow { } } + CameraControl { + id:cameracontrol + anchors.horizontalCenter: parent.horizontalCenter + ratio: 4/3 + device: camdev_device + width: camdev_device.width + height:80 + } + function changeVisible(visible) { - console.log("camapp visible is " + visible) + console.log("camera visible is " + visible) cameracontrol.switchChecked = visible } } diff --git a/package/config.xml b/package/config.xml index 6582fda..7be9cda 100644 --- a/package/config.xml +++ b/package/config.xml @@ -1,8 +1,8 @@ - - camapp + + camera - + This is a demo application TOYOTA APL 2.0 diff --git a/package/package.pro b/package/package.pro index d826c11..93c356b 100644 --- a/package/package.pro +++ b/package/package.pro @@ -14,6 +14,6 @@ QMAKE_EXTRA_TARGETS += copy_config PRE_TARGETDEPS += $$copy_config.target wgt.target = package -wgt.commands = wgtpkg-pack -f -o camapp.wgt root +wgt.commands = wgtpkg-pack -f -o camera.wgt root QMAKE_EXTRA_TARGETS += wgt diff --git a/sample/camapp_git.bb b/sample/camapp_git.bb deleted file mode 100644 index 6dffeab..0000000 --- a/sample/camapp_git.bb +++ /dev/null @@ -1,21 +0,0 @@ -SUMMARY = "Demo app for streeting-wheel" -DESCRIPTION = "AGL demo app for streeting-wheel" -HOMEPAGE = "https://gerrit.automotivelinux.org/gerrit/#/admin/projects/apps/als-meter-demo" -SECTION = "apps" - -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://LICENSE;md5=ae6497158920d9524cf208c09cc4c984" - -SRC_URI = "git://gerrit.automotivelinux.org/gerrit/apps/als-meter-demo;protocol=https;branch=master" -SRCREV = "9457d3ebf0fd63f63f5d8abdd570868c0298a92f" - -PV = "1.0+git${SRCPV}" -S = "${WORKDIR}/git" - -# build-time dependencies -DEPENDS += "qtquickcontrols2 opencv" - -# runtime dependencies -RDEPENDS_${PN} += "agl-service-steering-wheel" - -inherit qmake5 aglwgt diff --git a/sample/camera_git.bb b/sample/camera_git.bb new file mode 100644 index 0000000..89f6e2a --- /dev/null +++ b/sample/camera_git.bb @@ -0,0 +1,18 @@ +SUMMARY = "Demo app for streeting-wheel" +DESCRIPTION = "AGL demo app for streeting-wheel" +HOMEPAGE = "https://gerrit.automotivelinux.org/gerrit/#/admin/projects/apps/als-meter-demo" +SECTION = "apps" + +LICENSE = "Apache-2.0" +LIC_FILES_CHKSUM = "file://LICENSE;md5=ae6497158920d9524cf208c09cc4c984" + +SRC_URI = "git://gerrit.automotivelinux.org/gerrit/apps/als-meter-demo;protocol=https;branch=sandbox/zheng_wenlong/camapp" +SRCREV = "${AUTOREV}" + +PV = "1.0+git${SRCPV}" +S = "${WORKDIR}/git" + +# build-time dependencies +DEPENDS += "qtquickcontrols2 opencv" + +inherit qmake5 aglwgt -- cgit 1.2.3-korg