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
26 import "data.js" as Data
32 property bool animationRunning: false
33 property int policyMode: CameraResources.Image
34 property bool pressed: capture.pressed || zoomSlider.pressed || modeButton.pressed
35 property bool controlsVisible: imageMode.canCapture && cam.running && !animationRunning
36 && dimmer.opacity == 0.0 && !cameraMode.busy
38 signal previewAvailable(string uri)
46 overlay.previewAvailable(preview)
47 cam.autoFocus.stopAutoFocus()
50 onSaved: mountProtector.unlock()
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 iconId: cameraTheme.captureButtonImageIconId
80 onClicked: captureImage()
81 visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
84 if (mouseX <= 0 || mouseY <= 0 || mouseX > width || mouseY > height) {
85 // Release outside the button:
86 cam.autoFocus.stopAutoFocus()
94 running: capture.pressed || zoomCapture.zoomPressed
97 if (cam.autoFocus.cafStatus != AutoFocus.Success) {
98 cam.autoFocus.startAutoFocus()
105 onReleased: parent.captureImage()
110 zoomCapture: zoomCapture
112 if (!autoFocusTimer.running) {
113 cam.autoFocus.stopAutoFocus()
120 anchors.bottom: parent.bottom
121 anchors.bottomMargin: 20
122 anchors.left: parent.left
123 anchors.leftMargin: 20
125 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
126 visible: controlsVisible
127 expanded: settings.showToolBar
128 onExpandedChanged: settings.showToolBar = expanded
129 tools: CameraToolBarTools {
131 onClicked: toolBar.push(tools)
135 onClicked: toolBar.push(tools)
139 onClicked: toolBar.push(tools)
142 ImageWhiteBalanceButton {
143 onClicked: toolBar.push(tools)
146 ImageColorFilterButton {
147 onClicked: toolBar.push(tools)
151 onClicked: toolBar.push(tools)
158 anchors.top: parent.top
159 anchors.topMargin: 20
160 anchors.left: parent.left
161 anchors.leftMargin: 20
168 visible: controlsVisible
176 id: resolutionIndicator
177 source: "image://theme/" + Data.imageIcon(settings.imageAspectRatio, settings.imageResolution)
182 source: visible ? "image://theme/" + Data.wbIcon(settings.imageWhiteBalance) + "-screen" : ""
183 visible: settings.imageWhiteBalance != WhiteBalance.Auto
188 source: "image://theme/" + Data.cfIcon(settings.imageColorFilter) + "-screen"
189 visible: settings.imageColorFilter != ColorTone.Normal
194 visible: settings.imageIso != 0
195 source: "image://theme/" + Data.isoIcon(settings.imageIso)
200 visible: settings.useGps
201 source: cameraTheme.gpsIndicatorIcon
203 PropertyAnimation on opacity {
204 easing.type: Easing.OutSine
205 loops: Animation.Infinite
209 running: settings.useGps && !positionSource.position.longitudeValid
215 id: faceDetectionIndicator
216 visible: settings.faceDetectionEnabled
217 source: cameraTheme.faceDetectionIndicatorIcon
223 function cameraError() {
224 mountProtector.unlock()
227 function policyLost() {
231 function batteryLow() {
235 function captureImage() {
236 if (!imageMode.canCapture) {
237 showError(qsTr("Camera is already capturing an image."))
238 } else if (!checkBattery()) {
239 showError(qsTr("Not enough battery to capture images."))
240 } else if (!fileSystem.available) {
241 showError(qsTr("Camera cannot capture images in mass storage mode."))
242 } else if (!checkDiskSpace()) {
243 showError(qsTr("Not enough space to capture images."))
244 } else if (!mountProtector.lock()) {
245 showError(qsTr("Failed to lock images directory."))
247 metaData.setMetaData()
249 var fileName = fileNaming.imageFileName()
250 if (!imageMode.capture(fileName)) {
251 showError(qsTr("Failed to capture image. Please restart the camera."))
252 mountProtector.unlock()
254 trackerStore.storeImage(fileName)