CameraPage {
id: page
+ policyMode: CameraResources.Video
+
controlsVisible: recording.visible && cam.running && !standbyWidget.visible
orientationLock: PageOrientation.LockLandscape
width: 75
height: 75
opacity: 0.5
+
onClicked: {
- if (!videoMode.recording) {
- if (!fileSystem.available) {
- showError(qsTr("Camera cannot record videos in mass storage mode."));
- }
- else if (!videoMode.startRecording(fileNaming.videoFileName())) {
- showError(qsTr("Failed to record video. Please restart the camera."));
- }
+ if (!fileSystem.available) {
+ showError(qsTr("Camera cannot record videos in mass storage mode."));
+ return;
}
- else {
+
+ // We only toggle the mode to video recording so
+ // policy can acquire the needed resources
+
+ if (policyMode == CameraResources.Video) {
+ policyMode = CameraResources.Recording;
+ }
+ else if (videoMode.recording) {
+ // We just ask to stop video.
videoMode.stopRecording();
}
}
+ Connections {
+ target: videoMode
+ onRecordingChanged: {
+ if (!videoMode.recording) {
+ policyMode = CameraResources.Video;
+ }
+ }
+ }
+
+ Connections {
+ target: resourcePolicy
+ onAcquiredChanged: {
+ if (resourcePolicy.acquired && policyMode == CameraResources.Recording) {
+ if (!videoMode.startRecording(fileNaming.videoFileName())) {
+ showError(qsTr("Failed to record video. Please restart the camera."));
+ policyMode = CameraResources.Video
+}
+ }
+ }
+ }
+
visible: (videoMode.recording || videoMode.canCapture) && !cameraMode.animationRunning && !previewAnimationRunning && !standbyWidget.visible
}