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 visible: controlsVisible
82 if (mouseX <= 0 || mouseY <= 0 || mouseX > width || mouseY > height) {
83 // Release outside the button:
84 captureControl.canceled = true
92 running: captureControl.state == "capturing"
95 if (cam.autoFocus.cafStatus != AutoFocus.Success) {
107 capturePressed: capture.pressed
108 zoomPressed: zoomCapture.zoomPressed
109 proximityClosed: proximitySensor.close
110 onStartCapture: captureImage()
111 onCancelCapture: stopAutoFocus()
116 enabled: captureControl.showCancelBanner
117 onPressed: captureControl.canceled = true
122 anchors.bottom: parent.bottom
123 anchors.bottomMargin: 20
124 anchors.left: parent.left
125 anchors.leftMargin: 20
127 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
128 visible: controlsVisible
129 expanded: settings.showToolBar
130 onExpandedChanged: settings.showToolBar = expanded
131 tools: CameraToolBarTools {
133 onClicked: toolBar.push(tools)
134 visible: !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
138 onClicked: toolBar.push(tools)
142 onClicked: toolBar.push(tools)
145 ImageWhiteBalanceButton {
146 onClicked: toolBar.push(tools)
149 ImageColorFilterButton {
150 onClicked: toolBar.push(tools)
154 onClicked: toolBar.push(tools)
161 anchors.top: parent.top
162 anchors.topMargin: 20
163 anchors.left: parent.left
164 anchors.leftMargin: 20
171 visible: controlsVisible
180 visible: !toolBar.expanded && !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
181 source: cameraTheme.flashIcon(settings.imageFlashMode)
185 anchors.left: parent.left
186 anchors.right: parent.right
187 anchors.leftMargin: 5
188 anchors.rightMargin: 5
190 anchors.bottomMargin: 5
191 text: imageSettings.currentResolution ? qsTr("%1M").arg(imageSettings.currentResolution.megaPixels) : qsTr("?M")
193 verticalAlignment: Text.AlignVCenter
194 horizontalAlignment: Text.AlignHCenter
199 source: visible ? cameraTheme.whiteBalanceIcon(settings.imageWhiteBalance) : ""
200 visible: settings.imageWhiteBalance != WhiteBalance.Auto && !toolBar.expanded
205 source: visible ? cameraTheme.colorFilterIcon(settings.imageColorFilter) : ""
206 visible: settings.imageColorFilter != ColorTone.Normal && !toolBar.expanded
211 visible: settings.imageIso != 0 && !toolBar.expanded
212 source: visible ? cameraTheme.isoIcon(settings.imageIso) : ""
217 visible: settings.imageSceneMode != Scene.Auto && !toolBar.expanded
218 source: visible ? cameraTheme.imageSceneModeIcon(settings.imageSceneMode) : ""
223 visible: settings.useGps
224 source: cameraTheme.gpsIndicatorIcon
226 PropertyAnimation on opacity {
227 easing.type: Easing.OutSine
228 loops: Animation.Infinite
232 running: settings.useGps && !positionSource.position.longitudeValid
238 id: faceDetectionIndicator
239 visible: settings.faceDetectionEnabled
240 source: cameraTheme.faceDetectionIndicatorIcon
246 function cameraError() {
247 mountProtector.unlock(fileNaming.imagePath)
250 function policyLost() {
254 function batteryLow() {
258 function captureImage() {
259 if (!imageMode.canCapture) {
260 showError(qsTr("Camera is already capturing an image."))
262 } else if (!checkBattery()) {
263 showError(qsTr("Not enough battery to capture images."))
265 } else if (!fileSystem.available) {
266 showError(qsTr("Camera cannot capture images in mass storage mode."))
268 } else if (!fileSystem.hasFreeSpace(fileNaming.imagePath)) {
269 showError(qsTr("Not enough space to capture images."))
271 } else if (!mountProtector.lock(fileNaming.imagePath)) {
272 showError(qsTr("Failed to lock images directory."))
275 metaData.setMetaData()
277 var fileName = fileNaming.imageFileName()
278 if (!imageMode.capture(fileName)) {
279 showError(qsTr("Failed to capture image. Please restart the camera."))
280 mountProtector.unlock(fileNaming.imagePath)
283 trackerStore.storeImage(fileName)
288 function startAutoFocus() {
289 if (!overlay.cam.quirks.hasQuirk(Quirks.NoAutoFocus)) {
290 cam.autoFocus.startAutoFocus()
294 function stopAutoFocus() {
295 if (!overlay.cam.quirks.hasQuirk(Quirks.NoAutoFocus)) {
296 if (!autoFocusTimer.running) {
297 cam.autoFocus.stopAutoFocus()
302 function resetToolBar() {
303 if (toolBar.depth() > 1) {
308 function cameraDeviceChanged() {