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
26 import "data.js" as Data
30 property bool recording: false
33 property bool animationRunning: false
34 property int policyMode: recording == true ? CameraResources.Recording : CameraResources.Video
35 property bool controlsVisible: !animationRunning && cam != null && cam.running
36 && dimmer.opacity == 0.0 && !cameraMode.busy
37 property bool pressed: overlay.recording || capture.pressed ||
38 zoomSlider.pressed || modeButton.pressed
40 signal previewAvailable(string uri)
47 onPreviewAvailable: overlay.previewAvailable(preview)
53 anchors.top: parent.top
55 anchors.horizontalCenter: parent.horizontalCenter
56 visible: controlsVisible
61 anchors.bottom: parent.bottom
62 anchors.right: parent.right
63 anchors.rightMargin: 20
64 anchors.bottomMargin: 20
65 visible: controlsVisible && !overlay.recording
70 onReleased: overlay.toggleRecording()
75 zoomCapture: zoomCapture
80 anchors.right: parent.right
81 anchors.rightMargin: 20
82 anchors.verticalCenter: parent.verticalCenter
83 iconId: overlay.recording ? cameraTheme.captureButtonRecordingIconId : cameraTheme.captureButtonVideoIconId
88 onClicked: overlay.toggleRecording()
90 visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
95 anchors.bottom: parent.bottom
96 anchors.bottomMargin: 20
97 anchors.left: parent.left
98 anchors.leftMargin: 20
100 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
101 visible: controlsVisible
102 expanded: settings.showToolBar
103 onExpandedChanged: settings.showToolBar = expanded;
105 tools: CameraToolBarTools {
111 visible: !overlay.recording
112 onClicked: toolBar.push(tools)
116 onClicked: toolBar.push(tools)
119 VideoWhiteBalanceButton {
120 onClicked: toolBar.push(tools)
123 VideoColorFilterButton {
124 onClicked: toolBar.push(tools)
133 anchors.top: parent.top
134 anchors.topMargin: 20
135 anchors.left: parent.left
136 anchors.leftMargin: 20
143 visible: controlsVisible
151 id: resolutionIndicator
152 property string videoResolution: settings.device == 1 ? settings.secondaryVideoResolution : settings.primaryVideoResolution
153 property string videoRatio: settings.device == 1 ? settings.secondaryVideoAspectRatio : settings.primaryVideoAspectRatio
154 source: "image://theme/" + cameraTheme.videoIcon(videoRatio, videoResolution, settings.device)
159 source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
160 visible: settings.videoWhiteBalance != WhiteBalance.Auto
165 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
166 visible: settings.videoColorFilter != ColorTone.Normal
171 visible: settings.useGps
172 source: cameraTheme.gpsIndicatorIcon
174 PropertyAnimation on opacity {
175 easing.type: Easing.OutSine
176 loops: Animation.Infinite
180 running: settings.useGps && !positionSource.position.longitudeValid
188 inhibitDim: overlay.recording
192 target: Qt.application
194 if (!Qt.application.active && overlay.recording) {
195 overlay.stopRecording()
201 id: recordingDuration
202 property int duration: 0
203 running: overlay.recording
208 duration = duration + 1
210 if (duration == 3600) {
211 overlay.stopRecording()
212 showError(qsTr("Maximum recording time reached."))
213 } else if (!checkDiskSpace()) {
215 showError(qsTr("Not enough space to continue recording."))
221 RecordingDurationLabel {
222 visible: overlay.recording
223 duration: recordingDuration.duration
226 function doStartRecording() {
227 if (!overlay.recording) {
231 if (!pipelineManager.acquired || pipelineManager.hijacked) {
232 showError(qsTr("Failed to acquire needed resources."))
233 overlay.recording = false
237 metaData.setMetaData()
239 if (!mountProtector.lock()) {
240 showError(qsTr("Failed to lock images directory."))
241 overlay.recording = false
245 var file = fileNaming.videoFileName()
246 var tmpFile = fileNaming.temporaryVideoFileName()
248 if (!videoMode.startRecording(file, tmpFile)) {
249 showError(qsTr("Failed to record video. Please restart the camera."))
250 mountProtector.unlock()
251 overlay.recording = false
255 trackerStore.storeVideo(file);
258 function startRecording() {
259 if (!fileSystem.available) {
260 showError(qsTr("Camera cannot record videos in mass storage mode."))
261 } else if (!checkBattery()) {
262 showError(qsTr("Not enough battery to record video."))
263 } else if (!checkDiskSpace()) {
264 showError(qsTr("Not enough space to record video."))
266 recordingDuration.duration = 0
267 overlay.recording = true
272 function stopRecording() {
273 videoMode.stopRecording(true)
274 mountProtector.unlock()
275 overlay.recording = false
278 function toggleRecording() {
279 if (overlay.recording) {
280 overlay.stopRecording()
282 overlay.startRecording()
286 function cameraError() {
287 overlay.stopRecording()
290 function policyLost() {
291 overlay.stopRecording()
294 function batteryLow() {
295 if (!overlay.recording) {
299 if (!checkBattery()) {
300 overlay.stopRecording()
301 showError(qsTr("Not enough battery to record video."))