Warning, /plasma/plank-player/app/qml/PlayerOSD.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2021 Aditya Mehra <aix.m@outlook.com>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 import QtQuick 2.15
0006 import QtQuick.Layouts 1.15
0007 import org.kde.kirigami 2.15 as Kirigami
0008 import QtQuick.Controls 2.15 as Controls
0009 import QtMultimedia
0010 
0011 Item {
0012     id: osdControlsArea
0013     anchors.left: parent.left
0014     anchors.right: parent.right
0015     property bool opened: false
0016     property bool menuOpened
0017     property var videoItem
0018     property bool pinned: false
0019 
0020     onOpenedChanged: {
0021         if(opened){
0022             menuButton.forceActiveFocus()
0023             hideTimer.restart()
0024         }
0025     }
0026 
0027     Timer {
0028         id: hideTimer
0029         interval: 5000
0030         onTriggered: {
0031             if(!osdControlsArea.pinned){
0032                 osdControlsArea.opened = false;
0033                 if(!menuOpened){
0034                     videoItem.forceActiveFocus();
0035                 }
0036             }
0037         }
0038     }
0039 
0040     Rectangle {
0041         width: parent.width
0042         height: parent.height
0043         color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.6)
0044         y: opened ? 0 : parent.height
0045 
0046         Behavior on y {
0047             YAnimator {
0048                 duration: Kirigami.Units.longDuration
0049                 easing.type: Easing.OutCubic
0050             }
0051         }
0052 
0053         RowLayout {
0054             id: mainOSDLayout
0055             anchors.fill: parent
0056             anchors.margins: Kirigami.Units.largeSpacing
0057 
0058             OSDButton {
0059                 id: menuButton
0060                 Layout.maximumWidth: Kirigami.Units.iconSizes.large
0061                 Layout.preferredHeight: Kirigami.Units.iconSizes.large
0062                 iconSource: "menu_new"
0063                 KeyNavigation.right: playPauseButton
0064 
0065                 onClicked: (mouse)=> {
0066                     mainMenu.open()
0067                 }
0068             }
0069 
0070             OSDButton {
0071                 id: playPauseButton
0072                 Layout.maximumWidth: Kirigami.Units.iconSizes.large
0073                 Layout.preferredHeight: Kirigami.Units.iconSizes.large
0074                 iconSource: videoItem.playbackState === MediaPlayer.PlayingState ? "media-playback-pause"  : "media-playback-start"
0075                 KeyNavigation.right: mediaSkipBckButton
0076                 KeyNavigation.left: menuButton
0077 
0078                 onClicked: (mouse)=> {
0079                     videoItem.playbackState === MediaPlayer.PlayingState ? videoItem.pause() : videoItem.play()
0080                 }
0081             }
0082 
0083             OSDButton {
0084                 id: mediaSkipBckButton
0085                 Layout.maximumWidth: Kirigami.Units.iconSizes.large
0086                 Layout.preferredHeight: Kirigami.Units.iconSizes.large
0087                 iconSource: "media-seek-backward"
0088                 KeyNavigation.right: mediaSkipFwdButton
0089                 KeyNavigation.left: playPauseButton
0090 
0091                 onClicked: (mouse)=> {
0092                     videoItem.seek(videoItem.position - 5000)
0093                 }
0094             }
0095 
0096             OSDButton {
0097                 id: mediaSkipFwdButton
0098                 Layout.maximumWidth: Kirigami.Units.iconSizes.large
0099                 Layout.preferredHeight: Kirigami.Units.iconSizes.large
0100                 iconSource: "media-seek-forward"
0101                 KeyNavigation.right: osdSeekBar
0102                 KeyNavigation.left: mediaSkipBckButton
0103 
0104                 onClicked: (mouse)=> {
0105                     videoItem.seek(videoItem.position + 5000)
0106                 }
0107             }
0108 
0109             SeekBar {
0110                 id: osdSeekBar
0111                 Layout.fillWidth: true
0112                 Layout.fillHeight: true
0113                 KeyNavigation.right: pinOsdButton
0114                 KeyNavigation.left: mediaSkipFwdButton
0115                 duration: videoItem.duration
0116                 value: videoItem.position
0117             }
0118 
0119             OSDButton {
0120                 id: pinOsdButton
0121                 Layout.maximumWidth: Kirigami.Units.iconSizes.large
0122                 Layout.preferredHeight: Kirigami.Units.iconSizes.large
0123                 iconSource: "unlock"
0124                 KeyNavigation.right: fitVidOsdButton
0125                 KeyNavigation.left: osdSeekBar
0126 
0127                 onClicked: (mouse)=> {
0128                     console.log(osdControlsArea.pinned)
0129                     if(!osdControlsArea.pinned){
0130                         pinOsdButton.iconSource = "lock"
0131                         osdControlsArea.pinned = true
0132                     } else {
0133                         pinOsdButton.iconSource = "unlock"
0134                         osdControlsArea.pinned = false
0135                     }
0136                 }
0137             }
0138 
0139             OSDButton {
0140                 id: fitVidOsdButton
0141                 Layout.maximumWidth: Kirigami.Units.iconSizes.large
0142                 Layout.preferredHeight: Kirigami.Units.iconSizes.large
0143                 iconSource: "zoom-fit-best"
0144                 checkable: true
0145                 KeyNavigation.right: exitPlayerButton
0146                 KeyNavigation.left: pinOsdButton
0147 
0148                 onClicked: (mouse)=> {
0149                     if(videoItem.fillMode == VideoOutput.PreserveAspectFit){
0150                         videoItem.fillMode = VideoOutput.Stretch
0151                     } else {
0152                         videoItem.fillMode = VideoOutput.PreserveAspectFit
0153                     }
0154                 }
0155             }
0156 
0157             OSDButton {
0158                 id: exitPlayerButton
0159                 Layout.maximumWidth: Kirigami.Units.iconSizes.large
0160                 Layout.preferredHeight: Kirigami.Units.iconSizes.large
0161                 iconSource: "window-close"
0162                 KeyNavigation.left: fitVidOsdButton
0163 
0164                 onClicked: (mouse)=> {
0165                     window.close()
0166                 }
0167             }
0168         }
0169     }
0170 }