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.useGps
171 source: cameraTheme.gpsIndicatorIcon
173 PropertyAnimation on opacity {
174 easing.type: Easing.OutSine
175 loops: Animation.Infinite
179 running: settings.useGps && !positionSource.position.longitudeValid
187 inhibitDim: overlay.recording
191 target: Qt.application
193 if (!Qt.application.active && overlay.recording) {
194 overlay.stopRecording()
200 id: recordingDuration
201 property int duration: 0
202 running: overlay.recording
207 duration = duration + 1
209 if (duration == 3600) {
210 overlay.stopRecording()
211 showError(qsTr("Maximum recording time reached."))
212 } else if (!checkDiskSpace()) {
214 showError(qsTr("Not enough space to continue recording."))
220 RecordingDurationLabel {
221 visible: overlay.recording
222 duration: recordingDuration.duration
225 function doStartRecording() {
226 if (!overlay.recording) {
230 if (!pipelineManager.acquired || pipelineManager.hijacked) {
231 showError(qsTr("Failed to acquire needed resources."))
232 overlay.recording = false
236 metaData.setMetaData()
238 if (!mountProtector.lock()) {
239 showError(qsTr("Failed to lock images directory."))
240 overlay.recording = false
244 var file = fileNaming.videoFileName()
245 var tmpFile = fileNaming.temporaryVideoFileName()
247 if (!videoMode.startRecording(file, tmpFile)) {
248 showError(qsTr("Failed to record video. Please restart the camera."))
249 mountProtector.unlock()
250 overlay.recording = false
254 trackerStore.storeVideo(file);
257 function startRecording() {
258 if (!fileSystem.available) {
259 showError(qsTr("Camera cannot record videos in mass storage mode."))
260 } else if (!checkBattery()) {
261 showError(qsTr("Not enough battery to record video."))
262 } else if (!checkDiskSpace()) {
263 showError(qsTr("Not enough space to record video."))
265 recordingDuration.duration = 0
266 overlay.recording = true
271 function stopRecording() {
272 videoMode.stopRecording(true)
273 mountProtector.unlock()
274 overlay.recording = false
277 function toggleRecording() {
278 if (overlay.recording) {
279 overlay.stopRecording()
281 overlay.startRecording()
285 function cameraError() {
286 overlay.stopRecording()
289 function policyLost() {
290 overlay.stopRecording()
293 function batteryLow() {
294 if (!overlay.recording) {
298 if (!checkBattery()) {
299 overlay.stopRecording()
300 showError(qsTr("Not enough battery to record video."))