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 overlay.previewAvailable(preview)
46 cam.autoFocus.stopAutoFocus()
49 onSaved: mountProtector.unlock()
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 iconId: 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:
85 cam.autoFocus.stopAutoFocus()
93 running: capture.pressed || zoomCapture.zoomPressed
96 if (cam.autoFocus.cafStatus != AutoFocus.Success) {
97 cam.autoFocus.startAutoFocus()
104 onReleased: parent.captureImage()
109 zoomCapture: zoomCapture
111 if (!autoFocusTimer.running) {
112 cam.autoFocus.stopAutoFocus()
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 source: "image://theme/" + cameraTheme.flashIndicatorIcon(settings.imageFlashMode)
180 id: resolutionIndicator
181 property string imageAspectRatio: settings.device == 1 ? settings.secondaryImageAspectRatio : settings.primaryImageAspectRatio
182 property string imageResolution: settings.device == 1 ? settings.secondaryImageResolution : settings.primaryImageResolution
183 source: "image://theme/" + cameraTheme.imageIcon(imageAspectRatio, imageResolution, settings.device)
188 source: visible ? "image://theme/" + cameraTheme.whiteBalanceIndicatorIcon(settings.imageWhiteBalance) : ""
189 visible: settings.imageWhiteBalance != WhiteBalance.Auto
194 source: visible ? "image://theme/" + cameraTheme.colorFilterIndicatorIcon(settings.imageColorFilter) : ""
195 visible: settings.imageColorFilter != ColorTone.Normal
200 visible: settings.imageIso != 0
201 source: "image://theme/" + cameraTheme.isoIcon(settings.imageIso)
206 visible: settings.useGps
207 source: cameraTheme.gpsIndicatorIcon
209 PropertyAnimation on opacity {
210 easing.type: Easing.OutSine
211 loops: Animation.Infinite
215 running: settings.useGps && !positionSource.position.longitudeValid
221 id: faceDetectionIndicator
222 visible: settings.faceDetectionEnabled
223 source: cameraTheme.faceDetectionIndicatorIcon
229 function cameraError() {
230 mountProtector.unlock()
233 function policyLost() {
237 function batteryLow() {
241 function captureImage() {
242 if (!imageMode.canCapture) {
243 showError(qsTr("Camera is already capturing an image."))
244 } else if (!checkBattery()) {
245 showError(qsTr("Not enough battery to capture images."))
246 } else if (!fileSystem.available) {
247 showError(qsTr("Camera cannot capture images in mass storage mode."))
248 } else if (!checkDiskSpace()) {
249 showError(qsTr("Not enough space to capture images."))
250 } else if (!mountProtector.lock()) {
251 showError(qsTr("Failed to lock images directory."))
253 metaData.setMetaData()
255 var fileName = fileNaming.imageFileName()
256 if (!imageMode.capture(fileName)) {
257 showError(qsTr("Failed to capture image. Please restart the camera."))
258 mountProtector.unlock()
260 trackerStore.storeImage(fileName)