Guest User

Untitled

a guest
Mar 2nd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.11 KB | None | 0 0
  1. diff --git a/qml/pages/CameraUI.qml b/qml/pages/CameraUI.qml
  2. index bcb9cbf..abfd0d2 100644
  3. --- a/qml/pages/CameraUI.qml
  4. +++ b/qml/pages/CameraUI.qml
  5. @@ -58,7 +58,7 @@ Page {
  6. }
  7. onImageSaved: {
  8. console.log("Camera: image saved", path)
  9. - galleryModel.append({ photoPath: "file://" + path })
  10. + galleryModel.append({ photoPath: path })
  11. }
  12. }
  13. }
  14. diff --git a/qml/pages/GalleryUI.qml b/qml/pages/GalleryUI.qml
  15. index 9dd7284..ea6d873 100644
  16. --- a/qml/pages/GalleryUI.qml
  17. +++ b/qml/pages/GalleryUI.qml
  18. @@ -1,5 +1,6 @@
  19. import QtQuick 2.0
  20. import Sailfish.Silica 1.0
  21. +import Nemo.FileManager 1.0
  22.  
  23. Page {
  24. id: galleryPage
  25. @@ -9,6 +10,129 @@ Page {
  26. // The effective value will be restricted by ApplicationWindow.allowedOrientations
  27. allowedOrientations: Orientation.All
  28.  
  29. + backNavigation: false
  30. +
  31. + WorkerScript {
  32. + id: worker
  33. + source: Qt.resolvedUrl("js/workersync.mjs")
  34. + }
  35. +
  36. + Connections {
  37. + target: FileEngine
  38. + onFileDeleted: cleanupGallery()
  39. + }
  40. +
  41. + function removeFile(idx) {
  42. + console.log("Removing", photoList.get(idx).photoPath)
  43. + FileEngine.deleteFiles([photoList.get(idx).photoPath])
  44. + photoList.remove(idx)
  45. + worker.sendMessage({"model" : photoList})
  46. + }
  47. +
  48. + function cleanupGallery() {
  49. + console.log("Cleanup after file removal")
  50. + console.log("Gallery has", gallery.count, "items now and photoList has", photoList.count, "items now !")
  51. + if (gallery.count === 0) {
  52. + console.log("Zero gallery.count detected, closing gallery !")
  53. + pageStack.pop()
  54. + }
  55. + }
  56. +
  57. + Rectangle {
  58. + id: boxTop
  59. +
  60. + z: 99
  61. + visible: true
  62. + width: parent.width
  63. + height: parent.height / 6
  64. + color: "transparent"
  65. +
  66. + IconButton {
  67. + id: btnInfo
  68. + enabled: false
  69. +
  70. + icon.source: "image://theme/icon-m-about"
  71. +
  72. + anchors {
  73. + top: parent.top
  74. + topMargin: Theme.paddingMedium
  75. + left: parent.left
  76. + leftMargin: Theme.paddingMedium
  77. + }
  78. +
  79. + onClicked: {
  80. + console.log("Clicked info button")
  81. + }
  82. + }
  83. +
  84. + IconButton {
  85. + id: btnClose
  86. +
  87. + icon.source: "image://theme/icon-m-close"
  88. +
  89. + anchors {
  90. + top: parent.top
  91. + topMargin: Theme.paddingMedium
  92. + right: parent.right
  93. + rightMargin: Theme.paddingMedium
  94. + }
  95. +
  96. + onClicked: {
  97. + console.log("Clicked close button")
  98. + parent.visible = false
  99. + pageStack.pop()
  100. + }
  101. + }
  102. + }
  103. +
  104. + Rectangle {
  105. + id: boxBottom
  106. +
  107. + z: 99
  108. + visible: true
  109. + width: parent.width
  110. + height: parent.height / 6
  111. + color: "transparent"
  112. +
  113. + anchors.bottom: parent.bottom
  114. +
  115. + IconButton {
  116. + id: btnRemove
  117. +
  118. + icon.source: "image://theme/icon-m-delete"
  119. +
  120. + anchors {
  121. + top: parent.top
  122. + topMargin: Theme.paddingMedium
  123. + right: parent.horizontalCenter
  124. + rightMargin: Theme.paddingMedium
  125. + }
  126. +
  127. + onClicked: {
  128. + console.log("Clicked delete button, gallery has", gallery.count, "items...")
  129. + removeFile(gallery.currentIndex)
  130. + }
  131. + }
  132. +
  133. + IconButton {
  134. + id: btnShare
  135. + enabled: false
  136. +
  137. + icon.source: "image://theme/icon-m-share"
  138. +
  139. + anchors {
  140. + top: parent.top
  141. + topMargin: Theme.paddingMedium
  142. + left: parent.horizontalCenter
  143. + leftMargin: Theme.paddingMedium
  144. + }
  145. +
  146. + onClicked: {
  147. + console.log("Clicked share button")
  148. + }
  149. + }
  150. + }
  151. +
  152. SlideshowView {
  153. id: gallery
  154.  
  155. @@ -32,13 +156,14 @@ Page {
  156. sourceSize.width: parent.width
  157. anchors.fill: parent
  158. fillMode: Image.PreserveAspectFit
  159. - source: photoPath
  160. + source: "file://" + photoPath
  161.  
  162. MouseArea {
  163. anchors.fill: parent
  164. onClicked: {
  165. console.log("Clicked", thumbnail.source)
  166. - Qt.openUrlExternally(thumbnail.source)
  167. + boxTop.visible = boxTop.visible ? false : true
  168. + boxBottom.visible = boxTop.visible
  169. }
  170. }
  171. }
  172. diff --git a/qml/pages/js/workersync.mjs b/qml/pages/js/workersync.mjs
  173. new file mode 100644
  174. index 0000000..01dc476
  175. --- /dev/null
  176. +++ b/qml/pages/js/workersync.mjs
  177. @@ -0,0 +1,4 @@
  178. +WorkerScript.onMessage = function(msg) {
  179. + console.log("Syncing", msg.model, "model...");
  180. + msg.model.sync();
  181. +}
Advertisement
Add Comment
Please, Sign In to add comment