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
31 property bool animationRunning: false
32 property int policyMode: CameraResources.Image
33 property bool pressed: capture.pressed || zoomSlider.pressed || modeButton.pressed
34 property bool controlsVisible: imageMode.canCapture && cam.running && !animationRunning
35 && dimmer.opacity == 0.0 && !cameraMode.busy
37 signal previewAvailable(string uri)
45 onCaptureEnded: stopAutoFocus()
47 onPreviewAvailable: overlay.previewAvailable(preview)
49 onSaved: mountProtector.unlock(fileNaming.imagePath)
55 anchors.top: parent.top
57 anchors.horizontalCenter: parent.horizontalCenter
58 visible: controlsVisible
63 anchors.bottom: parent.bottom
64 anchors.right: parent.right
65 anchors.rightMargin: 20
66 anchors.bottomMargin: 20
67 visible: controlsVisible
72 anchors.right: parent.right
73 anchors.rightMargin: 20
74 anchors.verticalCenter: parent.verticalCenter
75 iconSource: cameraTheme.captureButtonImageIconId
79 onClicked: captureImage()
80 visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
83 if (mouseX <= 0 || mouseY <= 0 || mouseX > width || mouseY > height) {
84 // Release outside the button:
93 running: capture.pressed || zoomCapture.zoomPressed
96 if (cam.autoFocus.cafStatus != AutoFocus.Success) {
104 onReleased: parent.captureImage()
109 zoomCapture: zoomCapture
111 if (!autoFocusTimer.running) {
119 anchors.bottom: parent.bottom
120 anchors.bottomMargin: 20
121 anchors.left: parent.left
122 anchors.leftMargin: 20
124 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
125 visible: controlsVisible
126 expanded: settings.showToolBar
127 onExpandedChanged: settings.showToolBar = expanded
128 tools: CameraToolBarTools {
130 onClicked: toolBar.push(tools)
134 onClicked: toolBar.push(tools)
138 onClicked: toolBar.push(tools)
141 ImageWhiteBalanceButton {
142 onClicked: toolBar.push(tools)
145 ImageColorFilterButton {
146 onClicked: toolBar.push(tools)
150 onClicked: toolBar.push(tools)
157 anchors.top: parent.top
158 anchors.topMargin: 20
159 anchors.left: parent.left
160 anchors.leftMargin: 20
167 visible: controlsVisible
176 visible: !toolBar.expanded
177 source: cameraTheme.flashIcon(settings.imageFlashMode)
181 anchors.left: parent.left
182 anchors.right: parent.right
183 anchors.leftMargin: 5
184 anchors.rightMargin: 5
186 anchors.bottomMargin: 5
187 property string mp: imageSettings.currentResolutionMegapixel == "" ? "?" : imageSettings.currentResolutionMegapixel
188 text: qsTr("%1M").arg(mp)
190 verticalAlignment: Text.AlignVCenter
191 horizontalAlignment: Text.AlignHCenter
196 source: visible ? cameraTheme.whiteBalanceIcon(settings.imageWhiteBalance) : ""
197 visible: settings.imageWhiteBalance != WhiteBalance.Auto && !toolBar.expanded
202 source: visible ? cameraTheme.colorFilterIcon(settings.imageColorFilter) : ""
203 visible: settings.imageColorFilter != ColorTone.Normal && !toolBar.expanded
208 visible: settings.imageIso != 0 && !toolBar.expanded
209 source: visible ? cameraTheme.isoIcon(settings.imageIso) : ""
214 visible: settings.imageSceneMode != Scene.Auto && !toolBar.expanded
215 source: visible ? cameraTheme.imageSceneModeIcon(settings.imageSceneMode) : ""
220 visible: settings.useGps
221 source: cameraTheme.gpsIndicatorIcon
223 PropertyAnimation on opacity {
224 easing.type: Easing.OutSine
225 loops: Animation.Infinite
229 running: settings.useGps && !positionSource.position.longitudeValid
235 id: faceDetectionIndicator
236 visible: settings.faceDetectionEnabled
237 source: cameraTheme.faceDetectionIndicatorIcon
243 function cameraError() {
244 mountProtector.unlock(fileNaming.imagePath)
247 function policyLost() {
251 function batteryLow() {
255 function captureImage() {
256 if (!imageMode.canCapture) {
257 showError(qsTr("Camera is already capturing an image."))
259 } else if (!checkBattery()) {
260 showError(qsTr("Not enough battery to capture images."))
262 } else if (!fileSystem.available) {
263 showError(qsTr("Camera cannot capture images in mass storage mode."))
265 } else if (!fileSystem.hasFreeSpace(fileNaming.imagePath)) {
266 showError(qsTr("Not enough space to capture images."))
268 } else if (!mountProtector.lock(fileNaming.imagePath)) {
269 showError(qsTr("Failed to lock images directory."))
272 metaData.setMetaData()
274 var fileName = fileNaming.imageFileName()
275 if (!imageMode.capture(fileName)) {
276 showError(qsTr("Failed to capture image. Please restart the camera."))
277 mountProtector.unlock(fileNaming.imagePath)
280 trackerStore.storeImage(fileName)
285 function startAutoFocus() {
286 if (cam.device == 0) {
287 cam.autoFocus.startAutoFocus()
291 function stopAutoFocus() {
292 if (cam.device == 0) {
293 cam.autoFocus.stopAutoFocus()