0a8b9898e1cb75d586b3fdb0e4589ad90297d4b9
[harmattan/cameraplus] / qml / PostCapturePage.qml
1 // -*- qml -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22
23 import QtQuick 1.1
24 import com.nokia.meego 1.1
25 import QtCamera 1.0
26 import QtSparql 1.0
27 import CameraPlus 1.0
28
29 // QML QtGallery stuff is crap.
30 // Most of the ideas (and some code) for loading and displaying images are stolen from
31 // N9QmlPhotoPicker https://github.com/petrumotrescu/N9QmlPhotoPicker
32
33 // TODO: this is really basic.
34 // TODO: Seems losing resources in post capture will not be recovered from.
35
36 CameraPage {
37         id: page
38
39         property Item currentItem: null
40         property Item previousItem: null
41
42         controlsVisible: false
43         policyMode: CameraResources.PostCapture
44         needsPipeline: true
45
46         onCurrentItemChanged: {
47                 if (previousItem) {
48                         previousItem.stop();
49                 }
50
51                 previousItem = currentItem
52         }
53
54         onStatusChanged: {
55                 if (status == PageStatus.Active) {
56                         cam.stop();
57                 }
58         }
59
60         Connections {
61                 // Unlikely that we need this.
62                 target: cam
63                 onIdleChanged: {
64                         if (cam.idle && page.status == PageStatus.Active) {
65                                 cam.stop();
66                         }
67                 }
68         }
69
70         Rectangle {
71                 color: "black"
72                 anchors.fill: parent
73         }
74
75         function stop() {
76                 if (currentItem) {
77                         currentItem.stop();
78                 }
79         }
80
81         PathView {
82                 id: view
83                 anchors.fill: parent
84
85                 path: Path {
86                         startX: 0
87                         startY: view.height / 2
88                         PathLine { x: view.width; y: view.height / 2 }
89                 }
90
91                 flickDeceleration: 999999 // Insanely high value to prevent panning multiple images
92                 preferredHighlightBegin: 0.5
93                 preferredHighlightEnd: 0.5
94                 highlightRangeMode: PathView.StrictlyEnforceRange
95                 pathItemCount: 1
96
97                 model: SparqlListModel {
98                         // This is the exact query used by Harmattan gallery.
99                         // Gallery prints it as part of its debugging when
100                         // passing -output-level debug ;-)
101                         query: "SELECT nie:url(?urn) AS ?url nfo:fileName(?urn) AS ?filename ?created nie:mimeType(?urn) AS ?mimetype ( EXISTS { ?urn nao:hasTag nao:predefined-tag-favorite . } ) AS ?favorite nfo:duration(?urn) AS ?duration ?urn \"false\"^^xsd:boolean AS ?isVirtual nfo:fileLastModified(?urn) as ?lastmod nfo:hasRegionOfInterest(?urn) as ?roi tracker:id(?urn) AS ?trackerid WHERE { ?urn rdf:type nfo:Visual ; tracker:available \"true\"^^xsd:boolean . OPTIONAL { ?urn nie:contentCreated ?created } . ?urn nfo:equipment \"urn:equipment:" + deviceInfo.manufacturer + ":" + deviceInfo.model + ":\" . } ORDER BY DESC (?created)"
102
103                         connection: SparqlConnection {
104                                 id: connection
105                                 driver: "QTRACKER_DIRECT"
106                                 onStatusChanged: checkStatus(status)
107
108                                 function checkStatus(status) {
109                                         if (status == SparqlConnection.Error) {
110                                                 console.log("Error = "+connection.errorString());
111                                         }
112                                 }
113                         }
114                 }
115
116                 delegate: PostCaptureItem {
117                         width: view.width - 10
118                         height: view.height
119                 }
120         }
121
122         ToolBar {
123                 id: toolBar
124                 opacity: 0.8
125                 anchors.bottom: parent.bottom
126                 tools: ToolBarLayout {
127                         id: layout
128                         ToolIcon { iconId: "icon-m-toolbar-back"; onClicked: { page.stop(); pageStack.pop(); } }
129                 }
130         }
131
132         Rectangle {
133                 // TODO: transitions
134                 id: rect
135                 anchors.top: parent.top
136                 height: toolBar.height
137                 width: parent.width
138                 color: "black"
139                 opacity: toolBar.opacity
140                 visible: toolBar.visible
141                 Row {
142                         anchors.fill: parent
143
144                         Label {
145
146                         }
147
148                         Label {
149
150                         }
151                 }
152         }
153 }