blob: f76bc64e6277c9ffa9c19ebd4add22f14f809c52 (
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
import QtQuick 2.0
import QtMultimedia 5.0
import QtQuick.XmlListModel 2.0
FocusScope {
id: scope
x: parent.x; y: parent.y
width: parent.width; height: parent.height
focus: true
property bool active: false
Rectangle {
id: root
width:parent.width
height: parent.height
anchors.centerIn: parent
focus: true
color: "#262626"
Audio {
id: playMusic
source: ""
volume: volumeButton.volume
onSourceChanged: {
if (volumeButton.playing) playMusic.play()
}
onAvailabilityChanged: {
if (availability === Audio.Available) {
if (volumeButton.playing) playMusic.play()
}
}
}
Rectangle {
id: playerRect
anchors.top: volumeButton.top
anchors.left: volumeButton.left
anchors.bottom: volumeButton.bottom
anchors.right: parent.right
anchors.rightMargin: parent.height*.05
gradient: Gradient {
GradientStop {position: .1; color: "lightgrey"}
GradientStop {position: 1.0; color: "white"}
}
border {width:1; color: "#888888"}
radius: height/2
Rectangle {
id: displayRect
anchors.fill: parent
anchors.margins: parent.height*.1
gradient: Gradient {
GradientStop {position: .0; color: "#095477"}
GradientStop {position: 1.0; color: "#052e41"}
}
border {width:1; color: "#888888"}
radius: height/2
PathView {
enabled: root.activeFocus
id: stationList
anchors.fill:parent
anchors.leftMargin: parent.height*.9
model: stationModel
pathItemCount: 6
clip: true
property int openedIndex: -1
onMovementStarted: {
idleTimer.stop()
openedIndex = -1
pathItemCount = 5
}
onMovementEnded: idleTimer.restart()
onOpenedIndexChanged: {
if (openedIndex === -1) return
idleTimer.lastIndex=openedIndex
positionViewAtIndex(openedIndex, PathView.Center)
}
Timer {
id: idleTimer
interval: 5000
property int lastIndex: -1
onTriggered: {
stationList.openedIndex = idleTimer.lastIndex
}
}
Timer {
id: browseTimer
interval: 500
property string source:""
onTriggered: playMusic.source = source
}
path: Path {
startX: stationList.x; startY: 0
PathArc {
id: pathArc
x: stationList.x; relativeY: stationList.height*1.1
radiusX: volumeButton.height/2
radiusY: volumeButton.height/2
useLargeArc: false
}
}
delegate: Item {
id: stationDelegate
property bool opened: stationList.openedIndex === index
width: stationList.width*.7
height: opened? stationList.height*.4: stationList.height*.2
Behavior on height {NumberAnimation{duration:200}}
Text {
id: delegateText
anchors.left: parent.left
anchors.top: parent.top
text: (index+1) +". " +title
font.pixelSize: stationDelegate.opened? stationList.height*.15 : stationList.height*.1
font.weight: stationDelegate.opened? Font.Bold: Font.Normal
color: stationList.openedIndex ===-1 || opened? "white": "#0e82b8"
Behavior on font.pixelSize {NumberAnimation{duration:200}}
}
Text {
id: statustextText
anchors.left: parent.left
anchors.top: delegateText.bottom
text: playMusic.playbackState=== Audio.PlayingState ? "Playing...":
playMusic.status=== Audio.Buffering ? "Buffering...":
playMusic.status=== Audio.Loading ? "Loading...":
playMusic.playbackState=== Audio.StoppedState ? "Stopped":"Error"
font.pixelSize: stationList.height*.1
color: delegateText.color
opacity: opened? 1.0: .0
Behavior on opacity {NumberAnimation{duration:200}}
}
MouseArea {
anchors.fill: parent
visible: root.activeFocus
onClicked: {
if (opened){
idleTimer.lastIndex=-1
stationList.openedIndex=-1
}else {
stationList.openedIndex= index
browseTimer.source = url
browseTimer.restart()
}
}
}
}
}
}
}
XmlListModel {
id: stationModel
source: "channels.xml"
query: "/radio/channel"
XmlRole {name: "title"; query: "title/string()"}
XmlRole {name: "url"; query: "url/string()"}
}
VolumeButton {
id: volumeButton
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: size*.1
size:parent.height*.5
playing: playMusic.playbackState === Audio.PlayingState
onClicked: {
if (!playMusic.source) return;
if (!playing) {
playMusic.play()
}else {
playMusic.stop()
}
}
}
Component.onCompleted: {
volumeButton.init()
scope.focus = true
}
Keys.onPressed: {
if (event.key === Qt.Key_Down || event.key === Qt.Key_VolumeDown) {
event.accepted = true
if (volumeButton.volume > .1){
volumeButton.volume-=.1
}else{
volumeButton.volume = 0.0
}
}
if (event.key === Qt.Key_Up || event.key === Qt.Key_VolumeUp) {
event.accepted = true
if (volumeButton.volume < .9){
volumeButton.volume+=.1
}else{
volumeButton.volume = 1.0
}
}
}
}
}
|