summaryrefslogtreecommitdiffstats
path: root/homescreen/qml/SpeechChrome.qml
blob: 123928c4d649a7c727263d80a17968c500938750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import QtQuick 2.0
import SpeechChrome 1.0

Item {
    id: root

    clip: true

    property bool agentPresent: speechChromeController.agentPresent
    property string agentName: speechChromeController.agentName

    visible: agentPresent

    Image {
        id: chromeBarImage

        anchors.top: parent.top
        source: "./images/SpeechChrome/bar.png"

        Behavior on x {
            NumberAnimation { duration: 250 }
        }
        Behavior on opacity {
            NumberAnimation { duration: 250 }
        }
    }

    Image {
        id: pushToTalkLeft

        height: parent.height * 0.80
        width: height

        anchors.left: parent.left
        anchors.leftMargin: parent.width / 128
        anchors.verticalCenter: parent.verticalCenter
        source: agentName === "Alexa" ? "./images/SpeechChrome/push_to_talk_alexa.png" : "./images/SpeechChrome/push_to_talk.svg"

        MouseArea {
            anchors.fill: parent
            onPressed: speechChromeController.pushToTalk()
        }

        Behavior on opacity {
            NumberAnimation { duration: 250 }
        }
    }

    Image {
        id: pushToTalkRight

        height: parent.height * 0.80
        width: height

        anchors.right: parent.right
        anchors.rightMargin: parent.width / 128
        anchors.verticalCenter: parent.verticalCenter
        source: agentName === "Alexa" ? "./images/SpeechChrome/push_to_talk_alexa.png" : "./images/SpeechChrome/push_to_talk.svg"

        MouseArea {
            anchors.fill: parent
            onPressed: speechChromeController.pushToTalk()
        }

        Behavior on opacity {
            NumberAnimation { duration: 250 }
        }
    }

    states: [
        State {
            name: "Idle"
            when: speechChromeController.chromeState == SpeechChromeController.Idle
            PropertyChanges {
                target: chromeBarImage
                opacity: 0.0
                x: 0
            }
            PropertyChanges {
                target: pushToTalkLeft
                opacity: 1.0
                enabled: true
            }
            PropertyChanges {
                target: pushToTalkRight
                opacity: 1.0
                enabled: true
            }
        },
        State {
            name: "Listening"
            when: speechChromeController.chromeState == SpeechChromeController.Listening
            PropertyChanges {
                target: chromeBarImage
                opacity: 1.0
                x: 0
            }
            PropertyChanges {
                target: pushToTalkLeft
                opacity: 0.0
                enabled: false
            }
            PropertyChanges {
                target: pushToTalkRight
                opacity: 0.0
                enabled: false
            }
        },
        State {
            name: "Thinking"
            when: speechChromeController.chromeState == SpeechChromeController.Thinking
            PropertyChanges {
                target: chromeBarImage
                opacity: 1.0
                x: root.width - chromeBarImage.width
            }
            PropertyChanges {
                target: pushToTalkLeft
                opacity: 0.0
                enabled: false
            }
            PropertyChanges {
                target: pushToTalkRight
                opacity: 0.0
                enabled: false
            }
        },
        State {
            name: "Speaking"
            when: speechChromeController.chromeState == SpeechChromeController.Speaking
            PropertyChanges {
                target: chromeBarImage
                opacity: 1.0
                x: (root.width - chromeBarImage.width) * 0.5
            }
            PropertyChanges {
                target: pushToTalkLeft
                opacity: 0.0
                enabled: false
            }
            PropertyChanges {
                target: pushToTalkRight
                opacity: 0.0
                enabled: false
            }
        },
        State {
            name: "MicrophoneOff"
            when: speechChromeController.chromeState == SpeechChromeController.MicrophoneOff
            PropertyChanges {
                target: chromeBarImage
                opacity: 0.0
                x: 0
            }
            PropertyChanges {
                target: pushToTalkLeft
                opacity: 1.0
                enabled: true
            }
            PropertyChanges {
                target: pushToTalkRight
                opacity: 1.0
                enabled: true
            }
        }
    ]
}