Merge "homescreen: remove unused DBus code artifacts" 8.99.5 icefish/8.99.5 icefish_8.99.5
authorJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Tue, 28 Jan 2020 12:32:48 +0000 (12:32 +0000)
committerGerrit Code Review <gerrit@automotivelinux.org>
Tue, 28 Jan 2020 12:32:48 +0000 (12:32 +0000)
homescreen/qml/SpeechChrome.qml
homescreen/qml/images/SpeechChrome/push_to_talk_alexa.png [new file with mode: 0644]
homescreen/qml/images/SpeechChrome/speechchrome.qrc
homescreen/src/chromecontroller.cpp
homescreen/src/chromecontroller.h

index ab46cb6..123928c 100644 (file)
@@ -7,6 +7,7 @@ Item {
     clip: true
 
     property bool agentPresent: speechChromeController.agentPresent
+    property string agentName: speechChromeController.agentName
 
     visible: agentPresent
 
@@ -33,7 +34,7 @@ Item {
         anchors.left: parent.left
         anchors.leftMargin: parent.width / 128
         anchors.verticalCenter: parent.verticalCenter
-        source: "./images/SpeechChrome/push_to_talk.svg"
+        source: agentName === "Alexa" ? "./images/SpeechChrome/push_to_talk_alexa.png" : "./images/SpeechChrome/push_to_talk.svg"
 
         MouseArea {
             anchors.fill: parent
@@ -54,7 +55,7 @@ Item {
         anchors.right: parent.right
         anchors.rightMargin: parent.width / 128
         anchors.verticalCenter: parent.verticalCenter
-        source: "./images/SpeechChrome/push_to_talk.svg"
+        source: agentName === "Alexa" ? "./images/SpeechChrome/push_to_talk_alexa.png" : "./images/SpeechChrome/push_to_talk.svg"
 
         MouseArea {
             anchors.fill: parent
diff --git a/homescreen/qml/images/SpeechChrome/push_to_talk_alexa.png b/homescreen/qml/images/SpeechChrome/push_to_talk_alexa.png
new file mode 100644 (file)
index 0000000..f45218e
Binary files /dev/null and b/homescreen/qml/images/SpeechChrome/push_to_talk_alexa.png differ
index 42357f1..c5a9690 100644 (file)
@@ -2,5 +2,6 @@
     <qresource prefix="/images/SpeechChrome">
         <file>bar.png</file>
         <file>push_to_talk.svg</file>
+        <file>push_to_talk_alexa.png</file>
     </qresource>
 </RCC>
index b604dae..e944b2d 100644 (file)
@@ -64,6 +64,11 @@ ChromeController::ChromeController(const QUrl &bindingUrl, QObject *parent) :
                             continue;
                         if (agentId.compare(agentIt.value().toString()) == 0) {
                             agentFound = true;
+                            auto nameIt = agentObj.find(vshl::NAME_TAG);
+                            if (nameIt != agentObj.constEnd()) {
+                                m_voiceAgentName = nameIt.value().toString();
+                                emit agentNameChanged();
+                            }
                             break;
                         }
                     }
@@ -111,7 +116,7 @@ ChromeController::ChromeController(const QUrl &bindingUrl, QObject *parent) :
     connect(m_aglSocket, &AglSocketWrapper::eventReceived,
             this, [this](const QString &eventName, const QJsonValue &data) -> void {
         if (eventName.compare(vshl::VOICE_DIALOG_STATE_EVENT + m_voiceAgentId) == 0) {
-            const QJsonObject dataObj = QJsonDocument::fromJson(data.toString().toUtf8()).object();
+            const QJsonObject dataObj = data.toObject();
             auto objIt = dataObj.find(vshl::STATE_TAG);
             if (objIt == dataObj.constEnd()) {
                 qWarning() << "Voice dialog state event state missing.";
index 2a76002..047ddd9 100644 (file)
@@ -9,6 +9,7 @@ class ChromeController : public QObject
     Q_OBJECT
 
     Q_PROPERTY(bool agentPresent READ agentPresent NOTIFY agentPresentChanged)
+    Q_PROPERTY(QString agentName READ agentName NOTIFY agentNameChanged)
     Q_PROPERTY(int chromeState READ chromeState NOTIFY chromeStateChanged)
 
 public:
@@ -24,19 +25,22 @@ public:
     explicit ChromeController(const QUrl &bindingUrl, QObject *parent = nullptr);
     bool agentPresent() const { return m_agentPresent; }
     int chromeState() const { return m_chromeState; }
+    QString agentName() const { return m_voiceAgentName; }
 
 public slots:
     void pushToTalk();
 
 signals:
     void agentPresentChanged();
+    void agentNameChanged();
     void chromeStateChanged();
 
 private:
     void setChromeState(ChromeState state);
 
     AglSocketWrapper *m_aglSocket;
-    QString m_voiceAgentId;
+    QString m_voiceAgentId = "";
+    QString m_voiceAgentName = "";
     bool m_agentPresent = false;
     ChromeState m_chromeState = Idle;
 };