Warning, /plasma-mobile/plasma-camera/src/contents/ui/PreviewArea.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2020 Jonah BrĂ¼chert <jbb@kaidan.im>
0002 // SPDX-FileCopyrightText: 2020 Sebastian Pettke <sebpe@mailbox.org>
0003 //
0004 // SPDX-License-Identifier: GPL-3.0-or-later
0005
0006 import QtQuick 2.7
0007 import QtMultimedia 5.8
0008 import QtQuick.Controls.Material 2.0
0009 import QtQuick.Controls 2.0 as Controls
0010 import org.kde.kirigami 2.4 as Kirigami
0011 import QtGraphicalEffects 1.0
0012
0013
0014 Rectangle {
0015 id: preview
0016
0017 property var imageCapture
0018 property var videoRecorder
0019 property bool showVideoPreview: false // when set to true, the preview for the videoRecorder is shown, if false for the imageCapture
0020 property bool videoThumbnailRequested: false
0021
0022 visible: ((imageCapture.capturedImagePath && !showVideoPreview) || (videoRecorder.actualLocation && showVideoPreview)) && !(videoRecorder.recorderStatus === CameraRecorder.RecordingStatus)
0023 width: Kirigami.Units.gridUnit * 6
0024 height: width
0025 layer.enabled: preview.enabled
0026 layer.effect: DropShadow {
0027 color: Material.dropShadowColor
0028 samples: 30
0029 spread: 0.5
0030 }
0031
0032 Component.onCompleted: {
0033 videoRecorder.recorderStatusChanged.connect(createVideoThumbnail)
0034 }
0035
0036 function setPhotoPreview() {
0037 showVideoPreview = false
0038 }
0039
0040 function setVideoPreview() {
0041 videoThumbnailRequested = true
0042 showVideoPreview = true
0043 }
0044
0045 function createVideoThumbnail() {
0046 if (videoThumbnailRequested && !(videoRecorder.recorderStatus === CameraRecorder.FinalizingStatus)) {
0047 video.source = videoRecorder.actualLocation
0048 video.play()
0049 video.pause()
0050 videoThumbnailRequested = false
0051 }
0052 }
0053
0054 MouseArea {
0055 anchors.fill: parent
0056 onClicked: {
0057 if (showVideoPreview) {
0058 Qt.openUrlExternally(videoRecorder.actualLocation)
0059 }
0060 else {
0061 Qt.openUrlExternally("file://" + imageCapture.capturedImagePath)
0062 }
0063 }
0064 }
0065
0066 Image {
0067 visible: !showVideoPreview
0068 fillMode: Image.PreserveAspectCrop
0069 anchors.fill: parent
0070 source: imageCapture.capturedImagePath ? "file://" + imageCapture.capturedImagePath : ""
0071 }
0072
0073 Rectangle {
0074 visible: showVideoPreview
0075 anchors.fill: parent
0076 color: "grey"
0077
0078 Video {
0079 id: video
0080 anchors.fill: parent
0081 muted: true
0082 fillMode: VideoOutput.PreserveAspectCrop
0083 }
0084
0085 Controls.BusyIndicator {
0086 id: thumbnailBusyIdicator
0087 visible: (videoRecorder.recorderStatus === CameraRecorder.FinalizingStatus)
0088 Kirigami.Theme.textColor: "white"
0089 anchors.fill: parent
0090
0091 layer.enabled: thumbnailBusyIdicator.enabled
0092 layer.effect: DropShadow {
0093 color: Material.dropShadowColor
0094 samples: 30
0095 spread: 0.5
0096 }
0097 }
0098
0099 Kirigami.Icon {
0100 id: playbackIcon
0101 visible: !thumbnailBusyIdicator.visible
0102 source: "media-playback-start"
0103 color: "white"
0104 width: parent.width * 0.75
0105 height: width
0106 anchors.centerIn: parent
0107
0108 layer.enabled: playbackIcon.enabled
0109 layer.effect: DropShadow {
0110 color: Material.dropShadowColor
0111 samples: 30
0112 spread: 0.5
0113 }
0114 }
0115 }
0116 }