From 238076ffff13356c620a7834e25537d4a41e97a6 Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Mon, 8 Apr 2019 18:43:05 +0900 Subject: Add demo3 settings source code for cluster mode. Add demo3 settings source code for cluster mode. [Patch Set 2] Update LICENSE file. Change-Id: I586a211bb55e5017de62e36edd0bbba6968de1b8 BUG-AGL: SPEC-2261 Signed-off-by: zheng_wenlong --- .gitignore | 3 + .gitreview | 6 + LICENSE | 204 ++++++++++ app/SettingPage.qml | 65 +++ app/Settings.qml | 78 ++++ app/SettingsLauncher.qml | 83 ++++ app/app.pri | 12 + app/app.pro | 19 + app/bluetooth/Bluetooth.qml | 435 +++++++++++++++++++++ app/bluetooth/bluetooth.qrc | 8 + app/bluetooth/images/HMI_Pair_Button.svg | 43 ++ app/bluetooth/images/HMI_Paired_Button.svg | 43 ++ .../images/HMI_Settings_BluetoothIcon.svg | 55 +++ app/datetime/DateEdit.qml | 122 ++++++ app/datetime/DateTime.qml | 50 +++ app/datetime/EditSeparator.qml | 40 ++ app/datetime/TimeEdit.qml | 86 ++++ app/datetime/datetime.qrc | 14 + .../HMI_Settings_TimeDate_Arrow_DividingLine.svg | 24 ++ .../images/HMI_Settings_TimeDate_Arrow_Down.svg | 29 ++ .../images/HMI_Settings_TimeDate_Arrow_Up.svg | 29 ++ .../images/HMI_Settings_TimeDate_Button_Cancel.svg | 39 ++ .../images/HMI_Settings_TimeDate_Button_Set.svg | 39 ++ app/datetime/images/HMI_Settings_TimeIcon.svg | 59 +++ app/example/Example.qml | 114 ++++++ app/example/example.qrc | 6 + app/example/images/HMI_Settings_Example.svg | 72 ++++ app/images/HMI_Settings_DividingLine.svg | 58 +++ app/images/HMI_Settings_X.svg | 72 ++++ app/images/images.qrc | 6 + app/main.cpp | 147 +++++++ app/settings.qrc | 7 + app/version/Version.qml | 78 ++++ app/version/images/agl_slide_0.png | Bin 0 -> 1759918 bytes app/version/images/icon.svg | 182 +++++++++ app/version/version.qrc | 7 + app/wifi/Wifi.qml | 175 +++++++++ app/wifi/images/HMI_Settings_WifiIcon.svg | 61 +++ app/wifi/images/HMI_Settings_Wifi_1Bar.svg | 71 ++++ app/wifi/images/HMI_Settings_Wifi_2Bars.svg | 71 ++++ app/wifi/images/HMI_Settings_Wifi_3Bars.svg | 71 ++++ app/wifi/images/HMI_Settings_Wifi_Full.svg | 70 ++++ app/wifi/images/HMI_Settings_Wifi_Locked_1Bar.svg | 78 ++++ app/wifi/images/HMI_Settings_Wifi_Locked_2Bars.svg | 78 ++++ app/wifi/images/HMI_Settings_Wifi_Locked_3Bars.svg | 78 ++++ app/wifi/images/HMI_Settings_Wifi_Locked_Full.svg | 77 ++++ .../images/HMI_Settings_Wifi_Locked_NoBars.svg | 79 ++++ app/wifi/images/HMI_Settings_Wifi_NoBars.svg | 70 ++++ app/wifi/wifi.qrc | 16 + package/config.xml | 20 + package/icon.svg | 283 ++++++++++++++ package/package.pro | 21 + settings.pro | 3 + 53 files changed, 3656 insertions(+) create mode 100644 .gitignore create mode 100644 .gitreview create mode 100644 LICENSE create mode 100644 app/SettingPage.qml create mode 100644 app/Settings.qml create mode 100644 app/SettingsLauncher.qml create mode 100644 app/app.pri create mode 100644 app/app.pro create mode 100644 app/bluetooth/Bluetooth.qml create mode 100644 app/bluetooth/bluetooth.qrc create mode 100644 app/bluetooth/images/HMI_Pair_Button.svg create mode 100644 app/bluetooth/images/HMI_Paired_Button.svg create mode 100644 app/bluetooth/images/HMI_Settings_BluetoothIcon.svg create mode 100644 app/datetime/DateEdit.qml create mode 100644 app/datetime/DateTime.qml create mode 100644 app/datetime/EditSeparator.qml create mode 100644 app/datetime/TimeEdit.qml create mode 100644 app/datetime/datetime.qrc create mode 100644 app/datetime/images/HMI_Settings_TimeDate_Arrow_DividingLine.svg create mode 100644 app/datetime/images/HMI_Settings_TimeDate_Arrow_Down.svg create mode 100644 app/datetime/images/HMI_Settings_TimeDate_Arrow_Up.svg create mode 100644 app/datetime/images/HMI_Settings_TimeDate_Button_Cancel.svg create mode 100644 app/datetime/images/HMI_Settings_TimeDate_Button_Set.svg create mode 100644 app/datetime/images/HMI_Settings_TimeIcon.svg create mode 100644 app/example/Example.qml create mode 100644 app/example/example.qrc create mode 100644 app/example/images/HMI_Settings_Example.svg create mode 100644 app/images/HMI_Settings_DividingLine.svg create mode 100644 app/images/HMI_Settings_X.svg create mode 100644 app/images/images.qrc create mode 100644 app/main.cpp create mode 100644 app/settings.qrc create mode 100644 app/version/Version.qml create mode 100644 app/version/images/agl_slide_0.png create mode 100644 app/version/images/icon.svg create mode 100644 app/version/version.qrc create mode 100644 app/wifi/Wifi.qml create mode 100644 app/wifi/images/HMI_Settings_WifiIcon.svg create mode 100644 app/wifi/images/HMI_Settings_Wifi_1Bar.svg create mode 100644 app/wifi/images/HMI_Settings_Wifi_2Bars.svg create mode 100644 app/wifi/images/HMI_Settings_Wifi_3Bars.svg create mode 100644 app/wifi/images/HMI_Settings_Wifi_Full.svg create mode 100644 app/wifi/images/HMI_Settings_Wifi_Locked_1Bar.svg create mode 100644 app/wifi/images/HMI_Settings_Wifi_Locked_2Bars.svg create mode 100644 app/wifi/images/HMI_Settings_Wifi_Locked_3Bars.svg create mode 100644 app/wifi/images/HMI_Settings_Wifi_Locked_Full.svg create mode 100644 app/wifi/images/HMI_Settings_Wifi_Locked_NoBars.svg create mode 100644 app/wifi/images/HMI_Settings_Wifi_NoBars.svg create mode 100644 app/wifi/wifi.qrc create mode 100644 package/config.xml create mode 100644 package/icon.svg create mode 100644 package/package.pro create mode 100644 settings.pro diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..684dcbc --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build +*.pro.user +app/config.tests diff --git a/.gitreview b/.gitreview new file mode 100644 index 0000000..dbb1919 --- /dev/null +++ b/.gitreview @@ -0,0 +1,6 @@ +[gerrit] +host=gerrit.automotivelinux.org +port=29418 +project=apps/demo3-settings +defaultbranch=master + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b3201ab --- /dev/null +++ b/LICENSE @@ -0,0 +1,204 @@ + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don`t include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + diff --git a/app/SettingPage.qml b/app/SettingPage.qml new file mode 100644 index 0000000..c8072de --- /dev/null +++ b/app/SettingPage.qml @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * Copyright (c) 2019 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.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 + +Page { + id: root + readonly property bool isSetting: true + property string icon + property bool checkable: false + property bool checked: false + function done() { + parent.pop() + } + + function setStatusIcon(index, icon) { + dbus.setStatusIcon(index, icon) + } + + Connections { + target: root + onCheckedChanged: { + checkedSwitch.checked = checked + } + } + + Row { + anchors.right: parent.right + anchors.rightMargin: 100 + anchors.bottom: parent.top + anchors.bottomMargin: 10 + spacing: 20 + + Switch { + id: checkedSwitch + visible: root.checkable + onCheckedChanged: root.checked = checked + } + + ImageButton { + id: back + anchors.bottom: parent.bottom + offImage: '../images/HMI_Settings_X.svg' + onClicked: root.done() + } + } + +} diff --git a/app/Settings.qml b/app/Settings.qml new file mode 100644 index 0000000..9369066 --- /dev/null +++ b/app/Settings.qml @@ -0,0 +1,78 @@ +/* + * 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. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 + +import 'datetime' +import 'bluetooth' +import 'wifi' +import 'example' +import 'version' + +ApplicationWindow { + id: root + width: container.width * container.scale + height: container.height * container.scale + + onVisibleChanged: { + if (!visible) + stack.pop(settings) + } + + Item { + id: container + anchors.centerIn: parent + width: 1920 + height: 720 + scale: screenInfo.scale_factor() + + StackView { + id: stack + anchors.fill: parent + initialItem: settings + + SettingsLauncher { + id: settings + onLaunch: { + stack.push(app) + } + + Component.onCompleted: { + for (var a in stack.children) { + var app = stack.children[a] + if (!app.isSetting) continue + settingsModel.append({'icon': app.icon, 'title': app.title, 'checkable': app.checkable, 'app': app}) + app.visible = false + } + } + + model: ListModel { id: settingsModel } + } + + DateTime {} + + Bluetooth {} + + Wifi {} + +// Example {} + + Version {} + } +} +} diff --git a/app/SettingsLauncher.qml b/app/SettingsLauncher.qml new file mode 100644 index 0000000..c62627a --- /dev/null +++ b/app/SettingsLauncher.qml @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * Copyright (c) 2019 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.1 +import QtQuick.Controls 2.0 + +Page { + id: root + title: 'Settings' + property alias model: view.model + signal launch(var app) + signal toggled(var app, bool on) + + ListView { + id: view + anchors.fill: parent + anchors.margins: root.width * 0.075 + clip: true + + delegate: MouseArea { + id: delegate + width: ListView.view.width + height: width / 15 + RowLayout { + anchors.fill: parent + Item { + Layout.preferredWidth: 100 + Layout.preferredHeight: 100 + Image { + anchors.fill: parent + source: model.icon + } + } + Label { + Layout.fillWidth: true + text: model.title.toUpperCase() + color: '#00ADDC' + } + Switch { + id: checkedSwitch + visible: model.checkable + onCheckedChanged: model.app.checked = checked + } + Connections { + target: model.app + onCheckableChanged: { + checkedSwitch.visible = model.app.checkable + } + onCheckedChanged: { + checkedSwitch.checked = model.app.checked + } + } + + Component.onCompleted: { + checkedSwitch.checked = model.app.checked + } + } + Image { + source: '../images/HMI_Settings_DividingLine.svg' + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + visible: model.index > 0 + } + + onClicked: launch(model.app) + } + } +} 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..df45be1 --- /dev/null +++ b/app/app.pro @@ -0,0 +1,19 @@ +TARGET = settings +QT = quickcontrols2 websockets dbus + +SOURCES = main.cpp + +CONFIG += link_pkgconfig +PKGCONFIG += libhomescreen qlibwindowmanager qtappfw + +RESOURCES += \ + settings.qrc \ + images/images.qrc \ + datetime/datetime.qrc \ + wifi/wifi.qrc \ + bluetooth/bluetooth.qrc \ + example/example.qrc \ + version/version.qrc + + +include(app.pri) diff --git a/app/bluetooth/Bluetooth.qml b/app/bluetooth/Bluetooth.qml new file mode 100644 index 0000000..7a63e84 --- /dev/null +++ b/app/bluetooth/Bluetooth.qml @@ -0,0 +1,435 @@ +/* + * 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. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import QtWebSockets 1.0 +import '..' + +SettingPage { + id: root + icon: '/bluetooth/images/HMI_Settings_BluetoothIcon.svg' + title: 'Bluetooth' + checkable: true + readonly property bool isBluetooth: true + property int pairedDeviceCount: 0 + + Connections { + target: bluetooth + onRequestConfirmationEvent: { + bluetooth.send_confirmation() + } + + onDeviceAddedEvent: { + if (data.Paired === "True") { + pairedDeviceList.append({ + deviceAddress: data.Address, + deviceName: data.Name, + devicePairable: data.Paired, + deviceConnect: data.Connected, + connectAVP: data.AVPConnected, + connectHFP: data.HFPConnected, + textToShow: "" + }) + pairedDeviceCount = pairedDeviceCount + 1 + } else { + btDeviceList.append({ + deviceAddress: data.Address, + deviceName: data.Name, + devicePairable: data.Paired, + deviceConnect: data.Connected, + connectAVP: data.AVPConnected, + connectHFP: data.HFPConnected, + textToShow: "" + }) + } + } + + onDeviceRemovedEvent: { + if (findDevice(data.Address) >= 0) { + btDeviceList.remove(findDevice(data.Address)) + } else if(findPairDevice(data.Address) >= 0) { + pairedDeviceList.remove(findPairDevice(data.Address)) + pairedDeviceCount = pairedDeviceCount - 1 + } + } + + onDeviceUpdatedEvent: { + updateDeviceAttribute(data) + } + + onDeviceListEvent: { + for (var i = 0; i < data.list.length; i++) { + var value = data.list[i] + if (value.Paired==="True") { + if(findPairDevice(value.Address) == -1) { + pairedDeviceList.append({ + deviceAddress: value.Address, + deviceName: value.Name, + devicePairable:value.Paired, + deviceConnect: value.Connected, + connectAVP: value.AVPConnected, + connectHFP: value.HFPConnected, + textToShow: "" + }) + pairedDeviceCount = pairedDeviceCount + 1 + } + } + else + if (findDevice(value.Address) == -1) { + btDeviceList.append({ + deviceAddress: value.Address, + deviceName: value.Name, + devicePairable:value.Paired, + deviceConnect: value.Connected, + connectAVP: value.AVPConnected, + connectHFP: value.HFPConnected, + textToShow: "" + }) + } + } + } + + onPowerChanged: { + root.checked = bluetooth.power + } + } + + Text { + id: log + anchors.fill: parent + anchors.margins: 10 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + onCheckedChanged: { + console.log("Bluetooth set to", checked) + + pairedDeviceCount = 0 + bluetooth.power = checked; + bluetooth.discoverable = checked; + + if (checked == true) { + bluetooth.start_discovery() + } else { + btDeviceList.clear() + pairedDeviceList.clear() + bluetooth.stop_discovery() + } + } + + ListModel { + id: pairedDeviceList + } + ListModel { + id: btDeviceList + } + + + Rectangle { + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.margins: 80 + width: buttonScan.width + 10 + height: buttonScan.height + 10 + color: "#222" + border.color: "white" + + Button { + id: buttonScan + anchors.centerIn: parent + width: 100 + text: bluetooth.discoverable ? "STOP" :"SEARCH" + + MouseArea { + //id: mouseArea + anchors.fill: parent + + onClicked: { + if (bluetooth.discoverable === false && bluetooth.power === true) { + bluetooth.start_discovery() + bluetooth.discoverable = true; + } else { + bluetooth.stop_discovery() + bluetooth.discoverable = false; + } + } + } + } + } + + Component { + id:blueToothDevice + Rectangle { + height: 120 + width: parent.width + color: "transparent" + MouseArea { + anchors.fill: parent + Column { + anchors.left: parent.left + anchors.leftMargin: 80 + TextMetrics { + id: textMetrics + font.family: "Arial" + elide: Text.ElideRight + elideWidth: 140 + text: deviceName + } + Text { + id: btName + text: textMetrics.elidedText + color: '#66FF99' + font.pixelSize: 48 + } + Text { + id: btStatus + property string connectionState:"" + text: { + if ((devicePairable === "True") + && (deviceConnect === "True") + && (connectAVP === "True") + && (connectHFP === "False")) + text = " AV Connection, " + else if ((devicePairable === "True") + && (deviceConnect === "True") + && (connectHFP === "True") + && (connectAVP === "False")) + text = " Handsfree Connection, " + else if ((devicePairable === "True") + && (deviceConnect === "True") + && (connectHFP === "True") + && (connectAVP === "True")) + text = " Handsfree & AV Connection, " + else + text = connectionState + + text = deviceAddress + text + } + font.pixelSize: 18 + color: "#ffffff" + font.italic: true + } + Text { + id: btPairable + text: devicePairable + visible: false + } + Text { + id: btConnectstatus + text: deviceConnect + visible: false + } + } + Button { + id: removeButton + anchors.top:parent.top + anchors.topMargin: 15 + //anchors.horizontalCenter: btName.horizontalCenter + anchors.right: parent.right + anchors.rightMargin: 100 + + text: "Remove" + MouseArea { + anchors.fill: parent + onClicked: { + bluetooth.remove_device(deviceAddress); + if (findDevice(deviceAddress) != -1) { + btDeviceList.remove(findDevice(deviceAddress)) + } else if (findPairDevice(deviceAddress) != -1) { + pairedDeviceList.remove(findPairDevice(deviceAddress)) + pairedDeviceCount = pairedDeviceCount - 1 + } + } + } + } + + Button { + id: connectButton + anchors.top:parent.top + anchors.topMargin: 15 + anchors.right: removeButton.left + anchors.rightMargin: 10 + + text: (deviceConnect == "True") ? "Disconnect" : ((btPairable.text == "True") ? "Connect" : "Pair") + // only when HFP or AVP is connected, button will be shown as Disconnect + MouseArea { + anchors.fill: parent + onClicked: { + if (connectButton.text == "Pair"){ + connectButton.text = "Connect" + bluetooth.pair(deviceAddress) + btPairable.text = "True" + } + else if (connectButton.text == "Connect"){ + connectButton.text = "Disconnect" + bluetooth.connect(deviceAddress) + } + else if (connectButton.text == "Disconnect"){ + bluetooth.disconnect(deviceAddress) + connectButton.text = "Connect" + } + } + } + } + } + } + } + Text { + id: pairedlabel + width: parent.width + anchors.top: parent.top + anchors.topMargin: 50 + anchors.left: parent.left + anchors.leftMargin: 80 + height: 80 + color:'grey' + font.pixelSize: 30 + text:{ + if (bluetooth.power == true && pairedDeviceCount != 0) + "LIST OF PAIRED DEVICES" + else + "" + } + } + ListView{ + id: pairedListView + width: parent.width + anchors.top: pairedlabel.bottom + anchors.bottom: pairedlabel.bottom + anchors.bottomMargin: (-120*pairedDeviceCount) + model: pairedDeviceList + delegate: blueToothDevice + clip: true + } + Image { + anchors.bottom: pairedListView.bottom + anchors.left: parent.left + anchors.leftMargin: 80 + height: 5 + source: (bluetooth.power === true && pairedDeviceCount != 0) ? '../images/HMI_Settings_DividingLine.svg':'' + } + Text { + id: detectedlabel + width: parent.width + anchors.top: pairedListView.bottom + anchors.topMargin: (pairedDeviceCount != 0) ? 80:-80 + anchors.left: parent.left + anchors.leftMargin: 80 + height: 80 + color:'grey' + font.pixelSize: 30 + text: { + if (bluetooth.power === true) + "LIST OF DETECTED DEVICES" + else + "" + } + } + ListView { + id:listView2 + width: parent.width + anchors.top: detectedlabel.bottom + anchors.bottom: parent.bottom + anchors.bottomMargin: 150 + model: btDeviceList + delegate: blueToothDevice + clip: true + } + + function findDevice(address) { + for (var i = 0; i < btDeviceList.count; i++) { + if (address === btDeviceList.get(i).deviceAddress) + return i + } + return -1 + } + function findPairDevice(address){ + for (var i = 0; i < pairedDeviceList.count; i++) { + if (address === pairedDeviceList.get(i).deviceAddress) + return i + } + return -1 + } + + function updateDeviceAttribute(data){ + var text = "" + for (var i = 0; i < btDeviceList.count; i++) { + if (data.Address === btDeviceList.get(i).deviceAddress){ + btDeviceList.get(i).devicePairable = data.Paired + if (data.Paired === "True") + { + pairedDeviceList.append({ + deviceAddress: btDeviceList.get(i).deviceAddress, + deviceName: btDeviceList.get(i).deviceName, + devicePairable:btDeviceList.get(i).devicePairable, + deviceConnect: btDeviceList.get(i).deviceConnect, + connectAVP: btDeviceList.get(i).connectAVP, + connectHFP: btDeviceList.get(i).connectHFP, + textToShow: "" + }) + pairedDeviceCount = pairedDeviceCount + 1 + btDeviceList.remove(i, 1) + } + else{ + text=deviceConnectionAttribute(data) + btDeviceList.set(i, { + textToShow: " " + text + }) + + btDeviceList.get(i).deviceConnect = data.Connected + console.log(data.Connected) + } + + } + } + for (var i = 0; i < pairedDeviceList.count; i++) { + if(data.Address === pairedDeviceList.get(i).deviceAddress){ + pairedDeviceList.get(i).devicePairable = data.Paired + + text=deviceConnectionAttribute(data) + pairedDeviceList.set(i, { textToShow: " " + text }) + + pairedDeviceList.get(i).deviceConnect = data.Connected + } + } + } + + function deviceConnectionAttribute(data){ + var text = "" + if ((data.Paired === "True") + && (data.Connected === "True") + && (data.AVPConnected === "True") + && (data.HFPConnected === "False")) + text = "AV Connection, " + else if ((data.Paired === "True") + && (data.Connected === "True") + && (data.HFPConnected === "True") + && (data.AVPConnected === "False")) + text = "Handsfree Connection, " + else if ((data.Paired === "True") + && (data.Connected === "True") + && (data.HFPConnected === "True") + && (data.AVPConnected === "True")) { + console.log("all connected!!") + text = ", Handsfree & AV Connection"} + else + text = "" + return text + } +} diff --git a/app/bluetooth/bluetooth.qrc b/app/bluetooth/bluetooth.qrc new file mode 100644 index 0000000..bc8b70a --- /dev/null +++ b/app/bluetooth/bluetooth.qrc @@ -0,0 +1,8 @@ + + + Bluetooth.qml + images/HMI_Pair_Button.svg + images/HMI_Paired_Button.svg + images/HMI_Settings_BluetoothIcon.svg + + diff --git a/app/bluetooth/images/HMI_Pair_Button.svg b/app/bluetooth/images/HMI_Pair_Button.svg new file mode 100644 index 0000000..9d3f626 --- /dev/null +++ b/app/bluetooth/images/HMI_Pair_Button.svg @@ -0,0 +1,43 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + Pair + + + + + diff --git a/app/bluetooth/images/HMI_Paired_Button.svg b/app/bluetooth/images/HMI_Paired_Button.svg new file mode 100644 index 0000000..6e1f57a --- /dev/null +++ b/app/bluetooth/images/HMI_Paired_Button.svg @@ -0,0 +1,43 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + PairED + + + + + diff --git a/app/bluetooth/images/HMI_Settings_BluetoothIcon.svg b/app/bluetooth/images/HMI_Settings_BluetoothIcon.svg new file mode 100644 index 0000000..d41de2a --- /dev/null +++ b/app/bluetooth/images/HMI_Settings_BluetoothIcon.svg @@ -0,0 +1,55 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/datetime/DateEdit.qml b/app/datetime/DateEdit.qml new file mode 100644 index 0000000..f9f75fd --- /dev/null +++ b/app/datetime/DateEdit.qml @@ -0,0 +1,122 @@ +/* + * 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. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 + +GridLayout { + id: root + flow: GridLayout.TopToBottom + rows: 3 + + property int year: yearControl.model[yearControl.currentIndex] + property int month: monthControl.currentIndex + 1 + property int day: dayControl.currentIndex + 1 + + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Up.svg' + onClicked: monthControl.currentIndex++ + } + Tumbler { + id: monthControl + implicitWidth: 200 + model: ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] + onCurrentIndexChanged: dayControl.regenerateModel() + + EditSeparator { anchors.fill: parent } + } + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Down.svg' + onClicked: monthControl.currentIndex-- + } + + Item { width: 10; height: 10 } + Label { text: ':' } + Item { width: 10; height: 10 } + + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Up.svg' + onClicked: dayControl.currentIndex++ + } + + Tumbler { + id: dayControl + model: ListModel{ + id: monthModel + } + Component.onCompleted: regenerateModel() + function regenerateModel() { + var eom = 0 + var y = yearControl.model[yearControl.currentIndex] + var m = monthControl.currentIndex + 1 + switch (m) { + case 2: + eom = 28 + parseInt(1 / (y % 4 + 1)) - parseInt(1 - 1 / (y % 100 + 1)) + parseInt(1 / (y % 400 + 1)) + break + case 4: + case 6: + case 9: + case 11: + eom = 30 + break + default: + eom = 31 + break + } + while (monthModel.count < eom) + monthModel.append({modelData: monthModel.count + 1}) + while (monthModel.count > eom) + monthModel.remove(monthModel.count - 1, 1) + } + EditSeparator { anchors.fill: parent } + } + + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Down.svg' + onClicked: dayControl.currentIndex-- + } + + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Up.svg' + onClicked: yearControl.currentIndex++ + } + + Tumbler { + id: yearControl + Component.onCompleted: { + var arr = new Array + for (var i = 2010; i < 2050; i++) { + arr.push(i) + } + yearControl.model = arr + } + onCurrentIndexChanged: dayControl.regenerateModel() + EditSeparator { anchors.fill: parent } + } + + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Down.svg' + onClicked: yearControl.currentIndex-- + } +} diff --git a/app/datetime/DateTime.qml b/app/datetime/DateTime.qml new file mode 100644 index 0000000..5030b1e --- /dev/null +++ b/app/datetime/DateTime.qml @@ -0,0 +1,50 @@ +/* + * 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. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 +import '..' + +SettingPage { + id: root + icon: '/datetime/images/HMI_Settings_TimeIcon.svg' + title: 'Date & Time' + + ColumnLayout { + anchors.fill: parent + anchors.margins: 100 + Label { text: 'Date'} + DateEdit {} + Image { + source: '../images/HMI_Settings_DividingLine.svg' + } + Label { text: 'Time'} + TimeEdit {} + RowLayout { + anchors.right: parent.right + Button { + text: 'OK' + highlighted: true + onClicked: root.done() + } + } + Item { + Layout.fillHeight: true + } + } +} diff --git a/app/datetime/EditSeparator.qml b/app/datetime/EditSeparator.qml new file mode 100644 index 0000000..e833b52 --- /dev/null +++ b/app/datetime/EditSeparator.qml @@ -0,0 +1,40 @@ +/* + * 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. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 + +ColumnLayout { + anchors.fill: parent + z: -1 + Item { + Layout.fillHeight: true + Layout.preferredHeight: 1 + } + Repeater { + model: 2 + Image { + Layout.fillHeight: true + Layout.preferredHeight: 2 + Layout.alignment: Layout.Center + source: './images/HMI_Settings_TimeDate_Arrow_DividingLine.svg' + } + } + Item { + Layout.fillHeight: true + Layout.preferredHeight: 1 + } +} diff --git a/app/datetime/TimeEdit.qml b/app/datetime/TimeEdit.qml new file mode 100644 index 0000000..69a049b --- /dev/null +++ b/app/datetime/TimeEdit.qml @@ -0,0 +1,86 @@ +/* + * 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. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 + +GridLayout { + id: root + flow: GridLayout.TopToBottom + rows: 3 + + property int hour: hourControl.currentIndex + property int minutes: minutesControl.currentIndex + property string ampm: ampmControl.model[ampmControl.currentIndex] + + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Up.svg' + onClicked: hourControl.currentIndex++ + } + Tumbler { + id: hourControl + model: 12 + EditSeparator { anchors.fill: parent } + } + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Down.svg' + onClicked: hourControl.currentIndex-- + } + + Item { width: 10; height: 10 } + Label { text: ':' } + Item { width: 10; height: 10 } + + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Up.svg' + onClicked: minutesControl.currentIndex++ + } + + Tumbler { + id: minutesControl + model: 60 + EditSeparator { anchors.fill: parent } + } + + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Down.svg' + onClicked: minutesControl.currentIndex-- + } + + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Up.svg' + onClicked: ampmControl.currentIndex++ + } + + Tumbler { + id: ampmControl + model: ['AM', 'PM', 'AM', 'PM'] + EditSeparator { anchors.fill: parent } + } + + ImageButton { + Layout.alignment: Layout.Center + offImage: './images/HMI_Settings_TimeDate_Arrow_Down.svg' + onClicked: ampmControl.currentIndex-- + } +} diff --git a/app/datetime/datetime.qrc b/app/datetime/datetime.qrc new file mode 100644 index 0000000..c60c626 --- /dev/null +++ b/app/datetime/datetime.qrc @@ -0,0 +1,14 @@ + + + DateEdit.qml + DateTime.qml + TimeEdit.qml + EditSeparator.qml + images/HMI_Settings_TimeDate_Arrow_DividingLine.svg + images/HMI_Settings_TimeDate_Arrow_Down.svg + images/HMI_Settings_TimeDate_Arrow_Up.svg + images/HMI_Settings_TimeDate_Button_Cancel.svg + images/HMI_Settings_TimeDate_Button_Set.svg + images/HMI_Settings_TimeIcon.svg + + diff --git a/app/datetime/images/HMI_Settings_TimeDate_Arrow_DividingLine.svg b/app/datetime/images/HMI_Settings_TimeDate_Arrow_DividingLine.svg new file mode 100644 index 0000000..f311d6a --- /dev/null +++ b/app/datetime/images/HMI_Settings_TimeDate_Arrow_DividingLine.svg @@ -0,0 +1,24 @@ + + + + + + + + + + +]> + + + + + + + + diff --git a/app/datetime/images/HMI_Settings_TimeDate_Arrow_Down.svg b/app/datetime/images/HMI_Settings_TimeDate_Arrow_Down.svg new file mode 100644 index 0000000..18ae1f5 --- /dev/null +++ b/app/datetime/images/HMI_Settings_TimeDate_Arrow_Down.svg @@ -0,0 +1,29 @@ + + + + + + + + + + +]> + + + + + + + + + + + + diff --git a/app/datetime/images/HMI_Settings_TimeDate_Arrow_Up.svg b/app/datetime/images/HMI_Settings_TimeDate_Arrow_Up.svg new file mode 100644 index 0000000..7eba43d --- /dev/null +++ b/app/datetime/images/HMI_Settings_TimeDate_Arrow_Up.svg @@ -0,0 +1,29 @@ + + + + + + + + + + +]> + + + + + + + + + + + + diff --git a/app/datetime/images/HMI_Settings_TimeDate_Button_Cancel.svg b/app/datetime/images/HMI_Settings_TimeDate_Button_Cancel.svg new file mode 100644 index 0000000..14a7edc --- /dev/null +++ b/app/datetime/images/HMI_Settings_TimeDate_Button_Cancel.svg @@ -0,0 +1,39 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + CANCEL + + + + + diff --git a/app/datetime/images/HMI_Settings_TimeDate_Button_Set.svg b/app/datetime/images/HMI_Settings_TimeDate_Button_Set.svg new file mode 100644 index 0000000..e258e1e --- /dev/null +++ b/app/datetime/images/HMI_Settings_TimeDate_Button_Set.svg @@ -0,0 +1,39 @@ + + + + + + + + + + +]> + + + + + + + + + + + + + SET + + + + + diff --git a/app/datetime/images/HMI_Settings_TimeIcon.svg b/app/datetime/images/HMI_Settings_TimeIcon.svg new file mode 100644 index 0000000..d4b2ef6 --- /dev/null +++ b/app/datetime/images/HMI_Settings_TimeIcon.svg @@ -0,0 +1,59 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/example/Example.qml b/app/example/Example.qml new file mode 100644 index 0000000..283b76b --- /dev/null +++ b/app/example/Example.qml @@ -0,0 +1,114 @@ +/* + * 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. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 +import '..' + +SettingPage { + id: root + icon: '/example/images/HMI_Settings_Example.svg' + title: 'Example' + checkable: true + + ColumnLayout { + anchors.fill: parent + anchors.margins: 100 + RowLayout { + spacing: 20 + Button { + text: 'Wifi' + highlighted: true + property int index: 0 + property var icons: ['HMI_Status_Wifi_NoBars-01', 'HMI_Status_Wifi_1Bar-01', 'HMI_Status_Wifi_2Bars-01', 'HMI_Status_Wifi_3Bars-01', 'HMI_Status_Wifi_Full-01'] + onClicked: { + index = (index + 1) % icons.length + setStatusIcon(0, 'qrc:/images/Status/%1.png'.arg(icons[index])) + } + } + Button { + text: 'Bluetooth' + property int index: 0 + property var icons: ['HMI_Status_Bluetooth_Inactive-01', 'HMI_Status_Bluetooth_On-01'] + onClicked: { + index = (index + 1) % icons.length + setStatusIcon(1, 'qrc:/images/Status/%1.png'.arg(icons[index])) + } + } + Button { + text: 'Signal' + property int index: 0 + property var icons: ['HMI_Status_Signal_NoBars-01', 'HMI_Status_Signal_1Bars-01', 'HMI_Status_Signal_2Bars-01', 'HMI_Status_Signal_3Bars-01', 'HMI_Status_Signal_4Bars-01', 'HMI_Status_Signal_Full-01'] + onClicked: { + index = (index + 1) % icons.length + setStatusIcon(2, 'qrc:/images/Status/%1.png'.arg(icons[index])) + } + } + } + + Image { + source: '../images/HMI_Settings_DividingLine.svg' + } + + ListView { + Layout.fillWidth: true + Layout.fillHeight: true + clip: true + model: 10 + delegate: MouseArea { + width: ListView.view.width + height: 110 + RowLayout { + anchors.fill: parent + anchors.margins: 5 + spacing: 30 + Image { + source: './images/HMI_Settings_Example.svg' + } + + ColumnLayout { + Label { + id: title + Layout.fillWidth: true + text: 'Title' + font.pixelSize: 48 + } + Label { + id: subtitle + Layout.fillWidth: true + text: 'Subtitle' + color: '#66FF99' + font.pixelSize: 24 + } + } + + Button { + text: 'Go' + } + } + + Image { + source: '../images/HMI_Settings_DividingLine.svg' + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + visible: model.index > 0 + } + } + } + } +} diff --git a/app/example/example.qrc b/app/example/example.qrc new file mode 100644 index 0000000..5739f8e --- /dev/null +++ b/app/example/example.qrc @@ -0,0 +1,6 @@ + + + Example.qml + images/HMI_Settings_Example.svg + + diff --git a/app/example/images/HMI_Settings_Example.svg b/app/example/images/HMI_Settings_Example.svg new file mode 100644 index 0000000..5ad9479 --- /dev/null +++ b/app/example/images/HMI_Settings_Example.svg @@ -0,0 +1,72 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_Settings_DividingLine.svg b/app/images/HMI_Settings_DividingLine.svg new file mode 100644 index 0000000..d63589c --- /dev/null +++ b/app/images/HMI_Settings_DividingLine.svg @@ -0,0 +1,58 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/HMI_Settings_X.svg b/app/images/HMI_Settings_X.svg new file mode 100644 index 0000000..5ad9479 --- /dev/null +++ b/app/images/HMI_Settings_X.svg @@ -0,0 +1,72 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/images/images.qrc b/app/images/images.qrc new file mode 100644 index 0000000..0bb2c0d --- /dev/null +++ b/app/images/images.qrc @@ -0,0 +1,6 @@ + + + HMI_Settings_DividingLine.svg + HMI_Settings_X.svg + + diff --git a/app/main.cpp b/app/main.cpp new file mode 100644 index 0000000..026f932 --- /dev/null +++ b/app/main.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * Copyright (C) 2017 Konsulko Group + * + * 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 +#include +#include + +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[]) +{ + QString myname = QString("Settings"); + + QGuiApplication app(argc, argv); + app.setApplicationName(myname); + 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(); + + QQmlApplicationEngine engine; + if (positionalArguments.length() != 2) { + exit(EXIT_FAILURE); + } + int port = positionalArguments.takeFirst().toInt(); + QString secret = positionalArguments.takeFirst(); + QUrlQuery query; + query.addQueryItem(QStringLiteral("token"), secret); + + QUrl bindingAddressWS; + bindingAddressWS.setScheme(QStringLiteral("ws")); + bindingAddressWS.setHost(QStringLiteral("localhost")); + bindingAddressWS.setPort(port); + bindingAddressWS.setPath(QStringLiteral("/api")); + bindingAddressWS.setQuery(query); + QQmlContext *context = engine.rootContext(); + context->setContextProperty(QStringLiteral("bindingAddressWS"), bindingAddressWS); + context->setContextProperty("network", new Network(bindingAddressWS, context)); + + std::string token = secret.toStdString(); + LibHomeScreen* hs = new LibHomeScreen(); + QLibWindowmanager* qwm = new QLibWindowmanager(); + + // WindowManager + if(qwm->init(port,secret) != 0) { + exit(EXIT_FAILURE); + } + AGLScreenInfo screenInfo(qwm->get_scale_factor()); + // Request a surface as described in layers.json windowmanager’s file + if(qwm->requestSurface(myname) != 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, myname](json_object *object) { + fprintf(stderr, "Surface got syncDraw!\n"); + qwm->endDraw(myname); + }); + + // HomeScreen + 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){ + qwm->activateSurface(myname); + }); + + QFile version("/proc/version"); + if (version.open(QFile::ReadOnly)) { + QStringList data = QString::fromLocal8Bit(version.readAll()).split(QLatin1Char(' ')); + engine.rootContext()->setContextProperty("kernel", data.at(2)); + version.close(); + } else { + qWarning() << version.errorString(); + } + + QFile aglversion("/etc/os-release"); + if (aglversion.open(QFile::ReadOnly)) { + QStringList data = QString::fromLocal8Bit(aglversion.readAll()).split(QLatin1Char('\n')); + QStringList data2 = data.at(2).split(QLatin1Char('"')); + engine.rootContext()->setContextProperty("ucb", data2.at(1)); + aglversion.close(); + } else { + qWarning() << aglversion.errorString(); + } + + DBus dbus; + engine.rootContext()->setContextProperty("dbus", &dbus); + engine.rootContext()->setContextProperty("bluetooth", new Bluetooth(bindingAddressWS)); + engine.rootContext()->setContextProperty(QStringLiteral("screenInfo"), &screenInfo); + engine.load(QUrl(QStringLiteral("qrc:/Settings.qml"))); + QObject *root = engine.rootObjects().first(); + QQuickWindow *window = qobject_cast(root); + QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface())); + + return app.exec(); +} + +#include "main.moc" diff --git a/app/settings.qrc b/app/settings.qrc new file mode 100644 index 0000000..189f441 --- /dev/null +++ b/app/settings.qrc @@ -0,0 +1,7 @@ + + + Settings.qml + SettingsLauncher.qml + SettingPage.qml + + diff --git a/app/version/Version.qml b/app/version/Version.qml new file mode 100644 index 0000000..8d47ad5 --- /dev/null +++ b/app/version/Version.qml @@ -0,0 +1,78 @@ +/* + * 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. + */ + +import QtQuick 2.6 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.0 +import QtQuick.Window 2.2 +import AGL.Demo.Controls 1.0 +import '..' + +SettingPage { + id: root + icon: '/version/images/icon.svg' + title: 'Version Info' + + ColumnLayout { + id: container + anchors.fill: parent + anchors.margins: 100 + Label { + Layout.fillWidth: true + Layout.preferredHeight: 500 + text: 'Automotive\nGrade Linux' + font.pixelSize: 128 + horizontalAlignment: Label.AlignHCenter + verticalAlignment: Label.AlignVCenter + clip: true + Image { + anchors.centerIn: parent + source: './images/agl_slide_0.png' + z: -1 + opacity: 0.5 + } + } + + GridLayout { + columns: 2 + rowSpacing: 20 + columnSpacing: 20 + Label { + text: 'AGL:' + font.pixelSize: 48 + } + Label { + text: ucb + font.pixelSize: 48 + Layout.fillWidth: true + } + Label { + text: 'Kernel:' + font.pixelSize: 48 + } + Label { + text: kernel + font.pixelSize: 48 + Layout.fillWidth: true + } + } + + Item { + Layout.fillHeight: true + Layout.fillWidth: true + } + } +} diff --git a/app/version/images/agl_slide_0.png b/app/version/images/agl_slide_0.png new file mode 100644 index 0000000..6fd062d Binary files /dev/null and b/app/version/images/agl_slide_0.png differ diff --git a/app/version/images/icon.svg b/app/version/images/icon.svg new file mode 100644 index 0000000..97758e9 --- /dev/null +++ b/app/version/images/icon.svg @@ -0,0 +1,182 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/version/version.qrc b/app/version/version.qrc new file mode 100644 index 0000000..0453cc0 --- /dev/null +++ b/app/version/version.qrc @@ -0,0 +1,7 @@ + + + Version.qml + images/icon.svg + images/agl_slide_0.png + + diff --git a/app/wifi/Wifi.qml b/app/wifi/Wifi.qml new file mode 100644 index 0000000..85e8b60 --- /dev/null +++ b/app/wifi/Wifi.qml @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * Copyright (C) 2018 Konsulko Group + * + * 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.1 +import QtQuick.Controls 2.0 +import AGL.Demo.Controls 1.0 +import ".." + +SettingPage { + id: root + icon: '/wifi/images/HMI_Settings_WifiIcon.svg' + title: 'Wifi' + checkable: true + checked: network.wifiEnabled + readonly property bool isWifi: true + + onCheckedChanged: { + network.power(checked) + } + + Component { + id: wifiDevice + MouseArea { + height: 120 + width: ListView.view.width + Image { + anchors.left: parent.left + id: icon + source: { + var svg + if (strength < 30) + svg = "1Bar" + else if (strength < 50) + svg = "2Bars" + else if (strength < 70) + svg = "3Bars" + else + svg = "Full" + if (security === "Open") { + return 'images/HMI_Settings_Wifi_%1.svg'.arg(svg) + } else { + return 'images/HMI_Settings_Wifi_Locked_%1.svg'.arg(svg) + } + } + } + Column { + anchors.left: icon.right + anchors.leftMargin: 5 + Label { + id: networkNameText + text: ssid + color: '#66FF99' + font.pixelSize: 48 + font.bold: sstate === "ready" + || sstate === "online" + } + Label { + visible: sstate === "ready" + || sstate === "online" + text: "connected, " + address + font.pixelSize: 18 + color: "white" + } + } + + onClicked: { + if ((sstate === "ready") || sstate === "online") { + console.log("Disconnecting from ", ssid, " (", service, ")") + networkNameText.font.italic = 1 + network.disconnect(service) + } else { + console.log("Connecting to ", ssid, " (", service, ")") + networkNameText.font.italic = 1 + network.connect(service) + } + } + + Image { + source: '../images/HMI_Settings_DividingLine.svg' + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: -15 + visible: model.index > 0 + } + } + } + + ListView { + id: view + anchors.fill: parent + anchors.margins: 100 + model: WifiNetworkModel + delegate: wifiDevice + clip: true + } + + MouseArea { + id: dialog + anchors.fill: parent + visible: false + z: 1 + onVisibleChanged: { + if (visible) { + password.forceActiveFocus() + } else { + password.text = '' + } + } + + ColumnLayout { + anchors.fill: parent + Item { + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredHeight: 1 + Rectangle { + anchors.fill: parent + color: 'black' + opacity: 0.5 + } + RowLayout { + anchors.centerIn: parent + TextField { + id: password + property int reqid: 0 + placeholderText: 'Password' + } + Button { + text: 'Connect' + highlighted: true + onClicked: { + network.input(password.reqid, password.text) + dialog.visible = false + } + } + Button { + text: 'Cancel' + onClicked: dialog.visible = false + } + } + } + + Keyboard { + id: keyboard + Layout.fillWidth: true + Layout.fillHeight: true + Layout.preferredHeight: 1 + target: activeFocusControl + } + } + } + + Connections { + target: network + onInputRequest: { + password.reqid = id + dialog.visible = true + } + } +} diff --git a/app/wifi/images/HMI_Settings_WifiIcon.svg b/app/wifi/images/HMI_Settings_WifiIcon.svg new file mode 100644 index 0000000..4314729 --- /dev/null +++ b/app/wifi/images/HMI_Settings_WifiIcon.svg @@ -0,0 +1,61 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/images/HMI_Settings_Wifi_1Bar.svg b/app/wifi/images/HMI_Settings_Wifi_1Bar.svg new file mode 100644 index 0000000..e692c69 --- /dev/null +++ b/app/wifi/images/HMI_Settings_Wifi_1Bar.svg @@ -0,0 +1,71 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/images/HMI_Settings_Wifi_2Bars.svg b/app/wifi/images/HMI_Settings_Wifi_2Bars.svg new file mode 100644 index 0000000..f7cf642 --- /dev/null +++ b/app/wifi/images/HMI_Settings_Wifi_2Bars.svg @@ -0,0 +1,71 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/images/HMI_Settings_Wifi_3Bars.svg b/app/wifi/images/HMI_Settings_Wifi_3Bars.svg new file mode 100644 index 0000000..8a26f3f --- /dev/null +++ b/app/wifi/images/HMI_Settings_Wifi_3Bars.svg @@ -0,0 +1,71 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/images/HMI_Settings_Wifi_Full.svg b/app/wifi/images/HMI_Settings_Wifi_Full.svg new file mode 100644 index 0000000..9ad1869 --- /dev/null +++ b/app/wifi/images/HMI_Settings_Wifi_Full.svg @@ -0,0 +1,70 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/images/HMI_Settings_Wifi_Locked_1Bar.svg b/app/wifi/images/HMI_Settings_Wifi_Locked_1Bar.svg new file mode 100644 index 0000000..5da957f --- /dev/null +++ b/app/wifi/images/HMI_Settings_Wifi_Locked_1Bar.svg @@ -0,0 +1,78 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/images/HMI_Settings_Wifi_Locked_2Bars.svg b/app/wifi/images/HMI_Settings_Wifi_Locked_2Bars.svg new file mode 100644 index 0000000..7f180aa --- /dev/null +++ b/app/wifi/images/HMI_Settings_Wifi_Locked_2Bars.svg @@ -0,0 +1,78 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/images/HMI_Settings_Wifi_Locked_3Bars.svg b/app/wifi/images/HMI_Settings_Wifi_Locked_3Bars.svg new file mode 100644 index 0000000..276c758 --- /dev/null +++ b/app/wifi/images/HMI_Settings_Wifi_Locked_3Bars.svg @@ -0,0 +1,78 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/images/HMI_Settings_Wifi_Locked_Full.svg b/app/wifi/images/HMI_Settings_Wifi_Locked_Full.svg new file mode 100644 index 0000000..9058511 --- /dev/null +++ b/app/wifi/images/HMI_Settings_Wifi_Locked_Full.svg @@ -0,0 +1,77 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/images/HMI_Settings_Wifi_Locked_NoBars.svg b/app/wifi/images/HMI_Settings_Wifi_Locked_NoBars.svg new file mode 100644 index 0000000..6f389c6 --- /dev/null +++ b/app/wifi/images/HMI_Settings_Wifi_Locked_NoBars.svg @@ -0,0 +1,79 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/images/HMI_Settings_Wifi_NoBars.svg b/app/wifi/images/HMI_Settings_Wifi_NoBars.svg new file mode 100644 index 0000000..e23fc1d --- /dev/null +++ b/app/wifi/images/HMI_Settings_Wifi_NoBars.svg @@ -0,0 +1,70 @@ + + + +image/svg+xml \ No newline at end of file diff --git a/app/wifi/wifi.qrc b/app/wifi/wifi.qrc new file mode 100644 index 0000000..063088a --- /dev/null +++ b/app/wifi/wifi.qrc @@ -0,0 +1,16 @@ + + + Wifi.qml + images/HMI_Settings_Wifi_1Bar.svg + images/HMI_Settings_Wifi_2Bars.svg + images/HMI_Settings_Wifi_3Bars.svg + images/HMI_Settings_Wifi_Full.svg + images/HMI_Settings_Wifi_Locked_1Bar.svg + images/HMI_Settings_Wifi_Locked_2Bars.svg + images/HMI_Settings_Wifi_Locked_3Bars.svg + images/HMI_Settings_Wifi_Locked_Full.svg + images/HMI_Settings_Wifi_Locked_NoBars.svg + images/HMI_Settings_Wifi_NoBars.svg + images/HMI_Settings_WifiIcon.svg + + diff --git a/package/config.xml b/package/config.xml new file mode 100644 index 0000000..4ca6eaa --- /dev/null +++ b/package/config.xml @@ -0,0 +1,20 @@ + + + Settings + + + This is the settings application for date & time, wifi and bluetooth + Tasuku Suzuki <tasuku.suzuki@qt.io> + APL 2.0 + + + + + + + + + + + + diff --git a/package/icon.svg b/package/icon.svg new file mode 100644 index 0000000..6628784 --- /dev/null +++ b/package/icon.svg @@ -0,0 +1,283 @@ + + + +image/svg+xmlSETTINGS + \ No newline at end of file diff --git a/package/package.pro b/package/package.pro new file mode 100644 index 0000000..125a378 --- /dev/null +++ b/package/package.pro @@ -0,0 +1,21 @@ + +DISTFILES = icon.svg config.xml + +!equals($$_PRO_FILE_PWD_, $$OUT_PWD) { + copy_icon.target = $$OUT_PWD/root/icon.svg + copy_icon.depends = $$_PRO_FILE_PWD_/icon.svg + copy_icon.commands = $(COPY_FILE) \"$$replace(copy_icon.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_icon.target, /, $$QMAKE_DIR_SEP)\" + QMAKE_EXTRA_TARGETS += copy_icon + PRE_TARGETDEPS += $$copy_icon.target + + copy_config.target = $$OUT_PWD/root/config.xml + copy_config.depends = $$_PRO_FILE_PWD_/config.xml + copy_config.commands = $(COPY_FILE) \"$$replace(copy_config.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_config.target, /, $$QMAKE_DIR_SEP)\" + QMAKE_EXTRA_TARGETS += copy_config + PRE_TARGETDEPS += $$copy_config.target +} + +wgt.target = package +wgt.commands = wgtpkg-pack -f -o settings.wgt root + +QMAKE_EXTRA_TARGETS += wgt diff --git a/settings.pro b/settings.pro new file mode 100644 index 0000000..579a952 --- /dev/null +++ b/settings.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS = app package +package.depends += app -- cgit 1.2.3-korg