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
36 property bool inhibitDim: false
38 signal previewAvailable(string uri)
46 onCaptureEnded: stopAutoFocus()
48 enablePreview: settings.enablePreview
50 onPreviewAvailable: overlay.previewAvailable(preview)
52 onSaved: mountProtector.unlock(fileNaming.imagePath)
58 anchors.top: parent.top
60 anchors.horizontalCenter: parent.horizontalCenter
61 visible: controlsVisible
66 anchors.bottom: parent.bottom
67 anchors.right: parent.right
68 anchors.rightMargin: 20
69 anchors.bottomMargin: 20
70 visible: controlsVisible
75 anchors.right: parent.right
76 anchors.rightMargin: 20
77 anchors.verticalCenter: parent.verticalCenter
78 iconSource: cameraTheme.captureButtonImageIconId
82 visible: controlsVisible
85 if (mouseX <= 0 || mouseY <= 0 || mouseX > width || mouseY > height) {
86 // Release outside the button:
87 captureControl.canceled = true
95 running: captureControl.state == "capturing"
98 if (cam.autoFocus.cafStatus != AutoFocus.Success) {
110 capturePressed: capture.pressed
111 zoomPressed: zoomCapture.zoomPressed
112 proximityClosed: proximitySensor.sensorClosed
113 onStartCapture: captureImage()
114 onCancelCapture: stopAutoFocus()
119 enabled: captureControl.showCancelBanner
120 onPressed: captureControl.canceled = true
125 anchors.bottom: parent.bottom
126 anchors.bottomMargin: 20
127 anchors.left: parent.left
128 anchors.leftMargin: 20
130 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
131 visible: controlsVisible
132 expanded: settings.showToolBar
133 onExpandedChanged: settings.showToolBar = expanded
134 tools: CameraToolBarTools {
136 onClicked: toolBar.push(tools)
137 visible: overlay.cam ? !overlay.cam.quirks.hasQuirk(Quirks.NoFlash) : false
141 onClicked: toolBar.push(tools)
145 onClicked: toolBar.push(tools)
148 ImageWhiteBalanceButton {
149 onClicked: toolBar.push(tools)
152 ImageColorFilterButton {
153 onClicked: toolBar.push(tools)
157 onClicked: toolBar.push(tools)
164 anchors.top: parent.top
165 anchors.topMargin: 20
166 anchors.left: parent.left
167 anchors.leftMargin: 20
174 visible: controlsVisible
183 visible: !toolBar.expanded && !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
184 source: cameraTheme.flashIcon(settings.imageFlashMode)
188 anchors.left: parent.left
189 anchors.right: parent.right
190 anchors.leftMargin: 5
191 anchors.rightMargin: 5
193 anchors.bottomMargin: 5
194 text: imageSettings.currentResolution ? qsTr("%1M").arg(imageSettings.currentResolution.megaPixels) : qsTr("?M")
196 verticalAlignment: Text.AlignVCenter
197 horizontalAlignment: Text.AlignHCenter
202 source: visible ? cameraTheme.whiteBalanceIcon(settings.imageWhiteBalance) : ""
203 visible: settings.imageWhiteBalance != WhiteBalance.Auto && !toolBar.expanded
208 source: visible ? cameraTheme.colorFilterIcon(settings.imageColorFilter) : ""
209 visible: settings.imageColorFilter != ColorTone.Normal && !toolBar.expanded
214 visible: settings.imageIso != 0 && !toolBar.expanded
215 source: visible ? cameraTheme.isoIcon(settings.imageIso) : ""
220 visible: settings.imageSceneMode != Scene.Auto && !toolBar.expanded
221 source: visible ? cameraTheme.imageSceneModeIcon(settings.imageSceneMode) : ""
226 visible: settings.useGps
227 source: cameraTheme.gpsIndicatorIcon
229 PropertyAnimation on opacity {
230 easing.type: Easing.OutSine
231 loops: Animation.Infinite
235 running: settings.useGps && !positionSource.position.longitudeValid
241 id: faceDetectionIndicator
242 visible: settings.faceDetectionEnabled
243 source: cameraTheme.faceDetectionIndicatorIcon
249 function cameraError() {
250 mountProtector.unlock(fileNaming.imagePath)
253 function policyLost() {
257 function batteryLow() {
261 function captureImage() {
262 if (!imageMode.canCapture) {
263 showError(qsTr("Camera is already capturing an image."))
265 } else if (!checkBattery()) {
266 showError(qsTr("Not enough battery to capture images."))
268 } else if (!fileSystem.available) {
269 showError(qsTr("Camera cannot capture images in mass storage mode."))
271 } else if (!fileSystem.hasFreeSpace(fileNaming.imagePath)) {
272 showError(qsTr("Not enough space to capture images."))
274 } else if (!mountProtector.lock(fileNaming.imagePath)) {
275 showError(qsTr("Failed to lock images directory."))
278 metaData.setMetaData()
280 var fileName = fileNaming.imageFileName()
281 if (!imageMode.capture(fileName)) {
282 showError(qsTr("Failed to capture image. Please restart the camera."))
283 mountProtector.unlock(fileNaming.imagePath)
286 trackerStore.storeImage(fileName)
291 function startAutoFocus() {
292 if (!overlay.cam.quirks.hasQuirk(Quirks.NoAutoFocus)) {
293 cam.autoFocus.startAutoFocus()
297 function stopAutoFocus() {
298 if (!overlay.cam.quirks.hasQuirk(Quirks.NoAutoFocus)) {
299 if (!autoFocusTimer.running) {
300 cam.autoFocus.stopAutoFocus()
305 function resetToolBar() {
306 if (toolBar.depth() > 1) {
311 function cameraDeviceChanged() {