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();
152 visible: videoControlsVisible
153 anchors.top: parent.top
154 anchors.left: parent.left
155 anchors.topMargin: 20
156 anchors.leftMargin: 20
162 visible: controlsVisible
163 anchors.top: torch.bottom
164 anchors.left: parent.left
165 anchors.topMargin: 10
166 anchors.leftMargin: 20
171 visible: videoControlsVisible
172 anchors.top: scene.bottom
173 anchors.left: parent.left
174 anchors.topMargin: 10
175 anchors.leftMargin: 20
180 anchors.bottom: parent.bottom
181 anchors.bottomMargin: 20
182 anchors.left: parent.left
183 anchors.leftMargin: 20
186 onClicked: openFile("VideoSettingsPage.qml");
187 visible: controlsVisible
193 source: indicators.pressed ? "image://theme/meegotouch-camera-settings-indicators-background-pressed" : "image://theme/meegotouch-camera-settings-indicators-background"
202 id: resolutionIndicator
203 source: "image://theme/" + Data.videoIcon(settings.videoResolution);
208 source: "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen"
209 visible: settings.videoWhiteBalance != WhiteBalance.Auto
214 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
215 visible: settings.videoColorFilter != ColorTone.Normal
220 visible: settings.useGps
221 source: "image://theme/icon-m-camera-location"
223 PropertyAnimation on opacity {
224 easing.type: Easing.OutSine
225 loops: Animation.Infinite
229 running: settings.useGps && !positionSource.position.longitudeValid
238 anchors.top: parent.top
239 anchors.right: parent.right
240 anchors.topMargin: 20
241 anchors.rightMargin: 20
246 iconSource: "image://theme/icon-m-camera-roll"
247 onClicked: openFile("PostCapturePage.qml");
248 visible: controlsVisible && !videoMode.recording
252 anchors.left: parent.left
253 anchors.bottom: parent.bottom
254 anchors.leftMargin: 20
255 anchors.bottomMargin: 20
257 visible: videoControlsVisible && videoMode.recording
265 id: recordingDuration
267 property int duration: 0
269 running: cam.running && videoMode.recording
270 triggeredOnStart: true
275 duration = duration + 1;
276 if (duration == 3600) {
277 videoMode.stopRecording();
278 showError(qsTr("Maximum recording time reached."));
280 else if (!checkDiskSpace()) {
281 videoMode.stopRecording();
282 showError(qsTr("Not enough space to continue recording."));
295 source: "image://theme/icon-m-camera-ongoing-recording"
298 anchors.verticalCenter: parent.verticalCenter
299 anchors.left: parent.left
300 anchors.leftMargin: 5
302 sourceSize.height: 20
306 function formatDuration(dur) {
307 var secs = parseInt(dur);
308 var mins = Math.floor(secs / 60);
309 var seconds = secs - (mins * 60);
316 seconds = "0" + seconds;
319 return mins + ":" + seconds;
323 text: formatDuration(recordingDuration.duration);
324 anchors.left: recordingIcon.right
325 anchors.leftMargin: 5