911d481b31d53efbf7763de042b4744a249d0b15
[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: pushToTalk
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     states: [
49         State {
50             name: "Idle"
51             when: speechChromeController.chromeState == SpeechChromeController.Idle
52             PropertyChanges {
53                 target: chromeBarImage
54                 opacity: 0.0
55                 x: 0
56             }
57             PropertyChanges {
58                 target: pushToTalk
59                 opacity: 1.0
60                 enabled: true
61             }
62         },
63         State {
64             name: "Listening"
65             when: speechChromeController.chromeState == SpeechChromeController.Listening
66             PropertyChanges {
67                 target: chromeBarImage
68                 opacity: 1.0
69                 x: 0
70             }
71             PropertyChanges {
72                 target: pushToTalk
73                 opacity: 0.0
74                 enabled: false
75             }
76         },
77         State {
78             name: "Thinking"
79             when: speechChromeController.chromeState == SpeechChromeController.Thinking
80             PropertyChanges {
81                 target: chromeBarImage
82                 opacity: 1.0
83                 x: root.width - chromeBarImage.width
84             }
85             PropertyChanges {
86                 target: pushToTalk
87                 opacity: 0.0
88                 enabled: false
89             }
90         },
91         State {
92             name: "Speaking"
93             when: speechChromeController.chromeState == SpeechChromeController.Speaking
94             PropertyChanges {
95                 target: chromeBarImage
96                 opacity: 1.0
97                 x: (root.width - chromeBarImage.width) * 0.5
98             }
99             PropertyChanges {
100                 target: pushToTalk
101                 opacity: 0.0
102                 enabled: false
103             }
104         },
105         State {
106             name: "MicrophoneOff"
107             when: speechChromeController.chromeState == SpeechChromeController.MicrophoneOff
108             PropertyChanges {
109                 target: chromeBarImage
110                 opacity: 0.0
111                 x: 0
112             }
113             PropertyChanges {
114                 target: pushToTalk
115                 opacity: 1.0
116                 enabled: true
117             }
118         }
119     ]
120 }