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
38 property bool inhibitDim: recording
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
74 capturePressed: capture.pressed
75 zoomPressed: zoomCapture.zoomPressed
76 proximityClosed: proximitySensor.sensorClosed
77 onStartCapture: overlay.toggleRecording()
82 enabled: captureControl.showCancelBanner
83 onPressed: captureControl.canceled = true
88 anchors.right: parent.right
89 anchors.rightMargin: 20
90 anchors.verticalCenter: parent.verticalCenter
91 iconSource: overlay.recording ? cameraTheme.captureButtonRecordingIconId : cameraTheme.captureButtonVideoIconId
96 visible: controlsVisible
99 if (mouseX <= 0 || mouseY <= 0 || mouseX > width || mouseY > height) {
100 // Release outside the button:
101 captureControl.canceled = true
108 anchors.bottom: parent.bottom
109 anchors.bottomMargin: 20
110 anchors.left: parent.left
111 anchors.leftMargin: 20
113 targetWidth: parent.width - (anchors.leftMargin * 2) - (66 * 1.5)
114 visible: controlsVisible
115 expanded: settings.showToolBar
116 onExpandedChanged: settings.showToolBar = expanded;
118 tools: CameraToolBarTools {
121 visible: overlay.cam ? !overlay.cam.quirks.hasQuirk(Quirks.NoVideoTorch) : false
125 property bool hide: overlay.cam ? (overlay.recording && overlay.cam.quirks.hasQuirk(Quirks.NoSceneModeChangeDuringRecording)) || overlay.cam.quirks.hasQuirk(Quirks.NoNightSceneMode) : false
127 onClicked: toolBar.push(tools)
131 onClicked: toolBar.push(tools)
134 VideoWhiteBalanceButton {
135 onClicked: toolBar.push(tools)
138 VideoColorFilterButton {
139 onClicked: toolBar.push(tools)
148 anchors.top: parent.top
149 anchors.topMargin: 20
150 anchors.left: parent.left
151 anchors.leftMargin: 20
158 visible: controlsVisible
166 id: resolutionIndicator
167 source: cameraTheme.videoIcon(settings.videoAspectRatio,
168 settings.videoResolution, settings.device)
173 source: visible ? cameraTheme.whiteBalanceIcon(settings.videoWhiteBalance) : ""
174 visible: settings.videoWhiteBalance != WhiteBalance.Auto && !toolBar.expanded
179 source: visible ? cameraTheme.colorFilterIcon(settings.videoColorFilter) : ""
180 visible: settings.videoColorFilter != ColorTone.Normal && !toolBar.expanded
185 visible: settings.videoSceneMode != Scene.Auto && (!toolBar.expanded || overlay.recording)
186 source: visible ? cameraTheme.videoSceneModeIcon(settings.videoSceneMode) : ""
191 visible: settings.useGps
192 source: cameraTheme.gpsIndicatorIcon
194 PropertyAnimation on opacity {
195 easing.type: Easing.OutSine
196 loops: Animation.Infinite
200 running: settings.useGps && !positionSource.position.longitudeValid
208 target: Qt.application
210 if (!Qt.application.active && overlay.recording) {
211 overlay.stopRecording()
217 id: recordingDuration
218 property int duration: 0
219 running: overlay.recording
224 duration = duration + 1
226 if (duration == 3600) {
227 overlay.stopRecording()
228 showError(qsTr("Maximum recording time reached."))
229 } else if (!fileSystem.hasFreeSpace(fileNaming.temporaryVideoPath)) {
231 showError(qsTr("Not enough space to continue recording."))
237 RecordingDurationLabel {
238 visible: overlay.recording
239 duration: recordingDuration.duration
242 function resetToolBar() {
243 if (toolBar.depth() > 1) {
248 function doStartRecording() {
249 if (!overlay.recording) {
253 if (!pipelineManager.acquired || pipelineManager.hijacked) {
254 showError(qsTr("Failed to acquire needed resources."))
255 overlay.recording = false
259 metaData.setMetaData()
261 if (!mountProtector.lock(fileNaming.temporaryVideoPath)) {
262 showError(qsTr("Failed to lock temporary videos directory."))
263 overlay.recording = false
267 if (!mountProtector.lock(fileNaming.videoPath)) {
268 showError(qsTr("Failed to lock videos directory."))
269 overlay.recording = false
270 mountProtector.unlockAll()
274 var file = fileNaming.videoFileName()
275 var tmpFile = fileNaming.temporaryVideoFileName()
277 if (!videoMode.startRecording(file, tmpFile)) {
278 showError(qsTr("Failed to record video. Please restart the camera."))
279 mountProtector.unlockAll()
280 overlay.recording = false
284 trackerStore.storeVideo(file);
289 function startRecording() {
290 if (!fileSystem.available) {
291 showError(qsTr("Camera cannot record videos in mass storage mode."))
292 } else if (!checkBattery()) {
293 showError(qsTr("Not enough battery to record video."))
294 } else if (!fileSystem.hasFreeSpace(fileNaming.videoPath) || !fileSystem.hasFreeSpace(fileNaming.temporaryVideoPath)) {
295 showError(qsTr("Not enough space to record video."))
297 recordingDuration.duration = 0
298 overlay.recording = true
303 function stopRecording() {
304 videoMode.stopRecording(true)
305 mountProtector.unlockAll()
306 overlay.recording = false
309 function toggleRecording() {
310 if (overlay.recording) {
311 overlay.stopRecording()
313 overlay.startRecording()
317 function cameraError() {
318 overlay.stopRecording()
321 function policyLost() {
322 overlay.stopRecording()
325 function batteryLow() {
326 if (!overlay.recording) {
330 if (!checkBattery()) {
331 overlay.stopRecording()
332 showError(qsTr("Not enough battery to record video."))
336 function cameraDeviceChanged() {