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 != null && cam.running
37 && dimmer.opacity == 0.0 && !cameraMode.busy
38 property bool pressed: overlay.recording || capture.pressed ||
39 zoomSlider.pressed || modeButton.pressed
41 signal previewAvailable(string uri)
48 onPreviewAvailable: overlay.previewAvailable(preview)
54 anchors.top: parent.top
56 anchors.horizontalCenter: parent.horizontalCenter
57 visible: controlsVisible
62 anchors.bottom: parent.bottom
63 anchors.right: parent.right
64 anchors.rightMargin: 20
65 anchors.bottomMargin: 20
66 visible: controlsVisible && !overlay.recording
71 onReleased: overlay.toggleRecording()
76 zoomCapture: zoomCapture
81 anchors.right: parent.right
82 anchors.rightMargin: 20
83 anchors.verticalCenter: parent.verticalCenter
84 iconSource: overlay.recording ? "image://theme/icon-m-camera-video-record" : "image://theme/icon-m-camera-video-record"
89 onClicked: overlay.toggleRecording()
91 visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
96 anchors.bottom: parent.bottom
97 anchors.bottomMargin: 20
98 anchors.left: parent.left
99 anchors.leftMargin: 20
101 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
102 visible: controlsVisible
103 expanded: settings.showToolBar
104 onExpandedChanged: settings.showToolBar = expanded;
111 // TODO: hide when recording
112 onClicked: toolBar.push(items)
115 onClicked: toolBar.push(items)
117 VideoWhiteBalanceButton {
118 onClicked: toolBar.push(items)
120 VideoColorFilterButton {
121 onClicked: toolBar.push(items)
129 anchors.top: parent.top
130 anchors.topMargin: 20
131 anchors.left: parent.left
132 anchors.leftMargin: 20
139 visible: controlsVisible
147 id: resolutionIndicator
148 source: "image://theme/" + Data.videoIcon(settings.videoResolution)
153 source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
154 visible: settings.videoWhiteBalance != WhiteBalance.Auto
159 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
160 visible: settings.videoColorFilter != ColorTone.Normal
165 visible: settings.useGps
166 source: "image://theme/icon-m-camera-location"
168 PropertyAnimation on opacity {
169 easing.type: Easing.OutSine
170 loops: Animation.Infinite
174 running: settings.useGps && !positionSource.position.longitudeValid
182 inhibitDim: overlay.recording
186 target: Qt.application
188 if (!Qt.application.active && overlay.recording) {
189 overlay.stopRecording()
195 id: recordingDuration
196 property int duration: 0
197 running: overlay.recording
202 duration = duration + 1
204 if (duration == 3600) {
205 overlay.stopRecording()
206 showError(qsTr("Maximum recording time reached."))
207 } else if (!checkDiskSpace()) {
209 showError(qsTr("Not enough space to continue recording."))
215 RecordingDurationLabel {
216 visible: overlay.recording
217 duration: recordingDuration.duration
220 function doStartRecording() {
221 if (!overlay.recording) {
225 if (!pipelineManager.acquired || pipelineManager.hijacked) {
226 showError(qsTr("Failed to acquire needed resources."))
227 overlay.recording = false
231 metaData.setMetaData()
233 if (!mountProtector.lock()) {
234 showError(qsTr("Failed to lock images directory."))
235 overlay.recording = false
239 var file = fileNaming.videoFileName()
240 var tmpFile = fileNaming.temporaryVideoFileName()
242 if (!videoMode.startRecording(file, tmpFile)) {
243 showError(qsTr("Failed to record video. Please restart the camera."))
244 mountProtector.unlock()
245 overlay.recording = false
249 trackerStore.storeVideo(file);
252 function startRecording() {
253 if (!fileSystem.available) {
254 showError(qsTr("Camera cannot record videos in mass storage mode."))
255 } else if (!checkBattery()) {
256 showError(qsTr("Not enough battery to record video."))
257 } else if (!checkDiskSpace()) {
258 showError(qsTr("Not enough space to record video."))
260 recordingDuration.duration = 0
261 overlay.recording = true
266 function stopRecording() {
267 videoMode.stopRecording(true)
268 mountProtector.unlock()
269 overlay.recording = false
272 function toggleRecording() {
273 if (overlay.recording) {
274 overlay.stopRecording()
276 overlay.startRecording()
280 function cameraError() {
281 overlay.stopRecording()
284 function policyLost() {
285 overlay.stopRecording()
288 function batteryLow() {
289 if (!overlay.recording) {
293 if (!checkBattery()) {
294 overlay.stopRecording()
295 showError(qsTr("Not enough battery to record video."))