Display Alexa specific chrome when it is used
[apps/homescreen.git] / homescreen / qml / SpeechChrome.qml
1 import QtQuick 2.0
2 import SpeechChrome 1.0
3
4 Item {
5     id: root
6
7     clip: true
8
9     property bool agentPresent: speechChromeController.agentPresent
10     property string agentName: speechChromeController.agentName
11
12     visible: agentPresent
13
14     Image {
15         id: chromeBarImage
16
17         anchors.top: parent.top
18         source: "./images/SpeechChrome/bar.png"
19
20         Behavior on x {
21             NumberAnimation { duration: 250 }
22         }
23         Behavior on opacity {
24             NumberAnimation { duration: 250 }
25         }
26     }
27
28     Image {
29         id: pushToTalkLeft
30
31         height: parent.height * 0.80
32         width: height
33
34         anchors.left: parent.left
35         anchors.leftMargin: parent.width / 128
36         anchors.verticalCenter: parent.verticalCenter
37         source: agentName === "Alexa" ? "./images/SpeechChrome/push_to_talk_alexa.png" : "./images/SpeechChrome/push_to_talk.svg"
38
39         MouseArea {
40             anchors.fill: parent
41             onPressed: speechChromeController.pushToTalk()
42         }
43
44         Behavior on opacity {
45             NumberAnimation { duration: 250 }
46         }
47     }
48
49     Image {
50         id: pushToTalkRight
51
52         height: parent.height * 0.80
53         width: height
54
55         anchors.right: parent.right
56         anchors.rightMargin: parent.width / 128
57         anchors.verticalCenter: parent.verticalCenter
58         source: agentName === "Alexa" ? "./images/SpeechChrome/push_to_talk_alexa.png" : "./images/SpeechChrome/push_to_talk.svg"
59
60         MouseArea {
61             anchors.fill: parent
62             onPressed: speechChromeController.pushToTalk()
63         }
64
65         Behavior on opacity {
66             NumberAnimation { duration: 250 }
67         }
68     }
69
70     states: [
71         State {
72             name: "Idle"
73             when: speechChromeController.chromeState == SpeechChromeController.Idle
74             PropertyChanges {
75                 target: chromeBarImage
76                 opacity: 0.0
77                 x: 0
78             }
79             PropertyChanges {
80                 target: pushToTalkLeft
81                 opacity: 1.0
82                 enabled: true
83             }
84             PropertyChanges {
85                 target: pushToTalkRight
86                 opacity: 1.0
87                 enabled: true
88             }
89         },
90         State {
91             name: "Listening"
92             when: speechChromeController.chromeState == SpeechChromeController.Listening
93             PropertyChanges {
94                 target: chromeBarImage
95                 opacity: 1.0
96                 x: 0
97             }
98             PropertyChanges {
99                 target: pushToTalkLeft
100                 opacity: 0.0
101                 enabled: false
102             }
103             PropertyChanges {
104                 target: pushToTalkRight
105                 opacity: 0.0
106                 enabled: false
107             }
108         },
109         State {
110             name: "Thinking"
111             when: speechChromeController.chromeState == SpeechChromeController.Thinking
112             PropertyChanges {
113                 target: chromeBarImage
114                 opacity: 1.0
115                 x: root.width - chromeBarImage.width
116             }
117             PropertyChanges {
118                 target: pushToTalkLeft
119                 opacity: 0.0
120                 enabled: false
121             }
122             PropertyChanges {
123                 target: pushToTalkRight
124                 opacity: 0.0
125                 enabled: false
126             }
127         },
128         State {
129             name: "Speaking"
130             when: speechChromeController.chromeState == SpeechChromeController.Speaking
131             PropertyChanges {
132                 target: chromeBarImage
133                 opacity: 1.0
134                 x: (root.width - chromeBarImage.width) * 0.5
135             }
136             PropertyChanges {
137                 target: pushToTalkLeft
138                 opacity: 0.0
139                 enabled: false
140             }
141             PropertyChanges {
142                 target: pushToTalkRight
143                 opacity: 0.0
144                 enabled: false
145             }
146         },
147         State {
148             name: "MicrophoneOff"
149             when: speechChromeController.chromeState == SpeechChromeController.MicrophoneOff
150             PropertyChanges {
151                 target: chromeBarImage
152                 opacity: 0.0
153                 x: 0
154             }
155             PropertyChanges {
156                 target: pushToTalkLeft
157                 opacity: 1.0
158                 enabled: true
159             }
160             PropertyChanges {
161                 target: pushToTalkRight
162                 opacity: 1.0
163                 enabled: true
164             }
165         }
166     ]
167 }