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
30 property bool recording: false
33 property bool animationRunning: false
34 property int policyMode: recording == true ? CameraResources.Recording : CameraResources.Video
35 property bool controlsVisible: !animationRunning && cam != null && cam.running
36 && dimmer.opacity == 0.0 && !cameraMode.busy
37 property bool pressed: overlay.recording || capture.pressed ||
38 zoomSlider.pressed || modeButton.pressed
40 signal previewAvailable(string uri)
47 onPreviewAvailable: overlay.previewAvailable(preview)
53 anchors.top: parent.top
55 anchors.horizontalCenter: parent.horizontalCenter
56 visible: controlsVisible
61 anchors.bottom: parent.bottom
62 anchors.right: parent.right
63 anchors.rightMargin: 20
64 anchors.bottomMargin: 20
65 visible: controlsVisible && !overlay.recording
70 onReleased: overlay.toggleRecording()
75 zoomCapture: zoomCapture
80 anchors.right: parent.right
81 anchors.rightMargin: 20
82 anchors.verticalCenter: parent.verticalCenter
83 iconSource: overlay.recording ? "image://theme/icon-m-camera-video-record" : "image://theme/icon-m-camera-video-record"
88 onClicked: overlay.toggleRecording()
90 visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
95 anchors.bottom: parent.bottom
96 anchors.bottomMargin: 20
97 anchors.left: parent.left
98 anchors.leftMargin: 20
100 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
101 visible: controlsVisible
102 expanded: settings.showToolBar
103 onExpandedChanged: settings.showToolBar = expanded;
110 // TODO: hide when recording
111 onClicked: toolBar.push(items)
114 onClicked: toolBar.push(items)
116 VideoWhiteBalanceButton {
117 onClicked: toolBar.push(items)
119 VideoColorFilterButton {
120 onClicked: toolBar.push(items)
128 anchors.top: parent.top
129 anchors.topMargin: 20
130 anchors.left: parent.left
131 anchors.leftMargin: 20
138 visible: controlsVisible
146 id: resolutionIndicator
147 source: "image://theme/" + Data.videoIcon(settings.videoResolution)
152 source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
153 visible: settings.videoWhiteBalance != WhiteBalance.Auto
158 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
159 visible: settings.videoColorFilter != ColorTone.Normal
164 visible: settings.useGps
165 source: "image://theme/icon-m-camera-location"
167 PropertyAnimation on opacity {
168 easing.type: Easing.OutSine
169 loops: Animation.Infinite
173 running: settings.useGps && !positionSource.position.longitudeValid
181 inhibitDim: overlay.recording
185 target: Qt.application
187 if (!Qt.application.active && overlay.recording) {
188 overlay.stopRecording()
194 id: recordingDuration
195 property int duration: 0
196 running: overlay.recording
201 duration = duration + 1
203 if (duration == 3600) {
204 overlay.stopRecording()
205 showError(qsTr("Maximum recording time reached."))
206 } else if (!checkDiskSpace()) {
208 showError(qsTr("Not enough space to continue recording."))
214 RecordingDurationLabel {
215 visible: overlay.recording
216 duration: recordingDuration.duration
219 function doStartRecording() {
220 if (!overlay.recording) {
224 if (!pipelineManager.acquired || pipelineManager.hijacked) {
225 showError(qsTr("Failed to acquire needed resources."))
226 overlay.recording = false
230 metaData.setMetaData()
232 if (!mountProtector.lock()) {
233 showError(qsTr("Failed to lock images directory."))
234 overlay.recording = false
238 var file = fileNaming.videoFileName()
239 var tmpFile = fileNaming.temporaryVideoFileName()
241 if (!videoMode.startRecording(file, tmpFile)) {
242 showError(qsTr("Failed to record video. Please restart the camera."))
243 mountProtector.unlock()
244 overlay.recording = false
248 trackerStore.storeVideo(file);
251 function startRecording() {
252 if (!fileSystem.available) {
253 showError(qsTr("Camera cannot record videos in mass storage mode."))
254 } else if (!checkBattery()) {
255 showError(qsTr("Not enough battery to record video."))
256 } else if (!checkDiskSpace()) {
257 showError(qsTr("Not enough space to record video."))
259 recordingDuration.duration = 0
260 overlay.recording = true
265 function stopRecording() {
266 videoMode.stopRecording(true)
267 mountProtector.unlock()
268 overlay.recording = false
271 function toggleRecording() {
272 if (overlay.recording) {
273 overlay.stopRecording()
275 overlay.startRecording()
279 function cameraError() {
280 overlay.stopRecording()
283 function policyLost() {
284 overlay.stopRecording()
287 function batteryLow() {
288 if (!overlay.recording) {
292 if (!checkBattery()) {
293 overlay.stopRecording()
294 showError(qsTr("Not enough battery to record video."))