FileListPage.qml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. /**
  2. * Copyright (c) 2011-2012 Nokia Corporation.
  3. */
  4. import QtQuick 1.1
  5. import com.nokia.symbian 1.1
  6. import "SymbianUIConstants.js" as Constants
  7. Page {
  8. id: fileListPage
  9. // For keeping track of the currently browsed content type
  10. property int contentType: Constants.ContentType.Images;
  11. // Flag indicating if memory card is detected
  12. property bool memoryCardPresent: false
  13. // Folder that the phone memory folder list is about to switch to
  14. property string phoneMemoryFolderToGo
  15. // Folder that the memory card folder list is about to switch to
  16. property string memoryCardFolderToGo
  17. property bool initialized: false;
  18. tools: ToolBarLayout {
  19. ToolButton {
  20. flat: true
  21. iconSource: "toolbar-back"
  22. onClicked: {
  23. // Exit the application
  24. Qt.quit();
  25. }
  26. }
  27. ButtonRow {
  28. id: buttonsRow
  29. TabButton {
  30. id: imagesButton
  31. checked: (contentType == Constants.ContentType.Images)
  32. iconSource: "qrc:/images-icon.png"
  33. onClicked: {
  34. var path = fileHelper.phoneMemoryImagesPath;
  35. phoneMemoryFolderList.goToFolder(fileHelper.pathUrl(path));
  36. path = fileHelper.memoryCardImagesPath;
  37. memoryCardFolderList.goToFolder(fileHelper.pathUrl(path));
  38. contentType = Constants.ContentType.Images;
  39. }
  40. }
  41. TabButton {
  42. id: soundsButton
  43. checked: (contentType == Constants.ContentType.Sounds)
  44. iconSource: "qrc:/sounds-icon.png"
  45. onClicked: {
  46. var path = fileHelper.phoneMemorySoundsPath;
  47. phoneMemoryFolderList.goToFolder(fileHelper.pathUrl(path));
  48. path = fileHelper.memoryCardSoundsPath;
  49. memoryCardFolderList.goToFolder(fileHelper.pathUrl(path));
  50. contentType = Constants.ContentType.Sounds;
  51. }
  52. }
  53. TabButton {
  54. id: videosButton
  55. checked: (contentType == Constants.ContentType.Videos)
  56. iconSource: "qrc:/videos-icon.png"
  57. onClicked: {
  58. var path = fileHelper.phoneMemoryVideosPath;
  59. phoneMemoryFolderList.goToFolder(fileHelper.pathUrl(path));
  60. path = fileHelper.memoryCardVideosPath;
  61. memoryCardFolderList.goToFolder(fileHelper.pathUrl(path));
  62. contentType = Constants.ContentType.Videos;
  63. }
  64. }
  65. }
  66. }
  67. Image{
  68. anchors.fill: parent
  69. source: "qrc:/background.svg"
  70. }
  71. ScrollDecorator {
  72. flickableItem: flick
  73. }
  74. // Main flickable component
  75. Flickable{
  76. id: flick
  77. clip: true
  78. anchors {
  79. top: parent.top;
  80. left: parent.left
  81. right: parent.right
  82. bottom: parent.bottom
  83. }
  84. contentHeight: col.implicitHeight
  85. Column{
  86. id: col
  87. width: parent.width
  88. // Phone mmory folder list
  89. FolderList {
  90. id: phoneMemoryFolderList
  91. width: parent.width
  92. visible: false
  93. onFolderSelected: {
  94. pageStack.push(Qt.resolvedUrl("SubFolderPage.qml"), { folder: folder });
  95. }
  96. onFileSelected: {
  97. // Try to open the selected file
  98. if (!fileHelper.openUrl(file)) {
  99. console.debug("FileListPage.qml: " +
  100. "phoneMemoryFolderList::onFileSelected: Failed to open",
  101. file);
  102. }
  103. }
  104. function goToFolder(folder)
  105. {
  106. phoneMemoryFolderToGo = folder;
  107. flickableAnimation.restart();
  108. }
  109. }
  110. // Memory card folder list
  111. FolderList {
  112. id: memoryCardFolderList
  113. width: parent.width
  114. visible: false
  115. onFolderSelected: {
  116. pageStack.push(Qt.resolvedUrl("SubFolderPage.qml"), { folder: folder });
  117. }
  118. onFileSelected: {
  119. // Try to open the selected file
  120. if (!fileHelper.openUrl(file)) {
  121. console.debug("FileListPage.qml: " +
  122. "folderList::onFileSelected: Failed to open",
  123. file);
  124. }
  125. }
  126. function goToFolder(folder)
  127. {
  128. memoryCardFolderToGo = folder;
  129. flickableAnimation.restart();
  130. }
  131. }
  132. // Memory available space section
  133. Item{
  134. id: memoryAvailableItem
  135. width: parent.width
  136. height: childrenRect.height
  137. visible: false
  138. Column{
  139. width: parent.width
  140. ListHeading {
  141. id: listHeading
  142. width: parent.width
  143. ListItemText {
  144. anchors.fill: listHeading.paddingItem
  145. role: "Heading"
  146. text: "Memory Available"
  147. }
  148. }
  149. // Phone memory free and total space item
  150. ListItem {
  151. Column {
  152. anchors.fill: parent.paddingItem
  153. width: parent.width
  154. ListItemText {
  155. role: "Title"
  156. text: fileHelper.phoneMemoryImagesPath[0] + " (Phone memory)"
  157. }
  158. ListItemText {
  159. role: "SubTitle"
  160. text: fileHelper.phoneMemoryFreeAndTotalSpace()
  161. }
  162. }
  163. }
  164. // Memory card free and total space item
  165. ListItem {
  166. visible: memoryCardPresent
  167. Column {
  168. anchors.fill: parent.paddingItem
  169. width: parent.width
  170. ListItemText {
  171. role: "Title"
  172. text: fileHelper.memoryCardImagesPath[0] + " (Mass memory)"
  173. }
  174. // Sub title displaying the size and the date
  175. ListItemText {
  176. role: "SubTitle"
  177. text: fileHelper.memoryCardFreeAndTotalSpace()
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. }
  185. Timer{
  186. id: delayTimer
  187. interval: 500
  188. onTriggered: {
  189. console.log("timer triggered");
  190. fadeInAnimation.start();
  191. }
  192. }
  193. // fade in/out animation
  194. SequentialAnimation {
  195. id: flickableAnimation
  196. PropertyAnimation {
  197. target: flick
  198. property: "opacity"; to: 0;
  199. duration: Constants.DEFAULT_ANIM_DURATION
  200. }
  201. PropertyAction{
  202. target: phoneMemoryFolderList
  203. property: "folder"
  204. value: phoneMemoryFolderToGo
  205. }
  206. PropertyAction{
  207. target: memoryCardFolderList
  208. property: "folder"
  209. value: memoryCardFolderToGo
  210. }
  211. PropertyAction{
  212. targets: phoneMemoryFolderList
  213. property: "showNoFilesItem"
  214. value: true
  215. }
  216. PropertyAction{
  217. target: memoryCardFolderList
  218. property: "showNoFilesItem"
  219. value: true
  220. }
  221. PropertyAction{
  222. targets: [phoneMemoryFolderList, memoryAvailableItem]
  223. property: "visible"
  224. value: true
  225. }
  226. PropertyAction{
  227. targets: memoryCardFolderList
  228. property: "visible"
  229. value: memoryCardPresent ? true : false
  230. }
  231. onCompleted:{
  232. console.log("Sequential animation completed");
  233. delayTimer.start();
  234. console.log("Memory card present: " + memoryCardPresent);
  235. }
  236. }
  237. PropertyAnimation {
  238. id: fadeInAnimation
  239. target: flick
  240. property: "opacity"; to: 1.0;
  241. duration: Constants.DEFAULT_ANIM_DURATION
  242. }
  243. Component.onCompleted: {
  244. console.log("Component completed");
  245. // Navigate to images folders in the start-up.
  246. var path = fileHelper.pathUrl(fileHelper.phoneMemoryImagesPath);
  247. phoneMemoryFolderList.goToFolder(path);
  248. memoryCardPresent = fileHelper.memoryCardPresent
  249. if(memoryCardPresent){
  250. path = fileHelper.pathUrl(fileHelper.memoryCardImagesPath);
  251. memoryCardFolderList.goToFolder(path);
  252. }
  253. else
  254. memoryCardFolderList.visible = false;
  255. initialized = true;
  256. }
  257. onStatusChanged: {
  258. if(status == PageStatus.Active){
  259. switch (contentType)
  260. {
  261. case Constants.ContentType.Images:
  262. buttonsRow.checkedButton = imagesButton;;
  263. break;
  264. case Constants.ContentType.Sounds:
  265. buttonsRow.checkedButton = soundsButton;
  266. break;
  267. case Constants.ContentType.Videos:
  268. buttonsRow.checkedButton = videosButton;
  269. break;
  270. }
  271. }
  272. }
  273. }
  274. // End of file.