]> git.tdb.fi Git - xinema.git/blobdiff - remote/qml/pages/BrowsePage.qml
Add a remote control program for Sailfish OS
[xinema.git] / remote / qml / pages / BrowsePage.qml
diff --git a/remote/qml/pages/BrowsePage.qml b/remote/qml/pages/BrowsePage.qml
new file mode 100644 (file)
index 0000000..59ebff3
--- /dev/null
@@ -0,0 +1,106 @@
+import QtQuick 2.0
+import Sailfish.Silica 1.0
+import fi.mikkosoft.xinema 0.1
+
+Page
+{
+       id: page
+
+       SilicaFlickable
+       {
+               anchors.fill: parent
+               contentHeight: column.height
+
+               Column
+               {
+                       id: column
+
+                       width: parent.width
+                       spacing: Theme.paddingLarge
+
+                       PageHeader
+                       {
+                               title: qsTr("Browse files")
+                       }
+
+                       // This really should be SilicaListView, but I can't figure out an
+                       // easy way to turn the string lists into a suitable ListModel
+                       Column
+                       {
+                               width: parent.width
+                               spacing: Theme.paddingSmall
+
+                               DirectoryEntry
+                               {
+                                       visible: browseDirectory.directory!="/"
+                                       icon: "image://theme/icon-m-back"
+                                       text: ".."
+                                       onPressed:
+                                       {
+                                               var newDir = browseDirectory.directory;
+                                               var slash = newDir.lastIndexOf("/");
+                                               if(slash>0)
+                                                       newDir = newDir.substring(0, slash);
+                                               else
+                                                       newDir = "/";
+                                               browseDirectory.directory = newDir;
+                                       }
+                               }
+
+                               Repeater
+                               {
+                                       model: browseDirectory.subdirectories
+
+                                       DirectoryEntry
+                                       {
+                                               icon: "image://theme/icon-m-folder"
+                                               text: modelData
+
+                                               onPressed:
+                                               {
+                                                       var newDir = browseDirectory.directory;
+                                                       if(newDir!="/")
+                                                               newDir += "/";
+                                                       newDir += modelData;
+                                                       browseDirectory.directory = newDir;
+                                               }
+                                       }
+                               }
+
+                               Repeater
+                               {
+                                       model: browseDirectory.files
+                                       DirectoryEntry
+                                       {
+                                               text: modelData
+
+                                               onPressed: xinemaControl.play_file(browseDirectory.directory+"/"+modelData);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       BrowseDirectory
+       {
+               id: browseDirectory
+               control: xinemaControl
+       }
+
+       Connections
+       {
+               target: xinemaControl
+               onConnectedChanged:
+               {
+                       if(xinemaControl.connected)
+                               browseDirectory.directory = "/";
+               }
+       }
+
+       Component.onCompleted:
+       {
+               if(xinemaControl.connected)
+                       browseDirectory.directory = "/";
+       }
+}
+