Added TrackerStore to be used for creating a virtual file before image/video gets...
[harmattan/cameraplus] / qml / ImagePage.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 CameraPlus 1.0
27 import "data.js" as Data
28
29 CameraPage {
30         id: page
31
32         policyMode: CameraResources.Image
33         controlsVisible: capture.visible && cam.running && !standbyWidget.visible
34
35         orientationLock: PageOrientation.LockLandscape
36
37         Button {
38                 id: capture
39                 anchors.right: parent.right
40                 anchors.rightMargin: 20
41                 anchors.verticalCenter: parent.verticalCenter
42                 iconSource: "image://theme/icon-m-camera-shutter"
43                 width: 75
44                 height: 75
45                 opacity: 0.5
46                 onClicked: {
47                         if (!checkBattery()) {
48                                 showError(qsTr("Not enough battery to capture images."));
49                                 return;
50                         }
51
52                         if (!checkDiskSpace()) {
53                                 showError(qsTr("Not enough space to capture images."));
54                                 return;
55                         }
56
57                         if (!fileSystem.available) {
58                                 showError(qsTr("Camera cannot capture images in mass storage mode."));
59                                 return;
60                         }
61
62                         if (!mountProtector.lock()) {
63                                 showError(qsTr("Failed to lock images directory."));
64                                 return;
65                         }
66
67                         metaData.setMetaData();
68
69                         var fileName = fileNaming.imageFileName();
70                         if (!imageMode.capture(fileName)) {
71                                 showError(qsTr("Failed to capture image. Please restart the camera."));
72                                 return;
73                         }
74
75                         trackerStore.storeImage(fileName);
76                 }
77
78                 visible: imageMode.canCapture && !cameraMode.animationRunning && !previewAnimationRunning && cam.running
79         }
80
81         ImageMode {
82                 id: imageMode
83                 camera: cam
84                 onPreviewAvailable: page.setPreview(preview);
85                 onSaved: mountProtector.unlock();
86         }
87
88         FlashButton {
89                 id: flash
90                 visible: controlsVisible
91                 anchors.top: parent.top
92                 anchors.left: parent.left
93                 anchors.topMargin: 20
94                 anchors.leftMargin: 20
95         }
96
97         ImageSceneButton {
98                 id: scene
99                 visible: controlsVisible
100                 anchors.top: flash.bottom
101                 anchors.left: parent.left
102                 anchors.topMargin: 10
103                 anchors.leftMargin: 20
104         }
105
106         ImageEvCompButton {
107                 id: evComp
108                 visible: controlsVisible
109                 anchors.top: scene.bottom
110                 anchors.left: parent.left
111                 anchors.topMargin: 10
112                 anchors.leftMargin: 20
113         }
114
115         MouseArea {
116                 id: indicators
117                 anchors.bottom: parent.bottom
118                 anchors.bottomMargin: 20
119                 anchors.left: parent.left
120                 anchors.leftMargin: 20
121                 width: 48
122                 height: col.height
123                 onClicked: openFile("ImageSettingsPage.qml");
124                 visible: controlsVisible
125
126                 BorderImage {
127                         id: image
128                         anchors.fill: parent
129                         smooth: true
130                         source: indicators.pressed ? "image://theme/meegotouch-camera-settings-indicators-background-pressed" : "image://theme/meegotouch-camera-settings-indicators-background"
131                 }
132
133                 Column {
134                         id: col
135                         width: parent.width
136                         spacing: 5
137
138                         Indicator {
139                                 id: resolutionIndicator
140                                 source: "image://theme/" + Data.imageIcon(settings.imageAspectRatio, settings.imageResolution);
141                         }
142
143                         Indicator {
144                                 id: wbIndicator
145                                 source: "image://theme/" + Data.wbIcon(settings.imageWhiteBalance) + "-screen"
146                                 visible: settings.imageWhiteBalance != WhiteBalance.Auto
147                         }
148
149                         Indicator {
150                                 id: cfIndicator
151                                 source: "image://theme/" + Data.cfIcon(settings.imageColorFilter) + "-screen"
152                                 visible: settings.imageColorFilter != ColorTone.Normal
153                         }
154
155                         Indicator {
156                                 id: isoIndicator
157                                 visible: settings.imageIso != 0
158                                 source: "image://theme/" + Data.isoIcon(settings.imageIso);
159                         }
160
161                         Indicator {
162                                 id: gpsIndicator
163                                 visible: settings.useGps
164                                 source: "image://theme/icon-m-camera-location"
165
166                                 PropertyAnimation on opacity  {
167                                         easing.type: Easing.OutSine
168                                         loops: Animation.Infinite
169                                         from: 0.2
170                                         to: 1.0
171                                         duration: 1000
172                                         running: settings.useGps && !positionSource.position.longitudeValid
173                                         alwaysRunToEnd: true
174                                 }
175                         }
176                 }
177         }
178
179         Button {
180                 id: cameraRoll
181                 anchors.top: parent.top
182                 anchors.right: parent.right
183                 anchors.topMargin: 20
184                 anchors.rightMargin: 20
185                 width: 56
186                 height: 56
187
188                 opacity: 0.5
189                 iconSource: "image://theme/icon-m-camera-roll"
190                 onClicked: openFile("PostCapturePage.qml");
191                 visible: controlsVisible
192         }
193 }