4 * This file is part of CameraPlus.
6 * Copyright (C) 2012 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
24 import com.nokia.meego 1.1
27 import "data.js" as Data
29 // TODO: losing resources in the middle of recording will produce corrupted video
30 // TODO: optional resources?
35 property bool error: false
37 policyMode: CameraResources.Recording
39 controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning && !error
41 orientationLock: PageOrientation.LockLandscape
43 function policyLost() {
47 function cameraError() {
52 Component.onDestruction: videoMode.stopRecording();
55 if (page.status == PageStatus.Active) {
60 function startRecording() {
61 if (!pipelineManager.acquired || pipelineManager.hijacked) {
62 showError(qsTr("Failed to acquire needed resources."));
63 pageStack.pop(undefined, true);
67 metaData.setMetaData();
69 if (!mountProtector.lock()) {
70 showError(qsTr("Failed to lock images directory."));
71 pageStack.pop(undefined, true);
75 var file = fileNaming.videoFileName();
76 var tmpFile = fileNaming.temporaryVideoFileName();
78 if (!videoMode.startRecording(file, tmpFile)) {
79 showError(qsTr("Failed to record video. Please restart the camera."));
80 pageStack.pop(undefined, true);
81 mountProtector.unlock();
84 // TODO: sometimes this fails (fast stop after start).
85 trackerStore.storeVideo(file);
88 function stopRecording() {
89 mountProtector.unlock();
90 // Something is fishy here but if there is an error
91 // and we use immediate mode then the page never gets destroyed.
92 pageStack.pop(undefined, error ? false : true);
100 if (!checkBattery()) {
101 page.stopRecording();
102 showError(qsTr("Not enough battery to record video."));
108 anchors.right: parent.right
109 anchors.rightMargin: 20
110 anchors.verticalCenter: parent.verticalCenter
111 iconSource: "image://theme/icon-m-camera-video-record"
116 onClicked: page.stopRecording();
117 visible: controlsVisible
121 target: Qt.application
123 if (!Qt.application.active) {
124 page.stopRecording();
135 anchors.top: parent.top
136 anchors.topMargin: 20
137 anchors.left: parent.left
138 anchors.leftMargin: 20
145 visible: controlsVisible
153 id: resolutionIndicator
154 source: "image://theme/" + Data.videoIcon(settings.videoResolution);
159 source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
160 visible: settings.videoWhiteBalance != WhiteBalance.Auto
165 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
166 visible: settings.videoColorFilter != ColorTone.Normal
171 visible: settings.useGps
172 source: "image://theme/icon-m-camera-location"
174 PropertyAnimation on opacity {
175 easing.type: Easing.OutSine
176 loops: Animation.Infinite
180 running: settings.useGps && !positionSource.position.longitudeValid
188 anchors.bottom: parent.bottom
189 anchors.right: parent.right
190 anchors.rightMargin: 20
191 anchors.bottomMargin: 20
193 visible: controlsVisible
201 id: recordingDuration
203 property int duration: 0
205 running: videoMode.recording
210 duration = duration + 1;
211 if (duration == 3600) {
212 page.stopRecording();
213 showError(qsTr("Maximum recording time reached."));
215 else if (!checkDiskSpace()) {
216 page.stopRecording();
217 showError(qsTr("Not enough space to continue recording."));
224 source: "image://theme/icon-m-camera-ongoing-recording"
227 anchors.verticalCenter: parent.verticalCenter
228 anchors.left: parent.left
229 anchors.leftMargin: 5
231 sourceSize.height: 20
235 function formatDuration(dur) {
236 var secs = parseInt(recordingDuration.duration);
237 var minutes = Math.floor(secs / 60);
238 var seconds = secs - (minutes * 60);
240 var date = new Date();
241 date.setSeconds(seconds);
242 date.setMinutes(minutes);
243 return Qt.formatTime(date, "mm:ss");
247 text: formatDuration(recordingDuration.duration);
248 anchors.left: recordingIcon.right
249 anchors.leftMargin: 5
255 anchors.bottom: parent.bottom
256 anchors.bottomMargin: 20
257 anchors.left: parent.left
258 anchors.leftMargin: 20
260 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
261 visible: controlsVisible
262 expanded: settings.showToolBar
263 onExpandedChanged: settings.showToolBar = expanded;
270 onClicked: toolBar.push(items);
272 VideoWhiteBalanceButton {
273 onClicked: toolBar.push(items);
275 VideoColorFilterButton {
276 onClicked: toolBar.push(items);
279 iconSource: "image://theme/icon-m-toolbar-view-menu-white"
280 onClicked: openFile("VideoSettingsPage.qml");