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
31 property bool recording: false
34 property bool animationRunning: false
35 property int policyMode: recording == true ? CameraResources.Recording : CameraResources.Video
36 property bool controlsVisible: !animationRunning && cam.running && dimmer.opacity == 0.0
39 property bool pressed: overlay.recording || capture.pressed ||
40 zoomSlider.pressed || modeButton.pressed
42 signal previewAvailable(string uri)
49 onPreviewAvailable: overlay.previewAvailable(preview)
55 anchors.top: parent.top
57 anchors.horizontalCenter: parent.horizontalCenter
58 visible: controlsVisible
63 anchors.bottom: parent.bottom
64 anchors.right: parent.right
65 anchors.rightMargin: 20
66 anchors.bottomMargin: 20
67 visible: controlsVisible && !overlay.recording
72 onReleased: overlay.toggleRecording()
77 zoomCapture: zoomCapture
82 anchors.right: parent.right
83 anchors.rightMargin: 20
84 anchors.verticalCenter: parent.verticalCenter
85 iconSource: overlay.recording ? "image://theme/icon-m-camera-video-record" : "image://theme/icon-m-camera-video-record"
90 onClicked: overlay.toggleRecording()
92 visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
97 anchors.bottom: parent.bottom
98 anchors.bottomMargin: 20
99 anchors.left: parent.left
100 anchors.leftMargin: 20
102 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
103 visible: controlsVisible
104 expanded: settings.showToolBar
105 onExpandedChanged: settings.showToolBar = expanded;
112 // TODO: hide when recording
113 onClicked: toolBar.push(items)
116 onClicked: toolBar.push(items)
118 VideoWhiteBalanceButton {
119 onClicked: toolBar.push(items)
121 VideoColorFilterButton {
122 onClicked: toolBar.push(items)
130 anchors.top: parent.top
131 anchors.topMargin: 20
132 anchors.left: parent.left
133 anchors.leftMargin: 20
140 visible: controlsVisible
148 id: resolutionIndicator
149 source: "image://theme/" + Data.videoIcon(settings.videoResolution)
154 source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
155 visible: settings.videoWhiteBalance != WhiteBalance.Auto
160 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
161 visible: settings.videoColorFilter != ColorTone.Normal
166 visible: settings.useGps
167 source: "image://theme/icon-m-camera-location"
169 PropertyAnimation on opacity {
170 easing.type: Easing.OutSine
171 loops: Animation.Infinite
175 running: settings.useGps && !positionSource.position.longitudeValid
183 inhibitDim: overlay.recording
187 target: Qt.application
189 if (!Qt.application.active && overlay.recording) {
190 overlay.stopRecording()
196 id: recordingDuration
197 property int duration: 0
198 running: overlay.recording
203 duration = duration + 1
205 if (duration == 3600) {
206 overlay.stopRecording()
207 showError(qsTr("Maximum recording time reached."))
208 } else if (!checkDiskSpace()) {
210 showError(qsTr("Not enough space to continue recording."))
216 RecordingDurationLabel {
217 visible: overlay.recording
218 duration: recordingDuration.duration
221 function doStartRecording() {
222 if (!overlay.recording) {
226 if (!pipelineManager.acquired || pipelineManager.hijacked) {
227 showError(qsTr("Failed to acquire needed resources."))
228 overlay.recording = false
232 metaData.setMetaData()
234 if (!mountProtector.lock()) {
235 showError(qsTr("Failed to lock images directory."))
236 overlay.recording = false
240 var file = fileNaming.videoFileName()
241 var tmpFile = fileNaming.temporaryVideoFileName()
243 if (!videoMode.startRecording(file, tmpFile)) {
244 showError(qsTr("Failed to record video. Please restart the camera."))
245 mountProtector.unlock()
246 overlay.recording = false
250 trackerStore.storeVideo(file);
253 function startRecording() {
254 if (!fileSystem.available) {
255 showError(qsTr("Camera cannot record videos in mass storage mode."))
256 } else if (!checkBattery()) {
257 showError(qsTr("Not enough battery to record video."))
258 } else if (!checkDiskSpace()) {
259 showError(qsTr("Not enough space to record video."))
261 recordingDuration.duration = 0
262 overlay.recording = true
267 function stopRecording() {
268 videoMode.stopRecording(true)
269 mountProtector.unlock()
270 overlay.recording = false
273 function toggleRecording() {
274 if (overlay.recording) {
275 overlay.stopRecording()
277 overlay.startRecording()
281 function cameraError() {
282 overlay.stopRecording()
285 function policyLost() {
286 overlay.stopRecording()
289 function batteryLow() {
290 if (!overlay.recording) {
294 if (!checkBattery()) {
295 overlay.stopRecording()
296 showError(qsTr("Not enough battery to record video."))