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 trackerStore.storeVideo(file);
87 function stopRecording() {
88 mountProtector.unlock();
89 // Something is fishy here but if there is an error
90 // and we use immediate mode then the page never gets destroyed.
91 pageStack.pop(undefined, error ? false : true);
99 if (!checkBattery()) {
100 page.stopRecording();
101 showError(qsTr("Not enough battery to record video."));
107 anchors.right: parent.right
108 anchors.rightMargin: 20
109 anchors.verticalCenter: parent.verticalCenter
110 iconSource: "image://theme/icon-m-camera-video-record"
115 onClicked: page.stopRecording();
116 visible: controlsVisible
120 target: Qt.application
122 if (!Qt.application.active) {
123 page.stopRecording();
134 anchors.top: parent.top
135 anchors.topMargin: 20
136 anchors.left: parent.left
137 anchors.leftMargin: 20
144 visible: controlsVisible
152 id: resolutionIndicator
153 source: "image://theme/" + Data.videoIcon(settings.videoResolution);
158 source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
159 visible: settings.videoWhiteBalance != WhiteBalance.Auto
164 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
165 visible: settings.videoColorFilter != ColorTone.Normal
170 visible: settings.useGps
171 source: "image://theme/icon-m-camera-location"
173 PropertyAnimation on opacity {
174 easing.type: Easing.OutSine
175 loops: Animation.Infinite
179 running: settings.useGps && !positionSource.position.longitudeValid
187 anchors.bottom: parent.bottom
188 anchors.right: parent.right
189 anchors.rightMargin: 20
190 anchors.bottomMargin: 20
192 visible: controlsVisible
200 id: recordingDuration
202 property int duration: 0
204 running: videoMode.recording
209 duration = duration + 1;
210 if (duration == 3600) {
211 page.stopRecording();
212 showError(qsTr("Maximum recording time reached."));
214 else if (!checkDiskSpace()) {
215 page.stopRecording();
216 showError(qsTr("Not enough space to continue recording."));
223 source: "image://theme/icon-m-camera-ongoing-recording"
226 anchors.verticalCenter: parent.verticalCenter
227 anchors.left: parent.left
228 anchors.leftMargin: 5
230 sourceSize.height: 20
234 function formatDuration(dur) {
235 var secs = parseInt(recordingDuration.duration);
236 var minutes = Math.floor(secs / 60);
237 var seconds = secs - (minutes * 60);
239 var date = new Date();
240 date.setSeconds(seconds);
241 date.setMinutes(minutes);
242 return Qt.formatTime(date, "mm:ss");
246 text: formatDuration(recordingDuration.duration);
247 anchors.left: recordingIcon.right
248 anchors.leftMargin: 5
254 anchors.bottom: parent.bottom
255 anchors.bottomMargin: 20
256 anchors.left: parent.left
257 anchors.leftMargin: 20
259 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
260 visible: controlsVisible
261 expanded: settings.showToolBar
262 onExpandedChanged: settings.showToolBar = expanded;
269 onClicked: toolBar.push(items);
271 VideoWhiteBalanceButton {
272 onClicked: toolBar.push(items);
274 VideoColorFilterButton {
275 onClicked: toolBar.push(items);
280 iconSource: "image://theme/icon-m-toolbar-view-menu-white"
281 onClicked: openFile("VideoSettingsPage.qml");