]> git.tdb.fi Git - xinema.git/blob - remote/qml/pages/ChannelSelect.qml
Use filename as a fallback title if the stream doesn't have one
[xinema.git] / remote / qml / pages / ChannelSelect.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3
4 ValueButton
5 {
6         id: channelSelect
7
8         property var channels: null
9         property int currentChannel: -1
10         property bool _channelsAvailable: channels && channels.length
11         enabled: _channelsAvailable
12
13         value: (_channelsAvailable ? currentChannel>=0 ? (currentChannel+1)+": "+channels[currentChannel] : "0: (off)" : "(not available)")
14
15         onClicked:
16         {
17                 if(_channelsAvailable)
18                         pageStack.push(selectDialog);
19         }
20
21         Component
22         {
23                 id: selectDialog
24
25                 Page
26                 {
27                         id: page
28
29                         function selectChannel(index)
30                         {
31                                 channelSelect.currentChannel = index;
32                                 pageStack.pop();
33                         }
34
35                         SilicaFlickable
36                         {
37                                 width: parent.width
38                                 contentHeight: column.height
39
40                                 Column
41                                 {
42                                         id: column
43                                         width: parent.width
44                                         spacing: Theme.paddingLarge
45
46                                         PageHeader
47                                         {
48                                                 id: header
49                                                 title: channelSelect.label
50                                         }
51
52                                         ChannelItem
53                                         {
54                                                 channelIndex: 0
55                                                 channelName: "(off)"
56                                                 down: channelSelect.currentChannel+1==channelIndex
57
58                                                 onClicked: page.selectChannel(channelIndex-1);
59                                         }
60                                         Repeater
61                                         {
62                                                 id: repeater
63                                                 model: channelSelect.channels
64
65                                                 ChannelItem
66                                                 {
67                                                         channelIndex: index+1
68                                                         channelName: modelData
69                                                         down: channelSelect.currentChannel+1==channelIndex
70
71                                                         onClicked: page.selectChannel(channelIndex-1);
72                                                 }
73                                         }
74                                 }
75                         }
76                 }
77         }
78 }