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 iconId: 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 {
110 visible: !overlay.recording
111 onClicked: toolBar.push(tools)
115 onClicked: toolBar.push(tools)
118 VideoWhiteBalanceButton {
119 onClicked: toolBar.push(tools)
122 VideoColorFilterButton {
123 onClicked: toolBar.push(tools)
132 anchors.top: parent.top
133 anchors.topMargin: 20
134 anchors.left: parent.left
135 anchors.leftMargin: 20
142 visible: controlsVisible
150 id: resolutionIndicator
151 property string videoResolution: settings.device == 1 ? settings.secondaryVideoResolution : settings.primaryVideoResolution
152 property string videoRatio: settings.device == 1 ? settings.secondaryVideoAspectRatio : settings.primaryVideoAspectRatio
153 source: "image://theme/" + cameraTheme.videoIcon(videoRatio, videoResolution, settings.device)
158 source: visible ? "image://theme/" + cameraTheme.whiteBalanceIndicatorIcon(settings.videoWhiteBalance) : ""
159 visible: settings.videoWhiteBalance != WhiteBalance.Auto
164 source: visible ? "image://theme/" + cameraTheme.colorFilterIndicatorIcon(settings.videoColorFilter) : ""
165 visible: settings.videoColorFilter != ColorTone.Normal
170 visible: settings.videoSceneMode != Scene.Auto
171 source: visible ? "image://theme/" + cameraTheme.videoSceneModeIndicatorIcon(settings.videoSceneMode) : ""
176 visible: settings.useGps
177 source: cameraTheme.gpsIndicatorIcon
179 PropertyAnimation on opacity {
180 easing.type: Easing.OutSine
181 loops: Animation.Infinite
185 running: settings.useGps && !positionSource.position.longitudeValid
193 inhibitDim: overlay.recording
197 target: Qt.application
199 if (!Qt.application.active && overlay.recording) {
200 overlay.stopRecording()
206 id: recordingDuration
207 property int duration: 0
208 running: overlay.recording
213 duration = duration + 1
215 if (duration == 3600) {
216 overlay.stopRecording()
217 showError(qsTr("Maximum recording time reached."))
218 } else if (!checkDiskSpace()) {
220 showError(qsTr("Not enough space to continue recording."))
226 RecordingDurationLabel {
227 visible: overlay.recording
228 duration: recordingDuration.duration
231 function doStartRecording() {
232 if (!overlay.recording) {
236 if (!pipelineManager.acquired || pipelineManager.hijacked) {
237 showError(qsTr("Failed to acquire needed resources."))
238 overlay.recording = false
242 metaData.setMetaData()
244 if (!mountProtector.lock()) {
245 showError(qsTr("Failed to lock images directory."))
246 overlay.recording = false
250 var file = fileNaming.videoFileName()
251 var tmpFile = fileNaming.temporaryVideoFileName()
253 if (!videoMode.startRecording(file, tmpFile)) {
254 showError(qsTr("Failed to record video. Please restart the camera."))
255 mountProtector.unlock()
256 overlay.recording = false
260 trackerStore.storeVideo(file);
263 function startRecording() {
264 if (!fileSystem.available) {
265 showError(qsTr("Camera cannot record videos in mass storage mode."))
266 } else if (!checkBattery()) {
267 showError(qsTr("Not enough battery to record video."))
268 } else if (!checkDiskSpace()) {
269 showError(qsTr("Not enough space to record video."))
271 recordingDuration.duration = 0
272 overlay.recording = true
277 function stopRecording() {
278 videoMode.stopRecording(true)
279 mountProtector.unlock()
280 overlay.recording = false
283 function toggleRecording() {
284 if (overlay.recording) {
285 overlay.stopRecording()
287 overlay.startRecording()
291 function cameraError() {
292 overlay.stopRecording()
295 function policyLost() {
296 overlay.stopRecording()
299 function batteryLow() {
300 if (!overlay.recording) {
304 if (!checkBattery()) {
305 overlay.stopRecording()
306 showError(qsTr("Not enough battery to record video."))