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 iconSource: "image://theme/icon-m-camera-shutter"
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
131 onClicked: toolBar.push(items)
134 onClicked: toolBar.push(items)
137 onClicked: toolBar.push(items)
139 ImageWhiteBalanceButton {
140 onClicked: toolBar.push(items)
142 ImageColorFilterButton {
143 onClicked: toolBar.push(items)
146 onClicked: toolBar.push(items)
153 anchors.top: parent.top
154 anchors.topMargin: 20
155 anchors.left: parent.left
156 anchors.leftMargin: 20
163 visible: controlsVisible
171 id: resolutionIndicator
172 source: "image://theme/" + Data.imageIcon(settings.imageAspectRatio, settings.imageResolution)
177 source: visible ? "image://theme/" + Data.wbIcon(settings.imageWhiteBalance) + "-screen" : ""
178 visible: settings.imageWhiteBalance != WhiteBalance.Auto
183 source: "image://theme/" + Data.cfIcon(settings.imageColorFilter) + "-screen"
184 visible: settings.imageColorFilter != ColorTone.Normal
189 visible: settings.imageIso != 0
190 source: "image://theme/" + Data.isoIcon(settings.imageIso)
195 visible: settings.useGps
196 source: "image://theme/icon-m-camera-location"
198 PropertyAnimation on opacity {
199 easing.type: Easing.OutSine
200 loops: Animation.Infinite
204 running: settings.useGps && !positionSource.position.longitudeValid
210 id: faceDetectionIndicator
211 visible: settings.faceDetectionEnabled
212 source: "image://theme/icon-m-camera-face-detection-screen"
218 function cameraError() {
219 mountProtector.unlock()
222 function policyLost() {
226 function batteryLow() {
230 function captureImage() {
231 if (!imageMode.canCapture) {
232 showError(qsTr("Camera is already capturing an image."))
233 } else if (!checkBattery()) {
234 showError(qsTr("Not enough battery to capture images."))
235 } else if (!fileSystem.available) {
236 showError(qsTr("Camera cannot capture images in mass storage mode."))
237 } else if (!checkDiskSpace()) {
238 showError(qsTr("Not enough space to capture images."))
239 } else if (!mountProtector.lock()) {
240 showError(qsTr("Failed to lock images directory."))
242 metaData.setMetaData()
244 var fileName = fileNaming.imageFileName()
245 if (!imageMode.capture(fileName)) {
246 showError(qsTr("Failed to capture image. Please restart the camera."))
247 mountProtector.unlock()
249 trackerStore.storeImage(fileName)