Warning, /multimedia/plasmatube/src/ui/videoplayer/PictureInPictureVideo.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com> 0002 // SPDX-License-Identifier: GPL-3.0-or-later 0003 0004 import QtQuick 0005 import QtQuick.Controls as QQC2 0006 import Qt5Compat.GraphicalEffects 0007 0008 import org.kde.kirigami as Kirigami 0009 0010 import org.kde.plasmatube 0011 0012 Kirigami.ApplicationWindow { 0013 id: root 0014 0015 title: i18n("Picture in Picture") 0016 0017 flags: Qt.Window | Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint 0018 0019 minimumWidth: 320 0020 minimumHeight: 240 0021 0022 property alias renderer: renderer 0023 readonly property var video: PlasmaTube.videoController.currentVideo 0024 0025 MouseArea { 0026 id: videoContainer 0027 anchors.fill: parent 0028 0029 Kirigami.Theme.colorSet: Kirigami.Theme.Complementary 0030 Kirigami.Theme.inherit: false 0031 0032 property bool showControls: false 0033 onClicked: { 0034 if (showControls) { 0035 controlTimer.stop(); 0036 videoContainer.showControls = false; 0037 } else { 0038 showControls = true; 0039 controlTimer.restart(); 0040 } 0041 } 0042 0043 hoverEnabled: !Kirigami.Settings.tabletMode 0044 onContainsMouseChanged: { 0045 if (!pressed && hoverEnabled) { 0046 videoContainer.showControls = containsMouse; 0047 } 0048 } 0049 0050 Timer { 0051 id: controlTimer 0052 interval: 2000 0053 onTriggered: videoContainer.showControls = false 0054 } 0055 0056 MpvObject { 0057 id: renderer 0058 anchors.fill: parent 0059 0060 visible: !stopped 0061 } 0062 Rectangle { 0063 anchors.fill: renderer 0064 0065 color: "black" 0066 visible: renderer.stopped 0067 0068 Image { 0069 id: thumbnailImage 0070 0071 anchors.fill: parent 0072 source: video.thumbnailUrl("high") 0073 } 0074 0075 QQC2.BusyIndicator { 0076 anchors.centerIn: parent 0077 } 0078 } 0079 0080 VideoData { 0081 title: video.title 0082 visible: opacity > 0 0083 opacity: videoContainer.showControls ? 1 : 0 0084 Behavior on opacity { 0085 NumberAnimation { 0086 duration: Kirigami.Units.veryLongDuration; easing.type: Easing.InOutCubic 0087 } 0088 } 0089 } 0090 0091 VideoControls { 0092 inFullScreen: false 0093 anchors.fill: parent 0094 showPresentationControls: false 0095 0096 visible: opacity > 0 0097 opacity: videoContainer.showControls ? 1 : 0 0098 Behavior on opacity { 0099 NumberAnimation { 0100 duration: Kirigami.Units.veryLongDuration; easing.type: Easing.InOutCubic 0101 } 0102 } 0103 0104 QQC2.ToolButton { 0105 anchors { 0106 top: parent.top 0107 right: parent.right 0108 } 0109 0110 display: QQC2.AbstractButton.IconOnly 0111 0112 icon.name: "window-close-symbolic" 0113 icon.color: "white" 0114 0115 onClicked: root.close() 0116 } 0117 0118 QQC2.ToolButton { 0119 id: resizeHandler 0120 0121 anchors { 0122 bottom: parent.bottom 0123 right: parent.right 0124 } 0125 0126 display: QQC2.AbstractButton.IconOnly 0127 0128 icon.name: "drag-surface" 0129 0130 hoverEnabled: true 0131 } 0132 } 0133 } 0134 0135 DragHandler { 0136 grabPermissions: PointerHandler.CanTakeOverFromItems | PointerHandler.CanTakeOverFromHandlersOfDifferentType | PointerHandler.ApprovesTakeOverByAnything 0137 onActiveChanged: { 0138 if (active) { 0139 if (resizeHandler.hovered) { 0140 root.startSystemResize(Qt.RightEdge | Qt.BottomEdge); 0141 } else { 0142 root.startSystemMove(); 0143 } 0144 } 0145 } 0146 target: null 0147 } 0148 }