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
29 property bool recording: false
32 property bool animationRunning: false
33 property int policyMode: recording == true ? CameraResources.Recording : CameraResources.Video
34 property bool controlsVisible: !animationRunning && cam != null && cam.running
35 && dimmer.opacity == 0.0 && !cameraMode.busy
36 property bool pressed: overlay.recording || capture.pressed ||
37 zoomSlider.pressed || modeButton.pressed
39 signal previewAvailable(string uri)
46 onPreviewAvailable: overlay.previewAvailable(preview)
52 anchors.top: parent.top
54 anchors.horizontalCenter: parent.horizontalCenter
55 visible: controlsVisible
60 anchors.bottom: parent.bottom
61 anchors.right: parent.right
62 anchors.rightMargin: 20
63 anchors.bottomMargin: 20
64 visible: controlsVisible && !overlay.recording
69 onReleased: overlay.toggleRecording()
74 zoomCapture: zoomCapture
79 anchors.right: parent.right
80 anchors.rightMargin: 20
81 anchors.verticalCenter: parent.verticalCenter
82 iconSource: overlay.recording ? cameraTheme.captureButtonRecordingIconId : cameraTheme.captureButtonVideoIconId
87 onClicked: overlay.toggleRecording()
89 visible: controlsVisible && (!settings.zoomAsShutter && keys.active)
94 anchors.bottom: parent.bottom
95 anchors.bottomMargin: 20
96 anchors.left: parent.left
97 anchors.leftMargin: 20
99 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
100 visible: controlsVisible
101 expanded: settings.showToolBar
102 onExpandedChanged: settings.showToolBar = expanded;
104 tools: CameraToolBarTools {
107 visible: !overlay.cam.quirks.hasQuirk(Quirks.NoVideoTorch)
111 property bool hide: (overlay.recording && overlay.cam.quirks.hasQuirk(Quirks.NoSceneModeChangeDuringRecording)) || overlay.cam.quirks.hasQuirk(Quirks.NoNightSceneMode)
113 onClicked: toolBar.push(tools)
117 onClicked: toolBar.push(tools)
120 VideoWhiteBalanceButton {
121 onClicked: toolBar.push(tools)
124 VideoColorFilterButton {
125 onClicked: toolBar.push(tools)
134 anchors.top: parent.top
135 anchors.topMargin: 20
136 anchors.left: parent.left
137 anchors.leftMargin: 20
144 visible: controlsVisible
152 id: resolutionIndicator
153 property string videoResolution: settings.device == 1 ? settings.secondaryVideoResolution : settings.primaryVideoResolution
154 property string videoRatio: settings.device == 1 ? settings.secondaryVideoAspectRatio : settings.primaryVideoAspectRatio
155 source: cameraTheme.videoIcon(videoRatio, videoResolution, settings.device)
160 source: visible ? cameraTheme.whiteBalanceIcon(settings.videoWhiteBalance) : ""
161 visible: settings.videoWhiteBalance != WhiteBalance.Auto && !toolBar.expanded
166 source: visible ? cameraTheme.colorFilterIcon(settings.videoColorFilter) : ""
167 visible: settings.videoColorFilter != ColorTone.Normal && !toolBar.expanded
172 visible: settings.videoSceneMode != Scene.Auto && (!toolBar.expanded || overlay.recording)
173 source: visible ? cameraTheme.videoSceneModeIcon(settings.videoSceneMode) : ""
178 visible: settings.useGps
179 source: cameraTheme.gpsIndicatorIcon
181 PropertyAnimation on opacity {
182 easing.type: Easing.OutSine
183 loops: Animation.Infinite
187 running: settings.useGps && !positionSource.position.longitudeValid
195 inhibitDim: overlay.recording
199 target: Qt.application
201 if (!Qt.application.active && overlay.recording) {
202 overlay.stopRecording()
208 id: recordingDuration
209 property int duration: 0
210 running: overlay.recording
215 duration = duration + 1
217 if (duration == 3600) {
218 overlay.stopRecording()
219 showError(qsTr("Maximum recording time reached."))
220 } else if (!fileSystem.hasFreeSpace(fileNaming.temporaryVideoPath)) {
222 showError(qsTr("Not enough space to continue recording."))
228 RecordingDurationLabel {
229 visible: overlay.recording
230 duration: recordingDuration.duration
233 function resetToolBar() {
234 if (toolBar.depth() > 1) {
239 function doStartRecording() {
240 if (!overlay.recording) {
244 if (!pipelineManager.acquired || pipelineManager.hijacked) {
245 showError(qsTr("Failed to acquire needed resources."))
246 overlay.recording = false
250 metaData.setMetaData()
252 if (!mountProtector.lock(fileNaming.temporaryVideoPath)) {
253 showError(qsTr("Failed to lock temporary videos directory."))
254 overlay.recording = false
258 if (!mountProtector.lock(fileNaming.videoPath)) {
259 showError(qsTr("Failed to lock videos directory."))
260 overlay.recording = false
261 mountProtector.unlockAll()
265 var file = fileNaming.videoFileName()
266 var tmpFile = fileNaming.temporaryVideoFileName()
268 if (!videoMode.startRecording(file, tmpFile)) {
269 showError(qsTr("Failed to record video. Please restart the camera."))
270 mountProtector.unlockAll()
271 overlay.recording = false
275 trackerStore.storeVideo(file);
280 function startRecording() {
281 if (!fileSystem.available) {
282 showError(qsTr("Camera cannot record videos in mass storage mode."))
283 } else if (!checkBattery()) {
284 showError(qsTr("Not enough battery to record video."))
285 } else if (!fileSystem.hasFreeSpace(fileNaming.videoPath) || !fileSystem.hasFreeSpace(fileNaming.temporaryVideoPath)) {
286 showError(qsTr("Not enough space to record video."))
288 recordingDuration.duration = 0
289 overlay.recording = true
294 function stopRecording() {
295 videoMode.stopRecording(true)
296 mountProtector.unlockAll()
297 overlay.recording = false
300 function toggleRecording() {
301 if (overlay.recording) {
302 overlay.stopRecording()
304 overlay.startRecording()
308 function cameraError() {
309 overlay.stopRecording()
312 function policyLost() {
313 overlay.stopRecording()
316 function batteryLow() {
317 if (!overlay.recording) {
321 if (!checkBattery()) {
322 overlay.stopRecording()
323 showError(qsTr("Not enough battery to record video."))
327 function cameraDeviceChanged() {