From aa20a65e8c819be90b00628a424bfad697136d7f Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Thu, 7 Sep 2017 11:09:21 +0900 Subject: Add als-meter-demo Add new application what we showed in als2017. Run in renesas m3ulcb, show camera video by logitech cr920. Display someinformation get from agl-service-steering-wheel as a meter. Already do some test on Daring Dab 4.0.0. [PatchSet2] Add [QMAKE_CXXFLAGS += -mfp16-format=ieee] for raspberrypi3 build error. [PatchSet3] Add determine statements in app.pro for raspberrypi3. Change-Id: I68f44eac6533567055e1c20d0b5f929242c2f082 Signed-off-by: zheng_wenlong --- app/Als-meter-demo.qml | 290 +++++ app/CameraControl.qml | 136 +++ app/Mid.qml | 34 + app/MidOther.qml | 36 + app/Shift.qml | 51 + app/Speed.qml | 92 ++ app/Tacho.qml | 101 ++ app/als-meter-demo.qrc | 11 + app/app.pri | 12 + app/app.pro | 22 + app/camera.cpp | 139 +++ app/camera.h | 71 ++ app/config.tests/libhomescreen/libhomescreen.cpp | 8 + app/config.tests/libhomescreen/libhomescreen.pro | 5 + app/images/camera/camera_bg.svg | 484 ++++++++ app/images/camera/camerainfo_bg.svg | 93 ++ app/images/homescreen/homebg_bottom.svg | 1397 ++++++++++++++++++++++ app/images/images.qrc | 39 + app/images/meters/speed_0.svg | 102 ++ app/images/meters/speed_1.svg | 62 + app/images/meters/speed_2.svg | 94 ++ app/images/meters/speed_3.svg | 138 +++ app/images/meters/speed_4.svg | 78 ++ app/images/meters/speed_5.svg | 104 ++ app/images/meters/speed_6.svg | 119 ++ app/images/meters/speed_7.svg | 102 ++ app/images/meters/speed_8.svg | 164 +++ app/images/meters/speed_9.svg | 143 +++ app/images/meters/speed_center.svg | 391 ++++++ app/images/meters/speed_kmh.svg | 101 ++ app/images/meters/speed_limit_none.svg | 156 +++ app/images/meters/tacho_center.svg | 246 ++++ app/images/meters/tacho_frame.svg | 213 ++++ app/images/meters/tacho_hand.svg | 189 +++ app/images/meters/tacho_scale.svg | 876 ++++++++++++++ app/images/meters/tacho_shift_1.svg | 46 + app/images/meters/tacho_shift_2.svg | 63 + app/images/meters/tacho_shift_3.svg | 69 ++ app/images/meters/tacho_shift_4.svg | 56 + app/images/meters/tacho_shift_5.svg | 67 ++ app/images/meters/tacho_shift_6.svg | 72 ++ app/images/meters/tacho_shift_B.svg | 82 ++ app/images/meters/tacho_shift_D.svg | 67 ++ app/images/meters/tacho_shift_N.svg | 66 + app/images/meters/tacho_shift_P.svg | 88 ++ app/images/meters/tacho_shift_R.svg | 70 ++ app/images/mid/mid_S_normal.svg | 1171 ++++++++++++++++++ app/images/mid/mid_other.svg | 123 ++ app/images/mid/recirc_inter.svg | 339 ++++++ app/images/mid/recirc_outer.svg | 339 ++++++ app/main.cpp | 144 +++ 51 files changed, 9161 insertions(+) create mode 100644 app/Als-meter-demo.qml create mode 100644 app/CameraControl.qml create mode 100644 app/Mid.qml create mode 100644 app/MidOther.qml create mode 100644 app/Shift.qml create mode 100644 app/Speed.qml create mode 100644 app/Tacho.qml create mode 100644 app/als-meter-demo.qrc create mode 100644 app/app.pri create mode 100644 app/app.pro create mode 100644 app/camera.cpp create mode 100644 app/camera.h create mode 100644 app/config.tests/libhomescreen/libhomescreen.cpp create mode 100644 app/config.tests/libhomescreen/libhomescreen.pro create mode 100644 app/images/camera/camera_bg.svg create mode 100644 app/images/camera/camerainfo_bg.svg create mode 100644 app/images/homescreen/homebg_bottom.svg create mode 100644 app/images/images.qrc create mode 100644 app/images/meters/speed_0.svg create mode 100644 app/images/meters/speed_1.svg create mode 100644 app/images/meters/speed_2.svg create mode 100644 app/images/meters/speed_3.svg create mode 100644 app/images/meters/speed_4.svg create mode 100644 app/images/meters/speed_5.svg create mode 100644 app/images/meters/speed_6.svg create mode 100644 app/images/meters/speed_7.svg create mode 100644 app/images/meters/speed_8.svg create mode 100644 app/images/meters/speed_9.svg create mode 100644 app/images/meters/speed_center.svg create mode 100644 app/images/meters/speed_kmh.svg create mode 100644 app/images/meters/speed_limit_none.svg create mode 100644 app/images/meters/tacho_center.svg create mode 100644 app/images/meters/tacho_frame.svg create mode 100644 app/images/meters/tacho_hand.svg create mode 100644 app/images/meters/tacho_scale.svg create mode 100644 app/images/meters/tacho_shift_1.svg create mode 100644 app/images/meters/tacho_shift_2.svg create mode 100644 app/images/meters/tacho_shift_3.svg create mode 100644 app/images/meters/tacho_shift_4.svg create mode 100644 app/images/meters/tacho_shift_5.svg create mode 100644 app/images/meters/tacho_shift_6.svg create mode 100644 app/images/meters/tacho_shift_B.svg create mode 100644 app/images/meters/tacho_shift_D.svg create mode 100644 app/images/meters/tacho_shift_N.svg create mode 100644 app/images/meters/tacho_shift_P.svg create mode 100644 app/images/meters/tacho_shift_R.svg create mode 100644 app/images/mid/mid_S_normal.svg create mode 100644 app/images/mid/mid_other.svg create mode 100644 app/images/mid/recirc_inter.svg create mode 100644 app/images/mid/recirc_outer.svg create mode 100644 app/main.cpp (limited to 'app') diff --git a/app/Als-meter-demo.qml b/app/Als-meter-demo.qml new file mode 100644 index 0000000..4549704 --- /dev/null +++ b/app/Als-meter-demo.qml @@ -0,0 +1,290 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.0 +import QtQuick.Window 2.2 +import Camera 1.0 +import QtWebSockets 1.0 + +ApplicationWindow { + id: root + width: 1080 + height: 1487 + + property string als_meter_demo_request_str: "" + property string api_str: "steering-wheel" + property var msgid_enu: { "call":2, "retok":3, "reterr":4, "event":5 } + property int recirc:0 + property int vehiclespeed: 0 + property real enginespeed: 0 + property int wshift: 0 + + WebSocket { + id: websocket + url: bindingAddressWS + + onStatusChanged: { + if (websocket.status === WebSocket.Error){ + console.log ("Error: " + websocket.errorString) + websocket.active = false + countdown.start() + }else if (websocket.status === WebSocket.Open){ + console.log ("Socket Open") + do_subscribe() + }else if (websocket.status === WebSocket.Closed){ + console.log ("Socket closed") + } + } + + onTextMessageReceived: { + var message_json = JSON.parse(message); + console.log("Raw response: " + message) + + if (message_json[0] === msgid_enu.event){ + var propertyName = message_json[2].event.split("/")[1] + if (propertyName === "TransmissionMode"){ + wshift = message_json[2].data.value + }else if (propertyName === "VehicleSpeed"){ + vehiclespeed = message_json[2].data.value + }else if (propertyName === "EngineSpeed"){ + enginespeed = message_json[2].data.value + } + }else if (message_json[0] === msgid_enu.retok){ + for (var item in message_json[2].response){ + if (item === "TransmissionMode"){ + wshift = message_json[2].response["TransmissionMode"]["value"] + }else if (item === "VehicleSpeed"){ + vehiclespeed = message_json[2].response["VehicleSpeed"]["value"] + }else if (item === "EngineSpeed"){ + enginespeed = message_json[2].response["EngineSpeed"]["value"] + } + } + }else{ + console.log ("Event type error:", message_json[0]) + } + } + + active: false + } + + Timer { + id: countdown + repeat: false + interval: 3000 + triggeredOnStart: false + onTriggered: { + websocket.active = true + } + } + + Item { + id: topscreen_up + width: root.width + height: (root.height - bottomscreen.height)/2 + + CameraControl { + id:cameracontrol_up + listWH: true + device: camera_up + width: root.width + height:80 + } + Camera { + id: camera_up + width: root.width + height: topscreen_up.height - cameracontrol_up.height + anchors.top: cameracontrol_up.bottom + onIsrunningChanged: { + camerabg_up.visible = !isrunning + + if (isrunning){ + if (cameracontrol_dn.device.cameraCnt() === 1) + cameracontrol_dn.switchstatus = false; + }else{ + cameracontrol_dn.switchstatus = true; + } + } + onCamraCntChanged: { + if (!camera_dn.isrunning) + cameracontrol_dn.number = camera_dn.camranum(); + + if (!camera_up.isrunning) + cameracontrol_up.number = camera_up.camranum(); + } + + Image { + id: camerabg_up + anchors.centerIn: parent + width: 200 + height: 200 + source: "images/camera/camera_bg.svg" + } + } + } + + Item { + id: topscreen_dn + width: root.width + height: (root.height - bottomscreen.height)/2 + anchors.top: topscreen_up.bottom + CameraControl { + id:cameracontrol_dn + listWH: false + device: camera_dn + width: root.width + height:80 + back:0 + } + Camera { + id: camera_dn + width: root.width + height: topscreen_dn.height - cameracontrol_dn.height + anchors.top: cameracontrol_dn.bottom + onIsrunningChanged: { + camerabg_dn.visible = !isrunning + + if (isrunning){ + if (cameracontrol_up.device.cameraCnt() === 1) + cameracontrol_up.switchstatus = false; + }else{ + cameracontrol_up.switchstatus = true; + } + } + + onCamraCntChanged: { + if (!camera_up.isrunning) + cameracontrol_up.number = camera_up.camranum(); + + if (!camera_dn.isrunning) + cameracontrol_dn.number = camera_dn.camranum(); + } + + Image { + id: camerabg_dn + anchors.centerIn: parent + width: 200 + height: 200 + source: "images/camera/camera_bg.svg" + } + } + } + + Item { + id: bottomscreen + width: root.width + height: 600 + anchors.bottom: parent.bottom + Image { + width: parent.width + height: parent.height + asynchronous: true + fillMode: Image.TileHorizontally + smooth: true + source: "images/homescreen/homebg_bottom.svg" + } + RowLayout { + id: smtparts + anchors.left: parent.left + anchors.right: parent.right + Speed { + id: speedparts + anchors.left: parent.left + anchors.leftMargin: 30 + anchors.bottom: parent.bottom + anchors.bottomMargin: 120 + width: imgwidth + height: imgheight + } + ColumnLayout { + id: tachoparts + anchors.horizontalCenter: parent.horizontalCenter + Tacho { + anchors.top: parent.top + anchors.topMargin: -60 + anchors.horizontalCenter: parent.horizontalCenter + width: imgwidth + height: imgheight + } + MidOther { + anchors.bottom: parent.bottom + anchors.bottomMargin: 110 + anchors.horizontalCenter: parent.horizontalCenter + width: imgwidth + height: imgheight + } + } + Mid { + id: midparts + anchors.right: parent.right + anchors.rightMargin: 25 + anchors.bottom: parent.bottom + anchors.bottomMargin: 90 + width: imgwidth + height: imgheight + } + } + } + + onVisibleChanged: { + if (visible){ + if (!websocket.active){ + websocket.active = true + }else{ + do_subscribe() + } + } + else { + countdown.stop() + if (websocket.active) + do_unsubscribe() + } + } + + Connections { + target: appVisible + onVisibleChanged: { + if (!visible){ + if (websocket.active) + do_unsubscribe() + }else{ + if (websocket.active){ + do_subscribe() + }else{ + websocket.active = true + } + } + } + } + + function do_call(binding, verb, event_name) { + als_meter_demo_request_str = '[' + msgid_enu.call + ',"99999","' + binding+'/'+verb + '", {"event":"' + event_name + '"} ]' + websocket.sendTextMessage (als_meter_demo_request_str) + } + + function do_subscribe() { + do_call(api_str, "subscribe", "VehicleSpeed") + do_call(api_str, "subscribe", "TransmissionMode") + do_call(api_str, "subscribe", "EngineSpeed") + } + + function do_unsubscribe() { + do_call(api_str, "unsubscribe", "VehicleSpeed") + do_call(api_str, "unsubscribe", "TransmissionMode") + do_call(api_str, "unsubscribe", "EngineSpeed") + } +} diff --git a/app/CameraControl.qml b/app/CameraControl.qml new file mode 100644 index 0000000..f3407d5 --- /dev/null +++ b/app/CameraControl.qml @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.0 + +RowLayout { + property var device + property var listWH + 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 models: [number, fps, resolution] + property real back: 1 + property bool switchstatus: true + + Repeater { + id: info + model: ["No.:", "FPS:", "W*H:"] + delegate: RowLayout{ + Label { + id: label + text: model.modelData + color: "#59FF7F" + } + ComboBox { + id: camerainfo + implicitWidth: index != 2 ? 100 : 245 + font: label.font + model: models[index] + contentItem: Text { + text: camerainfo.displayText + font: camerainfo.font + color: camerainfo.pressed ? "#17a81a" : "white" + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + indicator: Canvas { + id: canvas + x: camerainfo.width - width - camerainfo.rightPadding + y: camerainfo.topPadding + (camerainfo.availableHeight - height) / 2 + width: 20 + height: 12 + contextType: "2d" + + Connections { + target: camerainfo + onPressedChanged: canvas.requestPaint() + } + + onPaint: { + context.reset(); + context.moveTo(0, 0); + context.lineTo(width, 0); + context.lineTo(width / 2, height); + context.closePath(); + context.fillStyle = camerainfo.pressed ? "#17a81a" : "white"; + context.fill(); + } + } + popup: Popup { + id: popup + y: camerainfo.height - 1 + implicitWidth: camerainfo.width + implicitHeight: listview.count > 6 ? (listview.contentHeight/3.3) : listview.contentHeight + padding: 0 + + contentItem: ListView { + id: listview + clip: true + model: camerainfo.visible ? camerainfo.delegateModel : null + currentIndex: camerainfo.highlightedIndex + ScrollIndicator.vertical: ScrollIndicator { } + } + background: Image { source: "images/camera/camerainfo_bg.svg" } + } + delegate: ItemDelegate { + id: popupdelegate + width: camerainfo.width + contentItem: Item { + implicitHeight: 30 + Text { + text: modelData + color: popupdelegate.pressed || highlighted ? "#21be2b" : "white" + font: camerainfo.font + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + } + } + highlighted: camerainfo.highlightedIndex == index + } + + background: Image { source: "images/camera/camerainfo_bg.svg" } + } + } + } + Switch { + id: cameraswitch + enabled: switchstatus + onCheckedChanged: { + 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){ + device.stop() + } + } + } + + onVisibleChanged: { + if (!visible) + cameraswitch.checked = false + } + + Component.onCompleted: { + device.enumerateCameras(); + number = device.camranum(); + + if (device.cameraCnt() === 0) + switchstatus = false; + } +} diff --git a/app/Mid.qml b/app/Mid.qml new file mode 100644 index 0000000..e658138 --- /dev/null +++ b/app/Mid.qml @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.6 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 + +Item { + property real imgwidth: 320 + property real imgheight: 320 + + Image { + id: midimg + width: imgwidth + height: imgheight + fillMode: Image.PreserveAspectFit + asynchronous: true + smooth: true + source: "images/mid/mid_S_normal.svg" + } +} diff --git a/app/MidOther.qml b/app/MidOther.qml new file mode 100644 index 0000000..579d5f1 --- /dev/null +++ b/app/MidOther.qml @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.6 +import QtQuick.Controls 2.0 +import QtQuick.Layouts 1.0 +import QtWebSockets 1.0 + +Item { + property real imgwidth: 430*120/150 + property real imgheight: 120 + + property var recirc_mid: ["images/mid/recirc_outer.svg", "images/mid/recirc_inter.svg"] + + Image { + width: imgwidth + height: imgheight + fillMode: Image.PreserveAspectFit + asynchronous: true + smooth: true + source: recirc_mid[recirc] + } +} diff --git a/app/Shift.qml b/app/Shift.qml new file mode 100644 index 0000000..60a0f0f --- /dev/null +++ b/app/Shift.qml @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.0 +import QtWebSockets 1.0 + +Row { + property real percent: 1 + property var carshift: [ + "images/meters/tacho_shift_N.svg", "images/meters/tacho_shift_D.svg" + ] + + property var wheelshift: [ + "images/meters/tacho_shift_1.svg", "images/meters/tacho_shift_2.svg", + "images/meters/tacho_shift_3.svg", "images/meters/tacho_shift_4.svg", + "images/meters/tacho_shift_5.svg", "images/meters/tacho_shift_6.svg" + ] + + Image { + width: percent*sourceSize.width + height: percent*sourceSize.height + fillMode: Image.PreserveAspectFit + smooth: true + asynchronous: true + source: wshift === 0 ? carshift[0] : carshift[1] + } + + Image { + visible: wshift > 0 + width: percent*sourceSize.width + height: percent*sourceSize.height + fillMode: Image.PreserveAspectFit + smooth: true + asynchronous: true + source: (wshift > 0 && wshift <= wheelshift.length) ? wheelshift[wshift-1] : wheelshift[0] + } +} diff --git a/app/Speed.qml b/app/Speed.qml new file mode 100644 index 0000000..46ec01f --- /dev/null +++ b/app/Speed.qml @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.3 +import QtWebSockets 1.0 + +Item { + property real imgwidth: 300 + property real imgheight: 300 + property var spdlist: [ + "images/meters/speed_0.svg", "images/meters/speed_1.svg", + "images/meters/speed_2.svg", "images/meters/speed_3.svg", + "images/meters/speed_4.svg", "images/meters/speed_5.svg", + "images/meters/speed_6.svg", "images/meters/speed_7.svg", + "images/meters/speed_8.svg", "images/meters/speed_9.svg" + ] + property var spdlimit: [ "images/meters/speed_limit_none.svg" ] + + Image { + width: 280 + height: 280 + anchors.top: parent.top + anchors.topMargin: 17 + anchors.horizontalCenter: parent.horizontalCenter + fillMode: Image.PreserveAspectFit + asynchronous: true + smooth: true + source: "images/meters/speed_center.svg" + } + + Image { + width: imgwidth + height: imgheight + fillMode: Image.PreserveAspectFit + smooth: true + asynchronous: true + source: spdlimit[0] + } + + Row { + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter + Image { + width: imgwidth*sourceSize.width/480 + height: imgheight*sourceSize.height/480 + fillMode: Image.PreserveAspectFit + asynchronous: true + smooth: true + visible: vehiclespeed > 99 + source: ((vehiclespeed - vehiclespeed%100)/100%10 < spdlist.length) ? spdlist[(vehiclespeed - vehiclespeed%100)/100%10] : spdlist[0] + } + Image { + width: imgwidth*sourceSize.width/480 + height: imgheight*sourceSize.height/480 + fillMode: Image.PreserveAspectFit + asynchronous: true + smooth: true + visible: vehiclespeed > 9 + source: ((vehiclespeed - vehiclespeed%10)/10%10 < spdlist.length) ? spdlist[(vehiclespeed - vehiclespeed%10)/10%10] : spdlist[0] + } + Image { + width: imgwidth*sourceSize.width/480 + height: imgheight*sourceSize.height/480 + fillMode: Image.PreserveAspectFit + asynchronous: true + smooth: true + source: (vehiclespeed%10 < spdlist.length) ? spdlist[vehiclespeed%10] : spdlist[0] + } + } + Image { + width: imgwidth + height: imgheight + fillMode: Image.PreserveAspectFit + asynchronous: true + smooth: true + source: "images/meters/speed_kmh.svg" + } +} diff --git a/app/Tacho.qml b/app/Tacho.qml new file mode 100644 index 0000000..9c4fbee --- /dev/null +++ b/app/Tacho.qml @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import QtQuick 2.6 +import QtWebSockets 1.0 + +Item { + property real imgwidth: 600 + property real imgheight: 600 + + property real tacho: enginespeed === undefined ? 0 : (enginespeed > 9000 ? 9 : enginespeed*9/9000) + + Image { + width: imgwidth + height: imgheight + fillMode: Image.PreserveAspectFit + smooth: true + asynchronous: true + source: "images/meters/tacho_center.svg" + } + Image { + width: imgwidth + height: imgheight + fillMode: Image.PreserveAspectFit + smooth: true + asynchronous: true + source: "images/meters/tacho_frame.svg" + } + Image { + width: imgwidth + height: imgheight + fillMode: Image.PreserveAspectFit + smooth: true + asynchronous: true + source: "images/meters/tacho_scale.svg" + } + Shift { + percent: imgwidth/480 + anchors.right: parent.right + anchors.rightMargin: wshift > 0 ? (imgwidth-width)/2+25 : (imgwidth-width)/2-5 + anchors.bottom: parent.bottom + anchors.bottomMargin: 100 + spacing: -10 + } + Canvas { + id: canvas + property real engleoffset: Math.PI*3/2.04 + property int linewidth: 90 + anchors.centerIn: parent + width: 420 + height: 420 + visible: tacho >= 0.05 + rotation: 135 + opacity: 0.5 + onPaint: { + var ctx = getContext("2d") + var gradient = ctx.createLinearGradient(0, 0, canvas.width, canvas.height) + gradient.addColorStop(0.0, Qt.rgba(1.0, 1.0, 1.0, 1.0)) + gradient.addColorStop(1.0, Qt.rgba(1.0, 1.0, 1.0, 0.0)) + + ctx.clearRect(0, 0, canvas.width, canvas.height); + ctx.beginPath(); + ctx.lineWidth = linewidth; + ctx.strokeStyle = gradient + ctx.arc(canvas.width/2, + canvas.height/2, + (canvas.width-ctx.lineWidth)/2, + 0.1, + engleoffset*(tacho/9) + (tacho < 3 ? 0.1 : (tacho < 7 ? 0.05 : 0.0)), + false) + ctx.stroke() + ctx.closePath() + } + } + Image { + width: imgwidth + height: imgheight + fillMode: Image.PreserveAspectFit + smooth: true + asynchronous: true + rotation: 28.8*tacho + source: "images/meters/tacho_hand.svg" + } + + onTachoChanged: { + canvas.requestPaint() + } +} diff --git a/app/als-meter-demo.qrc b/app/als-meter-demo.qrc new file mode 100644 index 0000000..4843da7 --- /dev/null +++ b/app/als-meter-demo.qrc @@ -0,0 +1,11 @@ + + + Als-meter-demo.qml + Speed.qml + Mid.qml + Tacho.qml + CameraControl.qml + Shift.qml + MidOther.qml + + diff --git a/app/app.pri b/app/app.pri new file mode 100644 index 0000000..014646f --- /dev/null +++ b/app/app.pri @@ -0,0 +1,12 @@ +TEMPLATE = app + +load(configure) +qtCompileTest(libhomescreen) + +config_libhomescreen { + CONFIG += link_pkgconfig + PKGCONFIG += homescreen + DEFINES += HAVE_LIBHOMESCREEN +} + +DESTDIR = $${OUT_PWD}/../package/root/bin diff --git a/app/app.pro b/app/app.pro new file mode 100644 index 0000000..a836400 --- /dev/null +++ b/app/app.pro @@ -0,0 +1,22 @@ +TARGET = als-meter-demo +QT = quickcontrols2 dbus + +LIBS += -lopencv_core -lopencv_videoio + +equals(QT_ARCH, "arm") { + QMAKE_CXXFLAGS += -mfp16-format=ieee +} + + +HEADERS += \ + camera.h + +SOURCES += \ + main.cpp \ + camera.cpp + +RESOURCES += \ + als-meter-demo.qrc \ + images/images.qrc + +include(app.pri) diff --git a/app/camera.cpp b/app/camera.cpp new file mode 100644 index 0000000..107880c --- /dev/null +++ b/app/camera.cpp @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "camera.h" +#include +#include + +#include +#include +#include +#include + +using namespace cv; + +Camera::Camera() { + running = false; + timer = new QTimer(this); + capture = new VideoCapture(); + + connect(timer, SIGNAL(timeout()), this, SLOT(grab())); +} + +Camera::~Camera() { + if (timer->isActive()) + timer->stop(); + if (capture && capture->isOpened()) + capture->release(); + delete timer; + delete capture; +} + +void Camera::paint(QPainter *painter) { + painter->drawImage(0, 0, image); +} + +void Camera::enumerateCameras() { + int maxID = 10; + for (int idx = 0; idx " << (char*)(cap.card) << ">" << (char*)(cap.bus_info);// << (cap.version>>16)&0xFF << (cap.version>>8)&0XFF << cap.version&0xFF; + cam_arr.push_back(idx); // vector of all available cameras + } + } + close(fd); + } + } + + camcnt = cam_arr.length(); + cam_arr_bak = cam_arr; +} + +void Camera::start(int no, int fps, QString res) { + try{ + for (QVariantList::iterator iter = cam_arr_bak.begin(); iter != cam_arr_bak.end(); ++iter){ + if (*iter == no){ + cam_arr_bak.erase(iter); + break; + } + } + + if (capture && capture->open(no)){ + capture->set(CAP_PROP_FRAME_WIDTH, res.section("*", 0, 0).toInt()); + capture->set(CAP_PROP_FRAME_HEIGHT, res.section("*", 1, 1).toInt()); + + if (fps > 0){ + timer->start(1000/fps); + running = true; + emit isrunningChanged(running); + + emit camraCntChanged(cam_arr_bak); + } + camnumbackup = no; + } + } + catch(cv::Exception & e) { + qDebug() << "als-meter-demo open device error: " << e.msg.c_str(); + } +} + +void Camera::stop() { + cam_arr_bak.push_back(camnumbackup); + + if (timer->isActive()) + timer->stop(); + if (capture && capture->isOpened()) + capture->release(); + image = QImage(); + update(); + running = false; + emit isrunningChanged(running); + + emit camraCntChanged(cam_arr_bak); +} + +QVariantList Camera::camranum() const{ + return cam_arr_bak; +} + +int Camera::cameraCnt() { + return camcnt; +} + +bool Camera::isrunning() const{ + return running; +} + +void Camera::grab() { + if (capture && capture->isOpened()){ + Mat frame; + capture->read(frame); + + if (!frame.empty()){ + image = QImage((const uchar*)(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_RGB888).rgbSwapped(); + image = image.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + update(); + } + } +} diff --git a/app/camera.h b/app/camera.h new file mode 100644 index 0000000..163f82e --- /dev/null +++ b/app/camera.h @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CAMERA_H +#define CAMERA_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace cv; +using namespace std; + +static QVariantList cam_arr_bak; + +class Camera : public QQuickPaintedItem +{ + Q_OBJECT + Q_PROPERTY(bool isrunning READ isrunning NOTIFY isrunningChanged) +public: + Camera(); + ~Camera(); + void paint(QPainter *painter); + bool isrunning() const; + Q_INVOKABLE QVariantList camranum() const; + + Q_INVOKABLE void start(int no, int fps, QString res); + Q_INVOKABLE void stop(); + + Q_INVOKABLE void enumerateCameras(); + Q_INVOKABLE int cameraCnt(); + +signals: + void isrunningChanged(const bool& isrunning); + void camraCntChanged(const QVariantList& camcnt); + +public slots: + void grab(); + +private: + bool running; + QImage image; + QTimer* timer; + cv::VideoCapture* capture; + + QVariantList cam_arr; + + int camnumbackup; + int camcnt; +}; + +#endif // CAMERA_H diff --git a/app/config.tests/libhomescreen/libhomescreen.cpp b/app/config.tests/libhomescreen/libhomescreen.cpp new file mode 100644 index 0000000..d698b05 --- /dev/null +++ b/app/config.tests/libhomescreen/libhomescreen.cpp @@ -0,0 +1,8 @@ +#include + +int main(int argc,char **argv) +{ + LibHomeScreen libHomeScreen; + return 0; +} + diff --git a/app/config.tests/libhomescreen/libhomescreen.pro b/app/config.tests/libhomescreen/libhomescreen.pro new file mode 100644 index 0000000..eb4e8f3 --- /dev/null +++ b/app/config.tests/libhomescreen/libhomescreen.pro @@ -0,0 +1,5 @@ +SOURCES = libhomescreen.cpp + +CONFIG -= qt +CONFIG += link_pkgconfig +PKGCONFIG += homescreen diff --git a/app/images/camera/camera_bg.svg b/app/images/camera/camera_bg.svg new file mode 100644 index 0000000..458f81c --- /dev/null +++ b/app/images/camera/camera_bg.svg @@ -0,0 +1,484 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/camera/camerainfo_bg.svg b/app/images/camera/camerainfo_bg.svg new file mode 100644 index 0000000..4251412 --- /dev/null +++ b/app/images/camera/camerainfo_bg.svg @@ -0,0 +1,93 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/homescreen/homebg_bottom.svg b/app/images/homescreen/homebg_bottom.svg new file mode 100644 index 0000000..78bf678 --- /dev/null +++ b/app/images/homescreen/homebg_bottom.svg @@ -0,0 +1,1397 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/images.qrc b/app/images/images.qrc new file mode 100644 index 0000000..b1bee21 --- /dev/null +++ b/app/images/images.qrc @@ -0,0 +1,39 @@ + + + meters/speed_3.svg + meters/speed_7.svg + meters/speed_8.svg + meters/speed_9.svg + meters/tacho_hand.svg + meters/tacho_shift_P.svg + meters/tacho_shift_R.svg + meters/speed_center.svg + meters/tacho_shift_N.svg + meters/tacho_center.svg + meters/tacho_scale.svg + meters/speed_5.svg + meters/speed_4.svg + meters/speed_6.svg + meters/speed_2.svg + meters/tacho_shift_D.svg + meters/speed_0.svg + meters/speed_limit_none.svg + meters/tacho_frame.svg + meters/speed_1.svg + meters/speed_kmh.svg + homescreen/homebg_bottom.svg + camera/camera_bg.svg + camera/camerainfo_bg.svg + mid/mid_S_normal.svg + mid/recirc_inter.svg + mid/recirc_outer.svg + meters/tacho_shift_B.svg + meters/tacho_shift_1.svg + meters/tacho_shift_2.svg + meters/tacho_shift_3.svg + meters/tacho_shift_4.svg + meters/tacho_shift_5.svg + meters/tacho_shift_6.svg + mid/mid_other.svg + + diff --git a/app/images/meters/speed_0.svg b/app/images/meters/speed_0.svg new file mode 100644 index 0000000..f3fb4ad --- /dev/null +++ b/app/images/meters/speed_0.svg @@ -0,0 +1,102 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/speed_1.svg b/app/images/meters/speed_1.svg new file mode 100644 index 0000000..05d48b4 --- /dev/null +++ b/app/images/meters/speed_1.svg @@ -0,0 +1,62 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/speed_2.svg b/app/images/meters/speed_2.svg new file mode 100644 index 0000000..dd97941 --- /dev/null +++ b/app/images/meters/speed_2.svg @@ -0,0 +1,94 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/speed_3.svg b/app/images/meters/speed_3.svg new file mode 100644 index 0000000..67a987c --- /dev/null +++ b/app/images/meters/speed_3.svg @@ -0,0 +1,138 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/images/meters/speed_4.svg b/app/images/meters/speed_4.svg new file mode 100644 index 0000000..c9b2364 --- /dev/null +++ b/app/images/meters/speed_4.svg @@ -0,0 +1,78 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/speed_5.svg b/app/images/meters/speed_5.svg new file mode 100644 index 0000000..2768361 --- /dev/null +++ b/app/images/meters/speed_5.svg @@ -0,0 +1,104 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/speed_6.svg b/app/images/meters/speed_6.svg new file mode 100644 index 0000000..ba4dcd0 --- /dev/null +++ b/app/images/meters/speed_6.svg @@ -0,0 +1,119 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/speed_7.svg b/app/images/meters/speed_7.svg new file mode 100644 index 0000000..2537843 --- /dev/null +++ b/app/images/meters/speed_7.svg @@ -0,0 +1,102 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/images/meters/speed_8.svg b/app/images/meters/speed_8.svg new file mode 100644 index 0000000..656205f --- /dev/null +++ b/app/images/meters/speed_8.svg @@ -0,0 +1,164 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/speed_9.svg b/app/images/meters/speed_9.svg new file mode 100644 index 0000000..96a6e87 --- /dev/null +++ b/app/images/meters/speed_9.svg @@ -0,0 +1,143 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/images/meters/speed_center.svg b/app/images/meters/speed_center.svg new file mode 100644 index 0000000..b9f9f60 --- /dev/null +++ b/app/images/meters/speed_center.svg @@ -0,0 +1,391 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/speed_kmh.svg b/app/images/meters/speed_kmh.svg new file mode 100644 index 0000000..daa2916 --- /dev/null +++ b/app/images/meters/speed_kmh.svg @@ -0,0 +1,101 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/speed_limit_none.svg b/app/images/meters/speed_limit_none.svg new file mode 100644 index 0000000..dde91bf --- /dev/null +++ b/app/images/meters/speed_limit_none.svg @@ -0,0 +1,156 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_center.svg b/app/images/meters/tacho_center.svg new file mode 100644 index 0000000..46086d9 --- /dev/null +++ b/app/images/meters/tacho_center.svg @@ -0,0 +1,246 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_frame.svg b/app/images/meters/tacho_frame.svg new file mode 100644 index 0000000..84a854f --- /dev/null +++ b/app/images/meters/tacho_frame.svg @@ -0,0 +1,213 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_hand.svg b/app/images/meters/tacho_hand.svg new file mode 100644 index 0000000..90ec605 --- /dev/null +++ b/app/images/meters/tacho_hand.svg @@ -0,0 +1,189 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/images/meters/tacho_scale.svg b/app/images/meters/tacho_scale.svg new file mode 100644 index 0000000..035b603 --- /dev/null +++ b/app/images/meters/tacho_scale.svg @@ -0,0 +1,876 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_shift_1.svg b/app/images/meters/tacho_shift_1.svg new file mode 100644 index 0000000..8e3ce67 --- /dev/null +++ b/app/images/meters/tacho_shift_1.svg @@ -0,0 +1,46 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_shift_2.svg b/app/images/meters/tacho_shift_2.svg new file mode 100644 index 0000000..8342580 --- /dev/null +++ b/app/images/meters/tacho_shift_2.svg @@ -0,0 +1,63 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_shift_3.svg b/app/images/meters/tacho_shift_3.svg new file mode 100644 index 0000000..9c8e804 --- /dev/null +++ b/app/images/meters/tacho_shift_3.svg @@ -0,0 +1,69 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_shift_4.svg b/app/images/meters/tacho_shift_4.svg new file mode 100644 index 0000000..5fb9296 --- /dev/null +++ b/app/images/meters/tacho_shift_4.svg @@ -0,0 +1,56 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_shift_5.svg b/app/images/meters/tacho_shift_5.svg new file mode 100644 index 0000000..f4e9838 --- /dev/null +++ b/app/images/meters/tacho_shift_5.svg @@ -0,0 +1,67 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_shift_6.svg b/app/images/meters/tacho_shift_6.svg new file mode 100644 index 0000000..da2f200 --- /dev/null +++ b/app/images/meters/tacho_shift_6.svg @@ -0,0 +1,72 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_shift_B.svg b/app/images/meters/tacho_shift_B.svg new file mode 100644 index 0000000..3dcbe56 --- /dev/null +++ b/app/images/meters/tacho_shift_B.svg @@ -0,0 +1,82 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_shift_D.svg b/app/images/meters/tacho_shift_D.svg new file mode 100644 index 0000000..3c824c4 --- /dev/null +++ b/app/images/meters/tacho_shift_D.svg @@ -0,0 +1,67 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_shift_N.svg b/app/images/meters/tacho_shift_N.svg new file mode 100644 index 0000000..3b41db7 --- /dev/null +++ b/app/images/meters/tacho_shift_N.svg @@ -0,0 +1,66 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/meters/tacho_shift_P.svg b/app/images/meters/tacho_shift_P.svg new file mode 100644 index 0000000..3847b14 --- /dev/null +++ b/app/images/meters/tacho_shift_P.svg @@ -0,0 +1,88 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/images/meters/tacho_shift_R.svg b/app/images/meters/tacho_shift_R.svg new file mode 100644 index 0000000..9007e01 --- /dev/null +++ b/app/images/meters/tacho_shift_R.svg @@ -0,0 +1,70 @@ + + + + + + + + image/svg+xml + + + + + + + diff --git a/app/images/mid/mid_S_normal.svg b/app/images/mid/mid_S_normal.svg new file mode 100644 index 0000000..5aaa6ab --- /dev/null +++ b/app/images/mid/mid_S_normal.svg @@ -0,0 +1,1171 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/images/mid/mid_other.svg b/app/images/mid/mid_other.svg new file mode 100644 index 0000000..7c5b0ad --- /dev/null +++ b/app/images/mid/mid_other.svg @@ -0,0 +1,123 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/images/mid/recirc_inter.svg b/app/images/mid/recirc_inter.svg new file mode 100644 index 0000000..64e0ec8 --- /dev/null +++ b/app/images/mid/recirc_inter.svg @@ -0,0 +1,339 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/images/mid/recirc_outer.svg b/app/images/mid/recirc_outer.svg new file mode 100644 index 0000000..bd72e5c --- /dev/null +++ b/app/images/mid/recirc_outer.svg @@ -0,0 +1,339 @@ + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/app/main.cpp b/app/main.cpp new file mode 100644 index 0000000..17bbe81 --- /dev/null +++ b/app/main.cpp @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2017 TOYOTA MOTOR CORPORATION + * Copyright (C) 2016 The Qt Company Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "camera.h" + +#ifdef HAVE_LIBHOMESCREEN +#include +#endif + +class AppVisible : public QObject +{ + Q_OBJECT +public: + AppVisible(QObject *parent = nullptr) : QObject(parent){ + m_ppid = getppid(); + m_visible = true; + QDBusConnection::sessionBus().connect("org.agl.windowmanager", + "/windowmanager", + "org.agl.windowmanager", + "appLayerVisibleChanged", + this, + SLOT(appLayerVisibleChanged(int,bool))); + } + +public slots: + void appLayerVisibleChanged(int pid, bool visible){ + bool tempvis = visible; + + if(tempvis && (m_ppid != pid)) + tempvis = false; + + if(m_visible != tempvis){ + m_visible = tempvis; + emit visibleChanged(m_visible); + } + } + +signals: + void visibleChanged(const bool& visible); + +private: + int m_ppid; + bool m_visible; +}; + +class DBus : public QObject +{ + Q_OBJECT +public: + DBus(QObject *parent = nullptr) + : QObject(parent) + , interface("org.agl.homescreen", "/StatusBar", "org.agl.statusbar", QDBusConnection::sessionBus()) + {} + + Q_INVOKABLE void setStatusIcon(int index, const QString &url) { + interface.call("setStatusIcon", index, url); + } + +private: + QDBusInterface interface; +}; + +int main(int argc, char *argv[]) +{ +#ifdef HAVE_LIBHOMESCREEN + LibHomeScreen libHomeScreen; + + if (!libHomeScreen.renderAppToAreaAllowed(0, 1)) { + qWarning() << "renderAppToAreaAllowed is denied"; + return -1; + } +#endif + + QGuiApplication app(argc, argv); + app.setApplicationName(QStringLiteral("als-meter-demo")); + app.setApplicationVersion(QStringLiteral("0.1.0")); + app.setOrganizationDomain(QStringLiteral("automotivelinux.org")); + app.setOrganizationName(QStringLiteral("AutomotiveGradeLinux")); + + QQuickStyle::setStyle("AGL"); + + 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(); + + qmlRegisterType("Camera", 1, 0, "Camera"); + + QQmlApplicationEngine engine; + int port = 0; + if (positionalArguments.length() == 2) { + port = positionalArguments.takeFirst().toInt(); + } + QString secret = positionalArguments.takeFirst(); + QUrl bindingAddressWS; + bindingAddressWS.setScheme(QStringLiteral("ws")); + bindingAddressWS.setHost(QStringLiteral("localhost")); + bindingAddressWS.setPort(port); + bindingAddressWS.setPath(QStringLiteral("/api")); + QUrlQuery query; + query.addQueryItem(QStringLiteral("token"), secret); + bindingAddressWS.setQuery(query); + QQmlContext *context = engine.rootContext(); + AppVisible appVisible; + context->setContextProperty(QStringLiteral("appVisible"), &appVisible); + context->setContextProperty(QStringLiteral("bindingAddressWS"), bindingAddressWS); + + DBus dbus; + engine.rootContext()->setContextProperty("dbus", &dbus); + engine.load(QUrl(QStringLiteral("qrc:/Als-meter-demo.qml"))); + + return app.exec(); +} + +#include "main.moc" -- cgit 1.2.3-korg