David Mugnai avatar David Mugnai committed 67485f7

PhotoGrid connected to Zoom

A new signal, imageSelected, is emitted by the PhotoGrid whenever
an image is clicked

Comments (0)

Files changed (2)

             onClicked: zoom.show({
                 title: "XXX",
                 date: null,
-                url: "http://apod.nasa.gov/apod/image/1209/airglow120824_ladanyi_1800px.jpg",
+                image: "http://apod.nasa.gov/apod/image/1209/airglow120824_ladanyi_1800px.jpg",
                 explanation: "<a href=\"http://www.google.com/\">ggg</a>"});
         }
     }
         }
         Image {
             id: image
+            fillMode: Image.PreserveAspectFit
             anchors {
                 fill: parent
                 margins: 60
             }
             Text {
                 id: explanation
-                height: 150
                 color: "#ffffff"
                 font {
                     pointSize: 8
-                    family: "Impact"
+                    family: "Verdana"
                 }
+                textFormat: Text.RichText
+                wrapMode: Text.Wrap
                 anchors {
                     right: parent.right
                     bottom: parent.bottom
         }
 
         function show(data) {
-            image.source = data.url
+            image.source = data.image
             explanation.text = data.explanation
             title.text = data.title
             zoom.visible = true
         width: 795
         height: 658
         color: "green"
+        onImageSelected: zoom.show(data)
     }
 }

qml/PhotoGrid.qml

         width: 1
     }
 
+    signal imageSelected(variant data);
+
     Component {
         id: gridComponent
         Rectangle {
             id: grid
 
             property alias model: grid_view1.model
+
             color: "red"
             z: 1
             clip: true
                             verticalCenter: parent.verticalCenter
                         }
                         fillMode: Image.Stretch
+                        MouseArea {
+                            anchors {
+                                fill: parent
+                            }
+                            onClicked: container.imageSelected({
+                                title: model.display,
+                                date: model.date,
+                                explanation: model.explanation,
+                                image: model.image})
+                        }
                     }
                 }
             }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.