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
24 import com.nokia.meego 1.1
27 import "data.js" as Data
29 // TODO: optional resources?
34 property bool error: false
36 policyMode: CameraResources.Recording
38 controlsVisible: cam.running && videoMode.recording && !error
40 orientationLock: PageOrientation.LockLandscape
42 function policyLost() {
46 function cameraError() {
52 if (page.status == PageStatus.Active) {
57 function startRecording() {
58 if (!pipelineManager.acquired || pipelineManager.hijacked) {
59 showError(qsTr("Failed to acquire needed resources."));
60 pageStack.pop(undefined, true);
64 metaData.setMetaData();
66 if (!mountProtector.lock()) {
67 showError(qsTr("Failed to lock images directory."));
68 pageStack.pop(undefined, true);
72 var file = fileNaming.videoFileName();
73 var tmpFile = fileNaming.temporaryVideoFileName();
75 if (!videoMode.startRecording(file, tmpFile)) {
76 showError(qsTr("Failed to record video. Please restart the camera."));
77 pageStack.pop(undefined, true);
78 mountProtector.unlock();
81 trackerStore.storeVideo(file);
84 function stopRecording() {
85 videoMode.stopRecording(true);
86 mountProtector.unlock();
87 // Something is fishy here but if there is an error
88 // and we use immediate mode then the page never gets destroyed.
89 pageStack.pop(undefined, error ? false : true);
97 if (!checkBattery()) {
99 showError(qsTr("Not enough battery to record video."));
105 anchors.right: parent.right
106 anchors.rightMargin: 20
107 anchors.verticalCenter: parent.verticalCenter
108 iconSource: "image://theme/icon-m-camera-video-record"
113 onClicked: page.stopRecording();
114 visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
118 target: Qt.application
120 if (!Qt.application.active) {
121 page.stopRecording();
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 source: "image://theme/" + Data.videoIcon(settings.videoResolution);
156 source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
157 visible: settings.videoWhiteBalance != WhiteBalance.Auto
162 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
163 visible: settings.videoColorFilter != ColorTone.Normal
168 visible: settings.useGps
169 source: "image://theme/icon-m-camera-location"
171 PropertyAnimation on opacity {
172 easing.type: Easing.OutSine
173 loops: Animation.Infinite
177 running: settings.useGps && !positionSource.position.longitudeValid
185 anchors.bottom: parent.bottom
186 anchors.right: parent.right
187 anchors.rightMargin: 20
188 anchors.bottomMargin: 20
190 visible: controlsVisible
198 id: recordingDuration
200 property int duration: 0
202 running: videoMode.recording
207 duration = duration + 1;
208 if (duration == 3600) {
209 page.stopRecording();
210 showError(qsTr("Maximum recording time reached."));
212 else if (!checkDiskSpace()) {
213 page.stopRecording();
214 showError(qsTr("Not enough space to continue recording."));
221 source: "image://theme/icon-m-camera-ongoing-recording"
224 anchors.verticalCenter: parent.verticalCenter
225 anchors.left: parent.left
226 anchors.leftMargin: 5
228 sourceSize.height: 20
232 function formatDuration(dur) {
233 var secs = parseInt(recordingDuration.duration);
234 var minutes = Math.floor(secs / 60);
235 var seconds = secs - (minutes * 60);
237 var date = new Date();
238 date.setSeconds(seconds);
239 date.setMinutes(minutes);
240 return Qt.formatTime(date, "mm:ss");
244 text: formatDuration(recordingDuration.duration);
245 anchors.left: recordingIcon.right
246 anchors.leftMargin: 5
252 anchors.bottom: parent.bottom
253 anchors.bottomMargin: 20
254 anchors.left: parent.left
255 anchors.leftMargin: 20
257 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
258 visible: controlsVisible
259 expanded: settings.showToolBar
260 onExpandedChanged: settings.showToolBar = expanded;
267 onClicked: toolBar.push(items);
269 VideoWhiteBalanceButton {
270 onClicked: toolBar.push(items);
272 VideoColorFilterButton {
273 onClicked: toolBar.push(items);
278 iconSource: "image://theme/icon-m-toolbar-view-menu-white"
279 onClicked: openFile("VideoSettingsPage.qml");