Guest User

harbour-advanced-camera patch to add a gallery

a guest
Feb 24th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. diff --git a/qml/pages/CameraUI.qml b/qml/pages/CameraUI.qml
  2. index 985a2f7..4dc5d3b 100644
  3. --- a/qml/pages/CameraUI.qml
  4. +++ b/qml/pages/CameraUI.qml
  5. @@ -93,6 +93,39 @@ Page {
  6. imageCapture {
  7. onImageCaptured: {
  8. photoPreview.source = preview // Show the preview in an Image
  9. + console.log("Camera: captured", photoPreview.source)
  10. + }
  11. + onImageSaved: {
  12. + console.log("Camera: image saved") //, photo.source)
  13. + photo.source = "file://" + path
  14. + //modelData.append({ photoPath: "file://" + path, photoMini: photo })
  15. + modelData.append({ photoPath: "file://" + path })
  16. + //modelData.append({ photoMini: photo })
  17. + btnGallery.visible = true
  18. + btnGallery.enabled = true
  19. + }
  20. + }
  21. + }
  22. +
  23. + Image {
  24. + id: photoPreview
  25. +
  26. + onStatusChanged: {
  27. + if (photoPreview.status == Image.Ready) {
  28. + console.log('photoPreview ready')
  29. + }
  30. + }
  31. + }
  32. +
  33. + Image {
  34. + id: photo
  35. + visible: false
  36. +
  37. + onStatusChanged: {
  38. + if (photo.status == Image.Ready) {
  39. + sourceSize: sourceSize / 4
  40. + //modelData.append({ "photoPath": camera.imageCapture.path, "photoMini": photo })
  41. + console.log("photo ready:", source, photo )
  42. }
  43. }
  44. }
  45. @@ -445,6 +478,10 @@ Page {
  46. }
  47. */
  48.  
  49. + ListModel {
  50. + id: modelData
  51. + }
  52. +
  53. Timer {
  54. id: delayQuery
  55. interval: 1000
  56. @@ -608,4 +645,26 @@ Page {
  57.  
  58. return siz.width + "x" + siz.height;
  59. }
  60. +
  61. + RoundButton {
  62. + id: btnGallery
  63. +
  64. + visible: false
  65. + enabled: false
  66. +
  67. + anchors.bottom: parent.bottom
  68. + anchors.bottomMargin: 50
  69. + anchors.right: parent.right
  70. + anchors.rightMargin: 50
  71. +
  72. + height: parent.height / 6
  73. + width: height
  74. +
  75. + image: "image://theme/icon-m-share-gallery"
  76. +
  77. + onClicked: {
  78. + pageStack.push(Qt.resolvedUrl("GalleryUI.qml"), { "photoList": modelData })
  79. + }
  80. + }
  81. +
  82. }
  83.  
  84.  
  85. ####### qml/pages/GalleryUI.qml #####
  86. import QtQuick 2.0
  87. import Sailfish.Silica 1.0
  88. import Sailfish.Media 1.0
  89. import QtMultimedia 5.4
  90. import QtQuick.Layouts 1.0
  91. import uk.co.piggz.harbour_advanced_camera 1.0
  92. import Nemo.Configuration 1.0
  93. import "../components/"
  94.  
  95. Page {
  96. id: galleryPage
  97.  
  98. property var photoList: ({})
  99.  
  100. // The effective value will be restricted by ApplicationWindow.allowedOrientations
  101. allowedOrientations: Orientation.Landscape
  102.  
  103. SlideshowView {
  104. id: gallery
  105.  
  106. clip: true
  107. width: parent.width
  108. height: parent.height
  109. itemWidth: width / 2
  110. itemHeight: height * 2 / 3
  111. y: parent.height / 6
  112.  
  113. model: photoList
  114.  
  115. delegate: Rectangle {
  116. id: delegate
  117. width: gallery.itemWidth
  118. height: gallery.height
  119. border.width: 1
  120. color: 'black'
  121.  
  122. Image {
  123. id: thumbnail
  124. sourceSize.width: parent.width
  125. anchors.fill: parent
  126. fillMode: Image.PreserveAspectFit
  127. //source: photoMini.source
  128. source: photoPath
  129. opacity: 1
  130.  
  131. MouseArea {
  132. anchors.fill: parent
  133. onClicked: {
  134. //TODO: open the photo
  135. console.log("Clicked", thumbnail.source)
  136. Qt.openUrlExternally(thumbnail.source)
  137. }
  138. }
  139. }
  140. /*
  141. Label {
  142. id: lblThumbnail
  143.  
  144. color: 'white'
  145. text: thumbnail.source
  146. }
  147. */
  148. }
  149. }
  150.  
  151.  
  152. }
Advertisement
Add Comment
Please, Sign In to add comment