4 * This file is part of CameraPlus.
6 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
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.
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.
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
24 import com.nokia.meego 1.1
27 import "data.js" as Data
33 property bool animationRunning: false
34 property int policyMode: CameraResources.Image
35 property bool pressed: capture.pressed || zoomSlider.pressed || modeButton.pressed
36 property bool controlsVisible: imageMode.canCapture && cam.running && !animationRunning
37 && dimmer.opacity == 0.0 && !cameraMode.busy
39 signal previewAvailable(string uri)
47 overlay.previewAvailable(preview)
48 cam.autoFocus.stopAutoFocus()
51 onSaved: mountProtector.unlock()
57 anchors.top: parent.top
59 anchors.horizontalCenter: parent.horizontalCenter
60 visible: controlsVisible
65 anchors.bottom: parent.bottom
66 anchors.right: parent.right
67 anchors.rightMargin: 20
68 anchors.bottomMargin: 20
69 visible: controlsVisible
74 anchors.right: parent.right
75 anchors.rightMargin: 20
76 anchors.verticalCenter: parent.verticalCenter
77 iconSource: "image://theme/icon-m-camera-shutter"
81 onClicked: captureImage()
82 visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
85 if (mouseX <= 0 || mouseY <= 0 || mouseX > width || mouseY > height) {
86 // Release outside the button:
87 cam.autoFocus.stopAutoFocus()
95 running: capture.pressed || zoomCapture.zoomPressed
98 if (cam.autoFocus.cafStatus != AutoFocus.Success) {
99 cam.autoFocus.startAutoFocus()
106 onReleased: parent.captureImage()
111 zoomCapture: zoomCapture
113 if (!autoFocusTimer.running) {
114 cam.autoFocus.stopAutoFocus()
121 anchors.bottom: parent.bottom
122 anchors.bottomMargin: 20
123 anchors.left: parent.left
124 anchors.leftMargin: 20
126 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
127 visible: controlsVisible
128 expanded: settings.showToolBar
129 onExpandedChanged: settings.showToolBar = expanded
132 onClicked: toolBar.push(items)
135 onClicked: toolBar.push(items)
138 onClicked: toolBar.push(items)
140 ImageWhiteBalanceButton {
141 onClicked: toolBar.push(items)
143 ImageColorFilterButton {
144 onClicked: toolBar.push(items)
147 onClicked: toolBar.push(items)
154 anchors.top: parent.top
155 anchors.topMargin: 20
156 anchors.left: parent.left
157 anchors.leftMargin: 20
164 visible: controlsVisible
172 id: resolutionIndicator
173 source: "image://theme/" + Data.imageIcon(settings.imageAspectRatio, settings.imageResolution)
178 source: visible ? "image://theme/" + Data.wbIcon(settings.imageWhiteBalance) + "-screen" : ""
179 visible: settings.imageWhiteBalance != WhiteBalance.Auto
184 source: "image://theme/" + Data.cfIcon(settings.imageColorFilter) + "-screen"
185 visible: settings.imageColorFilter != ColorTone.Normal
190 visible: settings.imageIso != 0
191 source: "image://theme/" + Data.isoIcon(settings.imageIso)
196 visible: settings.useGps
197 source: "image://theme/icon-m-camera-location"
199 PropertyAnimation on opacity {
200 easing.type: Easing.OutSine
201 loops: Animation.Infinite
205 running: settings.useGps && !positionSource.position.longitudeValid
211 id: faceDetectionIndicator
212 visible: settings.faceDetectionEnabled
213 source: "image://theme/icon-m-camera-face-detection-screen"
219 function cameraError() {
220 mountProtector.unlock()
223 function policyLost() {
227 function batteryLow() {
231 function captureImage() {
232 if (!imageMode.canCapture) {
233 showError(qsTr("Camera is already capturing an image."))
234 } else if (!checkBattery()) {
235 showError(qsTr("Not enough battery to capture images."))
236 } else if (!fileSystem.available) {
237 showError(qsTr("Camera cannot capture images in mass storage mode."))
238 } else if (!checkDiskSpace()) {
239 showError(qsTr("Not enough space to capture images."))
240 } else if (!mountProtector.lock()) {
241 showError(qsTr("Failed to lock images directory."))
243 metaData.setMetaData()
245 var fileName = fileNaming.imageFileName()
246 if (!imageMode.capture(fileName)) {
247 showError(qsTr("Failed to capture image. Please restart the camera."))
248 mountProtector.unlock()
250 trackerStore.storeImage(fileName)