From 32872aa68ef8caa98ead052b91151fbed560e2bb Mon Sep 17 00:00:00 2001 From: Raquel Medina Date: Tue, 3 Dec 2019 23:36:35 +0100 Subject: voice: add voice agents settings page Bug-AGL: SPEC-2981 Signed-off-by: Raquel Medina Change-Id: I8eb6ae44db10039197da406446b5057ae9cb3b50 --- app/Settings.qml | 3 + app/app.pro | 4 +- app/main.cpp | 2 + app/voice/ConfigDialog.qml | 235 ++++++++++++++++++++++++++++ app/voice/Voice.qml | 150 ++++++++++++++++++ app/voice/images/HMI_Settings_VoiceIcon.svg | 151 ++++++++++++++++++ app/voice/voice.qrc | 7 + package/config.xml | 1 + 8 files changed, 551 insertions(+), 2 deletions(-) create mode 100644 app/voice/ConfigDialog.qml create mode 100644 app/voice/Voice.qml create mode 100644 app/voice/images/HMI_Settings_VoiceIcon.svg create mode 100644 app/voice/voice.qrc diff --git a/app/Settings.qml b/app/Settings.qml index 47d5eb2..2fc560c 100644 --- a/app/Settings.qml +++ b/app/Settings.qml @@ -23,6 +23,7 @@ import 'bluetooth' import 'wifi' import 'wired' import 'version' +import 'voice' ApplicationWindow { id: root @@ -73,6 +74,8 @@ ApplicationWindow { Wired {} Version {} + + Voice {} } } } diff --git a/app/app.pro b/app/app.pro index 1d06003..c26e44b 100644 --- a/app/app.pro +++ b/app/app.pro @@ -13,7 +13,7 @@ RESOURCES += \ wifi/wifi.qrc \ wired/wired.qrc \ bluetooth/bluetooth.qrc \ - version/version.qrc - + version/version.qrc \ + voice/voice.qrc include(app.pri) diff --git a/app/main.cpp b/app/main.cpp index c610cef..b46029c 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -28,6 +28,7 @@ #include #include #include +#include int main(int argc, char *argv[]) { @@ -115,6 +116,7 @@ int main(int argc, char *argv[]) } engine.rootContext()->setContextProperty("bluetooth", new Bluetooth(bindingAddressWS, context)); + engine.rootContext()->setContextProperty("voice", new Voice(bindingAddressWS, context)); engine.rootContext()->setContextProperty(QStringLiteral("screenInfo"), &screenInfo); engine.load(QUrl(QStringLiteral("qrc:/Settings.qml"))); QObject *root = engine.rootObjects().first(); diff --git a/app/voice/ConfigDialog.qml b/app/voice/ConfigDialog.qml new file mode 100644 index 0000000..b04a792 --- /dev/null +++ b/app/voice/ConfigDialog.qml @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * Copyright (C) 2019 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.11 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.3 +import AGL.Demo.Controls 1.0 + + +Dialog { + id: root + property alias xpos: root.x + property alias ypos: root.y + property alias maxpwidth: root.width + property alias maxpheight: root.height + + property string thisAgentName: undefined + property string thisAgentId: undefined + property string thisAgentWuW: undefined + property string thisAgentAuthState: undefined + property string thisAgentConnState: undefined + property string thisAgentDialogState: undefined + property string thisAgentLoginUrl: undefined + property string thisAgentLoginCode: undefined + property bool tokenValid: false + property bool agentActive: false + + signal requestNewToken(string thisAgentId) + + visible: false + z: 1 + focus: true + modal: false + footer: DialogButtonBox { + Button { text: "CLOSE" + DialogButtonBox.buttonRole: DialogButtonBox.RejectRole + } + Button { text: "UPDATE" + DialogButtonBox.buttonRole: DialogButtonBox.ResetRole + } + background: Rectangle { + border.color : '#00ADDC' + color: '#848286' + } + } + + background: Rectangle { + border.color : '#00ADDC' + color: 'transparent' + } + + onReset: refreshToken() + function refreshToken() { + root.requestNewToken(thisAgentId); + } + + Item { + id: container + anchors.centerIn: parent + anchors.fill: parent + ColumnLayout { + anchors.fill: parent + RowLayout { + Layout.fillHeight: true + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft + spacing: 32 + visible: true + Label { + id: voiceLabel + font.pixelSize: 28 + color: '#080C0F' + text: "Voice Agent:" + Layout.preferredWidth: 200 + } + Label { + id: idLabel + font.pixelSize: 28 + color: '#66FF99' + text: thisAgentId + } + } + RowLayout { + Layout.fillHeight: true + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft + spacing: 32 + visible: true + Label { + id: namelabel + font.pixelSize: 28 + color: '#080C0F' + text: "Assistant Name:" + Layout.preferredWidth: 200 + } + Label { + id: aNamelabel + font.pixelSize: 28 + color: '#66FF99' + text: thisAgentName + } + } + RowLayout { + Layout.fillHeight: true + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft + spacing: 32 + visible: true + Label { + id: wuwlabel + font.pixelSize: 28 + color: '#080C0F' + text: "Wake Up Word:" + Layout.preferredWidth: 200 + } + Label { + id: thiswuwlabel + font.pixelSize: 28 + color: '#66FF99' + text: thisAgentWuW + } + } + RowLayout { + Layout.fillHeight: true + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + spacing: 16 + visible: true + ColumnLayout { + Layout.fillWidth: true + Label { + id: authLabel + font.pixelSize: 28 + color: '#080C0F' + text: "Authorization status:" + } + Label { + id: connlabel + font.pixelSize: 28 + color: '#080C0F' + text: "Connection status:" + } + Label { + id: dialogLabel + font.pixelSize: 28 + color: '#080C0F' + text: "Dialog status:" + } + } + ColumnLayout { + Layout.fillWidth: true + Label { + id: authsLabel + font.pixelSize: 28 + color: (thisAgentAuthState == "UNITIALIZED")? 'red' : '#66FF99' + text: thisAgentAuthState + } + Label { + id: connslabel + font.pixelSize: 28 + color: (thisAgentConnState == "DISCONNECTED")? 'red' : '#0DF9FF' + text: thisAgentConnState + } + Label { + id: dialogsLabel + font.pixelSize: 28 + color: (thisAgentDialogState == "MICROPHONEOFF")? 'red' : '#0DF9FF' + text: thisAgentDialogState + } + } + } + RowLayout { + Layout.fillHeight: true + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter + spacing: 16 + visible: true + ColumnLayout { + Layout.fillWidth: true + Label { + id: loginurlLabel + font.pixelSize: 28 + color: '#080C0F' + text: "Login url:" + } + Label { + id: logincodeLabel + font.pixelSize: 28 + color: '#080C0F' + text: "Login code:" + } + } + ColumnLayout { + Layout.fillWidth: true + Label { + id: urlLabel + font.pixelSize: 28 + color: root.tokenValid? '#848286':'#0DF9FF' + text: thisAgentLoginUrl + } + Label { + id: codeLabel + font.pixelSize: 28 + color: root.tokenValid? '#848286':'#0DF9FF' + text: thisAgentLoginCode + } + } + } + Label { + font.pixelSize: 18 + visible: root.tokenValid + text: "You can use the supplied login data to enable "+thisAgentName+"." + } + Label { + font.pixelSize: 18 + visible: !root.tokenValid + text: "The current login data is not valid. Press 'UPDATE' to refresh." + } + } + } +} diff --git a/app/voice/Voice.qml b/app/voice/Voice.qml new file mode 100644 index 0000000..b316132 --- /dev/null +++ b/app/voice/Voice.qml @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2016 The Qt Company Ltd. + * Copyright (C) 2019 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.11 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 2.4 +import AGL.Demo.Controls 1.0 +import ".." + +SettingPage { + id: root + icon: '/voice/images/HMI_Settings_VoiceIcon.svg' + title: 'Voice' + readonly property bool isVoice: true + + Rectangle { + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.top + anchors.margins: 80 + width: 110 + color: "#222" + border.color: "white" + + Button { + id: buttonScan + anchors.centerIn: parent + anchors.margins: 10 + text: enabled? "SCAN" : "PROCESSING" + visible: true + enabled: true + + Timer { + id: scanAnimationTimer + interval: 3000 + running: false + repeat: false + onTriggered: { + buttonScan.enabled = true + } + } + MouseArea { + anchors.fill: parent + + onClicked: { + voice.scan() + buttonScan.enabled = false + scanAnimationTimer.start() + } + } + } + } + + Component { + id: voiceAgent + MouseArea { + height: 120 + width: ListView.view.width + Column { + anchors.left: parent.left + anchors.leftMargin: 5 + id: agentId + Label { + id: agentIdText + text: id + color: '#66FF99' + font.pixelSize: 38 + font.bold: active === "active" + } + } + Column { + anchors.left: agentId.right + anchors.leftMargin: 100 + id: agentName + Label { + id: agentNameText + text: name + color: '#66FF99' + font.pixelSize: 38 + font.bold: active === "active" + } + } + Column { + anchors.right: parent.right + anchors.rightMargin: 5 + Button { + visible: active === "active" + font.pixelSize: 18 + text: "DETAILS" + onClicked: { + agentdata.tokenValid = Qt.binding(function() { return (usrauth[2] === "expired")? false : true }) + agentdata.agentActive = Qt.binding(function() { return (active === "active")? true: false }) + agentdata.open() + } + + ConfigDialog { + id: agentdata + parent: Overlay.overlay + maxpwidth: 744 + maxpheight: 744 + xpos: (parent.width - maxpwidth)/2 + ypos: (parent.height - maxpheight) + thisAgentName: name + thisAgentId: id + thisAgentWuW: wuw + thisAgentAuthState: authstate + thisAgentConnState: connstate + thisAgentDialogState: dialogstate + thisAgentLoginUrl: usrauth[0] + thisAgentLoginCode: usrauth[1] + + onRequestNewToken: { + voice.getCBLpair(id); + } + } + } + } + + 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: VoiceAgentModel + delegate: voiceAgent + clip: true + } +} diff --git a/app/voice/images/HMI_Settings_VoiceIcon.svg b/app/voice/images/HMI_Settings_VoiceIcon.svg new file mode 100644 index 0000000..edc87a7 --- /dev/null +++ b/app/voice/images/HMI_Settings_VoiceIcon.svg @@ -0,0 +1,151 @@ + + + +image/svg+xmlCommunication LinkTranscommunication link.ConnectorExit to or entry from another part of chart.Magnetic TapeMagnetic tape storage \ No newline at end of file diff --git a/app/voice/voice.qrc b/app/voice/voice.qrc new file mode 100644 index 0000000..8b05e91 --- /dev/null +++ b/app/voice/voice.qrc @@ -0,0 +1,7 @@ + + + Voice.qml + ConfigDialog.qml + images/HMI_Settings_VoiceIcon.svg + + diff --git a/package/config.xml b/package/config.xml index f7f2c1b..2c251d0 100644 --- a/package/config.xml +++ b/package/config.xml @@ -11,6 +11,7 @@ + -- cgit 1.2.3-korg