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 onPreviewAvailable: overlay.previewAvailable(preview)
50 onSaved: mountProtector.unlock(fileNaming.imagePath)
56 anchors.top: parent.top
58 anchors.horizontalCenter: parent.horizontalCenter
59 visible: controlsVisible
64 anchors.bottom: parent.bottom
65 anchors.right: parent.right
66 anchors.rightMargin: 20
67 anchors.bottomMargin: 20
68 visible: controlsVisible
73 anchors.right: parent.right
74 anchors.rightMargin: 20
75 anchors.verticalCenter: parent.verticalCenter
76 iconSource: cameraTheme.captureButtonImageIconId
80 visible: controlsVisible
83 if (mouseX <= 0 || mouseY <= 0 || mouseX > width || mouseY > height) {
84 // Release outside the button:
85 captureControl.canceled = true
93 running: captureControl.state == "capturing"
96 if (cam.autoFocus.cafStatus != AutoFocus.Success) {
108 capturePressed: capture.pressed
109 zoomPressed: zoomCapture.zoomPressed
110 proximityClosed: proximitySensor.sensorClosed
111 onStartCapture: captureImage()
112 onCancelCapture: stopAutoFocus()
117 enabled: captureControl.showCancelBanner
118 onPressed: captureControl.canceled = true
123 anchors.bottom: parent.bottom
124 anchors.bottomMargin: 20
125 anchors.left: parent.left
126 anchors.leftMargin: 20
128 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
129 visible: controlsVisible
130 expanded: settings.showToolBar
131 onExpandedChanged: settings.showToolBar = expanded
132 tools: CameraToolBarTools {
134 onClicked: toolBar.push(tools)
135 visible: !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
139 onClicked: toolBar.push(tools)
143 onClicked: toolBar.push(tools)
146 ImageWhiteBalanceButton {
147 onClicked: toolBar.push(tools)
150 ImageColorFilterButton {
151 onClicked: toolBar.push(tools)
155 onClicked: toolBar.push(tools)
162 anchors.top: parent.top
163 anchors.topMargin: 20
164 anchors.left: parent.left
165 anchors.leftMargin: 20
172 visible: controlsVisible
181 visible: !toolBar.expanded && !overlay.cam.quirks.hasQuirk(Quirks.NoFlash)
182 source: cameraTheme.flashIcon(settings.imageFlashMode)
186 anchors.left: parent.left
187 anchors.right: parent.right
188 anchors.leftMargin: 5
189 anchors.rightMargin: 5
191 anchors.bottomMargin: 5
192 text: imageSettings.currentResolution ? qsTr("%1M").arg(imageSettings.currentResolution.megaPixels) : qsTr("?M")
194 verticalAlignment: Text.AlignVCenter
195 horizontalAlignment: Text.AlignHCenter
200 source: visible ? cameraTheme.whiteBalanceIcon(settings.imageWhiteBalance) : ""
201 visible: settings.imageWhiteBalance != WhiteBalance.Auto && !toolBar.expanded
206 source: visible ? cameraTheme.colorFilterIcon(settings.imageColorFilter) : ""
207 visible: settings.imageColorFilter != ColorTone.Normal && !toolBar.expanded
212 visible: settings.imageIso != 0 && !toolBar.expanded
213 source: visible ? cameraTheme.isoIcon(settings.imageIso) : ""
218 visible: settings.imageSceneMode != Scene.Auto && !toolBar.expanded
219 source: visible ? cameraTheme.imageSceneModeIcon(settings.imageSceneMode) : ""
224 visible: settings.useGps
225 source: cameraTheme.gpsIndicatorIcon
227 PropertyAnimation on opacity {
228 easing.type: Easing.OutSine
229 loops: Animation.Infinite
233 running: settings.useGps && !positionSource.position.longitudeValid
239 id: faceDetectionIndicator
240 visible: settings.faceDetectionEnabled
241 source: cameraTheme.faceDetectionIndicatorIcon
247 function cameraError() {
248 mountProtector.unlock(fileNaming.imagePath)
251 function policyLost() {
255 function batteryLow() {
259 function captureImage() {
260 if (!imageMode.canCapture) {
261 showError(qsTr("Camera is already capturing an image."))
263 } else if (!checkBattery()) {
264 showError(qsTr("Not enough battery to capture images."))
266 } else if (!fileSystem.available) {
267 showError(qsTr("Camera cannot capture images in mass storage mode."))
269 } else if (!fileSystem.hasFreeSpace(fileNaming.imagePath)) {
270 showError(qsTr("Not enough space to capture images."))
272 } else if (!mountProtector.lock(fileNaming.imagePath)) {
273 showError(qsTr("Failed to lock images directory."))
276 metaData.setMetaData()
278 var fileName = fileNaming.imageFileName()
279 if (!imageMode.capture(fileName)) {
280 showError(qsTr("Failed to capture image. Please restart the camera."))
281 mountProtector.unlock(fileNaming.imagePath)
284 trackerStore.storeImage(fileName)
289 function startAutoFocus() {
290 if (!overlay.cam.quirks.hasQuirk(Quirks.NoAutoFocus)) {
291 cam.autoFocus.startAutoFocus()
295 function stopAutoFocus() {
296 if (!overlay.cam.quirks.hasQuirk(Quirks.NoAutoFocus)) {
297 if (!autoFocusTimer.running) {
298 cam.autoFocus.stopAutoFocus()
303 function resetToolBar() {
304 if (toolBar.depth() > 1) {
309 function cameraDeviceChanged() {