]> git.tdb.fi Git - xinema.git/blob - remote/qml/pages/BrowsePage.qml
Add a remote control program for Sailfish OS
[xinema.git] / remote / qml / pages / BrowsePage.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 import fi.mikkosoft.xinema 0.1
4
5 Page
6 {
7         id: page
8
9         SilicaFlickable
10         {
11                 anchors.fill: parent
12                 contentHeight: column.height
13
14                 Column
15                 {
16                         id: column
17
18                         width: parent.width
19                         spacing: Theme.paddingLarge
20
21                         PageHeader
22                         {
23                                 title: qsTr("Browse files")
24                         }
25
26                         // This really should be SilicaListView, but I can't figure out an
27                         // easy way to turn the string lists into a suitable ListModel
28                         Column
29                         {
30                                 width: parent.width
31                                 spacing: Theme.paddingSmall
32
33                                 DirectoryEntry
34                                 {
35                                         visible: browseDirectory.directory!="/"
36                                         icon: "image://theme/icon-m-back"
37                                         text: ".."
38                                         onPressed:
39                                         {
40                                                 var newDir = browseDirectory.directory;
41                                                 var slash = newDir.lastIndexOf("/");
42                                                 if(slash>0)
43                                                         newDir = newDir.substring(0, slash);
44                                                 else
45                                                         newDir = "/";
46                                                 browseDirectory.directory = newDir;
47                                         }
48                                 }
49
50                                 Repeater
51                                 {
52                                         model: browseDirectory.subdirectories
53
54                                         DirectoryEntry
55                                         {
56                                                 icon: "image://theme/icon-m-folder"
57                                                 text: modelData
58
59                                                 onPressed:
60                                                 {
61                                                         var newDir = browseDirectory.directory;
62                                                         if(newDir!="/")
63                                                                 newDir += "/";
64                                                         newDir += modelData;
65                                                         browseDirectory.directory = newDir;
66                                                 }
67                                         }
68                                 }
69
70                                 Repeater
71                                 {
72                                         model: browseDirectory.files
73                                         DirectoryEntry
74                                         {
75                                                 text: modelData
76
77                                                 onPressed: xinemaControl.play_file(browseDirectory.directory+"/"+modelData);
78                                         }
79                                 }
80                         }
81                 }
82         }
83
84         BrowseDirectory
85         {
86                 id: browseDirectory
87                 control: xinemaControl
88         }
89
90         Connections
91         {
92                 target: xinemaControl
93                 onConnectedChanged:
94                 {
95                         if(xinemaControl.connected)
96                                 browseDirectory.directory = "/";
97                 }
98         }
99
100         Component.onCompleted:
101         {
102                 if(xinemaControl.connected)
103                         browseDirectory.directory = "/";
104         }
105 }
106