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