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
32 policyMode: CameraResources.Video
34 controlsVisible: videoControlsVisible && !videoMode.recording
35 property bool videoControlsVisible: recording.visible && cam.running && !standbyWidget.visible
37 orientationLock: PageOrientation.LockLandscape
40 inhibitDim: videoMode.recording
44 if (!videoMode.recording) {
48 if (!checkBattery()) {
49 videoMode.stopRecording();
50 showError(qsTr("Not enough battery to record video."));
56 anchors.right: parent.right
57 anchors.rightMargin: 20
58 anchors.verticalCenter: parent.verticalCenter
59 iconSource: "image://theme/icon-m-camera-video-record"
64 onClicked: buttonClicked();
66 function buttonClicked() {
67 if (!fileSystem.available) {
68 showError(qsTr("Camera cannot record videos in mass storage mode."));
72 // We only toggle the mode to video recording so
73 // policy can acquire the needed resources
75 if (policyMode == CameraResources.Video) {
76 if (!checkBattery()) {
77 showError(qsTr("Not enough battery to record video."));
81 if (!checkDiskSpace()) {
82 showError(qsTr("Not enough space to record video."));
86 policyMode = CameraResources.Recording;
88 else if (videoMode.recording) {
89 // We just ask to stop video.
90 videoMode.stopRecording();
97 if (!videoMode.recording) {
98 policyMode = CameraResources.Video;
104 target: resourcePolicy
106 if (resourcePolicy.acquired && policyMode == CameraResources.Recording) {
107 metaData.setMetaData();
109 if (!mountProtector.lock()) {
110 showError(qsTr("Failed to lock images directory."));
111 policyMode = CameraResources.Video
116 if (!videoMode.startRecording(fileNaming.videoFileName(),
117 fileNaming.temporaryVideoFileName())) {
118 showError(qsTr("Failed to record video. Please restart the camera."));
119 policyMode = CameraResources.Video
125 visible: (videoMode.recording || videoMode.canCapture) && !cameraMode.animationRunning && !previewAnimationRunning && !standbyWidget.visible
129 target: Qt.application
131 if (!Qt.application.active && videoMode.recording) {
132 videoMode.stopRecording();
140 onPreviewAvailable: {
141 if (!standbyWidget.visible) {
142 page.setPreview(preview);
146 onSaved: mountProtector.unlock();
151 visible: videoControlsVisible
152 anchors.top: parent.top
153 anchors.left: parent.left
154 anchors.topMargin: 20
155 anchors.leftMargin: 20
161 visible: controlsVisible
162 anchors.top: torch.bottom
163 anchors.left: parent.left
164 anchors.topMargin: 10
165 anchors.leftMargin: 20
170 visible: videoControlsVisible
171 anchors.top: scene.bottom
172 anchors.left: parent.left
173 anchors.topMargin: 10
174 anchors.leftMargin: 20
179 anchors.bottom: parent.bottom
180 anchors.bottomMargin: 20
181 anchors.left: parent.left
182 anchors.leftMargin: 20
185 onClicked: openFile("VideoSettingsPage.qml");
186 visible: controlsVisible
192 source: indicators.pressed ? "image://theme/meegotouch-camera-settings-indicators-background-pressed" : "image://theme/meegotouch-camera-settings-indicators-background"
201 id: resolutionIndicator
202 source: "image://theme/" + Data.videoIcon(settings.videoResolution);
207 source: "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen"
208 visible: settings.videoWhiteBalance != WhiteBalance.Auto
213 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
214 visible: settings.videoColorFilter != ColorTone.Normal
219 visible: settings.useGps
220 source: "image://theme/icon-m-camera-location"
222 PropertyAnimation on opacity {
223 easing.type: Easing.OutSine
224 loops: Animation.Infinite
228 running: settings.useGps && !positionSource.position.longitudeValid
237 anchors.top: parent.top
238 anchors.right: parent.right
239 anchors.topMargin: 20
240 anchors.rightMargin: 20
245 iconSource: "image://theme/icon-m-camera-roll"
246 onClicked: openFile("PostCapturePage.qml");
247 visible: controlsVisible && !videoMode.recording
251 anchors.left: parent.left
252 anchors.bottom: parent.bottom
253 anchors.leftMargin: 20
254 anchors.bottomMargin: 20
256 visible: videoControlsVisible && videoMode.recording
264 id: recordingDuration
266 property int duration: 0
268 running: cam.running && videoMode.recording
269 triggeredOnStart: true
274 duration = duration + 1;
275 if (duration == 3600) {
276 videoMode.stopRecording();
277 showError(qsTr("Maximum recording time reached."));
279 else if (!checkDiskSpace()) {
280 videoMode.stopRecording();
281 showError(qsTr("Not enough space to continue recording."));
294 source: "image://theme/icon-m-camera-ongoing-recording"
297 anchors.verticalCenter: parent.verticalCenter
298 anchors.left: parent.left
299 anchors.leftMargin: 5
301 sourceSize.height: 20
305 function formatDuration(dur) {
306 var secs = parseInt(dur);
307 var mins = Math.floor(secs / 60);
308 var seconds = secs - (mins * 60);
315 seconds = "0" + seconds;
318 return mins + ":" + seconds;
322 text: formatDuration(recordingDuration.duration);
323 anchors.left: recordingIcon.right
324 anchors.leftMargin: 5