summaryrefslogtreecommitdiffstats
path: root/homescreen/qml/SpeechChrome.qml
blob: 911d481b31d53efbf7763de042b4744a249d0b15 (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
import QtQuick 2.0
import SpeechChrome 1.0

Item {
    id: root

    clip: true

    property bool agentPresent: speechChromeController.agentPresent

    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: pushToTalk

        height: parent.height * 0.80
        width: height

        anchors.left: parent.left
        anchors.leftMargin: parent.width / 128
        anchors.verticalCenter: parent.verticalCenter
        source: "./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: pushToTalk
                opacity: 1.0
                enabled: true
            }
        },
        State {
            name: "Listening"
            when: speechChromeController.chromeState == SpeechChromeController.Listening
            PropertyChanges {
                target: chromeBarImage
                opacity: 1.0
                x: 0
            }
            PropertyChanges {
                target: pushToTalk
                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: pushToTalk
                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: pushToTalk
                opacity: 0.0
                enabled: false
            }
        },
        State {
            name: "MicrophoneOff"
            when: speechChromeController.chromeState == SpeechChromeController.MicrophoneOff
            PropertyChanges {
                target: chromeBarImage
                opacity: 0.0
                x: 0
            }
            PropertyChanges {
                target: pushToTalk
                opacity: 1.0
                enabled: true
            }
        }
    ]
}