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
29 property bool recording: false
32 property bool animationRunning: false
33 property int policyMode: recording == true ? CameraResources.Recording : CameraResources.Video
34 property bool controlsVisible: !animationRunning && cam != null && cam.running
35 && dimmer.opacity == 0.0 && !cameraMode.busy
36 property bool pressed: overlay.recording || capture.pressed ||
37 zoomSlider.pressed || modeButton.pressed
39 signal previewAvailable(string uri)
46 onPreviewAvailable: overlay.previewAvailable(preview)
52 anchors.top: parent.top
54 anchors.horizontalCenter: parent.horizontalCenter
55 visible: controlsVisible
60 anchors.bottom: parent.bottom
61 anchors.right: parent.right
62 anchors.rightMargin: 20
63 anchors.bottomMargin: 20
64 visible: controlsVisible && !overlay.recording
69 onReleased: overlay.toggleRecording()
74 zoomCapture: zoomCapture
79 anchors.right: parent.right
80 anchors.rightMargin: 20
81 anchors.verticalCenter: parent.verticalCenter
82 iconSource: overlay.recording ? cameraTheme.captureButtonRecordingIconId : cameraTheme.captureButtonVideoIconId
87 onClicked: overlay.toggleRecording()
89 visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
94 anchors.bottom: parent.bottom
95 anchors.bottomMargin: 20
96 anchors.left: parent.left
97 anchors.leftMargin: 20
99 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
100 visible: controlsVisible
101 expanded: settings.showToolBar
102 onExpandedChanged: settings.showToolBar = expanded;
104 tools: CameraToolBarTools {
107 visible: cam.device == 0
111 visible: !overlay.recording
112 onClicked: toolBar.push(tools)
116 onClicked: toolBar.push(tools)
119 VideoWhiteBalanceButton {
120 onClicked: toolBar.push(tools)
123 VideoColorFilterButton {
124 onClicked: toolBar.push(tools)
133 anchors.top: parent.top
134 anchors.topMargin: 20
135 anchors.left: parent.left
136 anchors.leftMargin: 20
143 visible: controlsVisible
151 id: resolutionIndicator
152 property string videoResolution: settings.device == 1 ? settings.secondaryVideoResolution : settings.primaryVideoResolution
153 property string videoRatio: settings.device == 1 ? settings.secondaryVideoAspectRatio : settings.primaryVideoAspectRatio
154 source: cameraTheme.videoIcon(videoRatio, videoResolution, settings.device)
159 source: visible ? cameraTheme.whiteBalanceIcon(settings.videoWhiteBalance) : ""
160 visible: settings.videoWhiteBalance != WhiteBalance.Auto && !toolBar.expanded
165 source: visible ? cameraTheme.colorFilterIcon(settings.videoColorFilter) : ""
166 visible: settings.videoColorFilter != ColorTone.Normal && !toolBar.expanded
171 visible: settings.videoSceneMode != Scene.Auto && (!toolBar.expanded || overlay.recording)
172 source: visible ? cameraTheme.videoSceneModeIcon(settings.videoSceneMode) : ""
177 visible: settings.useGps
178 source: cameraTheme.gpsIndicatorIcon
180 PropertyAnimation on opacity {
181 easing.type: Easing.OutSine
182 loops: Animation.Infinite
186 running: settings.useGps && !positionSource.position.longitudeValid
194 inhibitDim: overlay.recording
198 target: Qt.application
200 if (!Qt.application.active && overlay.recording) {
201 overlay.stopRecording()
207 id: recordingDuration
208 property int duration: 0
209 running: overlay.recording
214 duration = duration + 1
216 if (duration == 3600) {
217 overlay.stopRecording()
218 showError(qsTr("Maximum recording time reached."))
219 } else if (!fileSystem.hasFreeSpace(fileNaming.temporaryVideoPath)) {
221 showError(qsTr("Not enough space to continue recording."))
227 RecordingDurationLabel {
228 visible: overlay.recording
229 duration: recordingDuration.duration
232 function doStartRecording() {
233 if (!overlay.recording) {
237 if (!pipelineManager.acquired || pipelineManager.hijacked) {
238 showError(qsTr("Failed to acquire needed resources."))
239 overlay.recording = false
243 metaData.setMetaData()
245 if (!mountProtector.lock(fileNaming.temporaryVideoPath)) {
246 showError(qsTr("Failed to lock temporary videos directory."))
247 overlay.recording = false
251 if (!mountProtector.lock(fileNaming.videoPath)) {
252 showError(qsTr("Failed to lock videos directory."))
253 overlay.recording = false
254 mountProtector.unlockAll()
258 var file = fileNaming.videoFileName()
259 var tmpFile = fileNaming.temporaryVideoFileName()
261 if (!videoMode.startRecording(file, tmpFile)) {
262 showError(qsTr("Failed to record video. Please restart the camera."))
263 mountProtector.unlockAll()
264 overlay.recording = false
268 trackerStore.storeVideo(file);
270 if (toolBar.depth() > 1) {
275 function startRecording() {
276 if (!fileSystem.available) {
277 showError(qsTr("Camera cannot record videos in mass storage mode."))
278 } else if (!checkBattery()) {
279 showError(qsTr("Not enough battery to record video."))
280 } else if (!fileSystem.hasFreeSpace(fileNaming.videoPath) || !fileSystem.hasFreeSpace(fileNaming.temporaryVideoPath)) {
281 showError(qsTr("Not enough space to record video."))
283 recordingDuration.duration = 0
284 overlay.recording = true
289 function stopRecording() {
290 videoMode.stopRecording(true)
291 mountProtector.unlockAll()
292 overlay.recording = false
295 function toggleRecording() {
296 if (overlay.recording) {
297 overlay.stopRecording()
299 overlay.startRecording()
303 function cameraError() {
304 overlay.stopRecording()
307 function policyLost() {
308 overlay.stopRecording()
311 function batteryLow() {
312 if (!overlay.recording) {
316 if (!checkBattery()) {
317 overlay.stopRecording()
318 showError(qsTr("Not enough battery to record video."))