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 source: "image://theme/" + Data.videoIcon(settings.videoResolution)
157 source: visible ? "image://theme/" + Data.wbIcon(settings.videoWhiteBalance) + "-screen" : ""
158 visible: settings.videoWhiteBalance != WhiteBalance.Auto
163 source: "image://theme/" + Data.cfIcon(settings.videoColorFilter) + "-screen"
164 visible: settings.videoColorFilter != ColorTone.Normal
169 visible: settings.useGps
170 source: cameraTheme.gpsIndicatorIcon
172 PropertyAnimation on opacity {
173 easing.type: Easing.OutSine
174 loops: Animation.Infinite
178 running: settings.useGps && !positionSource.position.longitudeValid
186 inhibitDim: overlay.recording
190 target: Qt.application
192 if (!Qt.application.active && overlay.recording) {
193 overlay.stopRecording()
199 id: recordingDuration
200 property int duration: 0
201 running: overlay.recording
206 duration = duration + 1
208 if (duration == 3600) {
209 overlay.stopRecording()
210 showError(qsTr("Maximum recording time reached."))
211 } else if (!checkDiskSpace()) {
213 showError(qsTr("Not enough space to continue recording."))
219 RecordingDurationLabel {
220 visible: overlay.recording
221 duration: recordingDuration.duration
224 function doStartRecording() {
225 if (!overlay.recording) {
229 if (!pipelineManager.acquired || pipelineManager.hijacked) {
230 showError(qsTr("Failed to acquire needed resources."))
231 overlay.recording = false
235 metaData.setMetaData()
237 if (!mountProtector.lock()) {
238 showError(qsTr("Failed to lock images directory."))
239 overlay.recording = false
243 var file = fileNaming.videoFileName()
244 var tmpFile = fileNaming.temporaryVideoFileName()
246 if (!videoMode.startRecording(file, tmpFile)) {
247 showError(qsTr("Failed to record video. Please restart the camera."))
248 mountProtector.unlock()
249 overlay.recording = false
253 trackerStore.storeVideo(file);
256 function startRecording() {
257 if (!fileSystem.available) {
258 showError(qsTr("Camera cannot record videos in mass storage mode."))
259 } else if (!checkBattery()) {
260 showError(qsTr("Not enough battery to record video."))
261 } else if (!checkDiskSpace()) {
262 showError(qsTr("Not enough space to record video."))
264 recordingDuration.duration = 0
265 overlay.recording = true
270 function stopRecording() {
271 videoMode.stopRecording(true)
272 mountProtector.unlock()
273 overlay.recording = false
276 function toggleRecording() {
277 if (overlay.recording) {
278 overlay.stopRecording()
280 overlay.startRecording()
284 function cameraError() {
285 overlay.stopRecording()
288 function policyLost() {
289 overlay.stopRecording()
292 function batteryLow() {
293 if (!overlay.recording) {
297 if (!checkBattery()) {
298 overlay.stopRecording()
299 showError(qsTr("Not enough battery to record video."))