Warning, /multimedia/audiotube/src/contents/ui/PlaylistPage.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2021 Jonah BrĂ¼chert <jbb@kaidan.im>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 import QtQuick 2.15
0006 import QtQuick.Layouts 1.12
0007 import QtQuick.Controls 2.12 as Controls
0008 import org.kde.kirigami 2.12 as Kirigami
0009 
0010 import org.kde.ytmusic 1.0
0011 
0012 import "components"
0013 
0014 Kirigami.ScrollablePage {
0015     id: root
0016 
0017     required property string playlistId
0018 
0019     title: playlistModel.title
0020 
0021     SongMenu {
0022         id: menu
0023     }
0024     DoubleActionButton {
0025         id: action
0026         visible: false
0027         property bool shown
0028         shown: !root.flickable.atYBeginning
0029         onShownChanged:
0030             if(shown){
0031                 visible = true
0032                 appear.running = true
0033             } else {
0034                 disappear.running = true
0035             }
0036 
0037         parent: overlay
0038         x: root.width - width - margin
0039         y: root.height - height - margin
0040         NumberAnimation on y {
0041             id: appear
0042             easing.type: Easing.InCubic
0043             running: false
0044             from: root.height
0045             to: root.height - action.height - action.margin
0046             duration: 100
0047         }
0048         NumberAnimation on y {
0049             id: disappear
0050             easing.type: Easing.OutCubic
0051             running: false
0052             from: root.height - action.height - action.margin
0053             to: root.height
0054             duration: 100
0055             onFinished: action.visible = false
0056         }
0057         rightAction: Kirigami.Action {
0058             icon.name: "media-playlist-shuffle"
0059             text: i18n("Shuffle")
0060             onTriggered: {
0061                 applicationWindow().playShufflePlaylist(playlistModel.playlistId)
0062             }
0063         }
0064         leftAction: Kirigami.Action {
0065             icon.name: "media-playback-start"
0066             text: i18n("Play")
0067             onTriggered: {
0068                 applicationWindow().playPlaylist(playlistModel.playlistId)
0069             }
0070         }
0071     }
0072 
0073     PlaylistImporter {
0074         id: localPlaylistsModel
0075         onImportFinished: {
0076             applicationWindow().showPassiveNotification(i18n("Playlist successfully imported"))
0077         }
0078     }
0079 
0080     ListView {
0081         id: songList
0082         footer: Item { height: 60 }
0083         header: ListHeader {
0084             visibleActions: [
0085                 Kirigami.Action {
0086                     icon.name: "media-playback-start"
0087                     text: i18n("Play")
0088                     onTriggered: {
0089                         applicationWindow().playPlaylist(playlistModel.playlistId)
0090                     }
0091                 },
0092                 Kirigami.Action {
0093                     icon.name: "media-playlist-shuffle"
0094                     text: i18n("Shuffle")
0095                     onTriggered: {
0096                         applicationWindow().playShufflePlaylist(playlistModel.playlistId)
0097                     }
0098                 }
0099             ]
0100             overflowActions: [
0101                 Kirigami.Action {
0102                     text: i18n("Append to queue")
0103                     icon.name: "media-playlist-append"
0104                     onTriggered: UserPlaylistModel.appendPlaylist(playlistModel)
0105                 },
0106                 Kirigami.Action {
0107                     text: i18n("Import Playlist")
0108                     icon.name: "document-save"
0109                     onTriggered: localPlaylistsModel.importPlaylist(playlistModel.webUrl)
0110                 },
0111                 Kirigami.Action {
0112                     text: i18n("Open in Browser")
0113                     icon.name: "internet-services"
0114                     onTriggered: Qt.openUrlExternally(playlistModel.webUrl)
0115                 },
0116                 Kirigami.Action {
0117                     text: i18n("Share")
0118                     icon.name: "emblem-shared-symbolic"
0119                     onTriggered:{
0120                         openShareMenu(playlistModel.title, playlistModel.webUrl)
0121                     }
0122                 }
0123 
0124             ]
0125             title: playlistModel.title
0126             imageSourceURL: playlistModel.thumbnailUrl
0127             width: songList.width
0128             subtitle: i18n("Playlist")
0129 
0130         }
0131 
0132         model: PlaylistModel {
0133             id: playlistModel
0134 
0135             playlistId: root.playlistId
0136         }
0137 
0138         reuseItems: true
0139 
0140         delegate: Controls.ItemDelegate {
0141             id: delegateItem
0142 
0143             required property string title
0144             required property string videoId
0145             required property var artists
0146             required property string thumbnailUrl
0147             required property string artistsDisplayString
0148             required property int index
0149 
0150             width: parent.width
0151 
0152             contentItem: MouseArea {
0153                 implicitHeight: content.implicitHeight
0154                 acceptedButtons: Qt.LeftButton | Qt.RightButton
0155                 onClicked: if (mouse.button === Qt.RightButton) {
0156                                menu.openForSong(delegateItem.videoId, delegateItem.title, delegateItem.artists, delegateItem.artistsDisplayString)
0157                            } else if (mouse.button === Qt.LeftButton) {
0158                                play(videoId)
0159                           }
0160                 RowLayout {
0161                     id: content
0162                     anchors.fill: parent
0163 
0164                     RoundedImage {
0165                         source: delegateItem.thumbnailUrl
0166                         height: 35
0167                         width: height
0168                         radius: 5
0169                     }
0170 
0171                     ColumnLayout {
0172                         Controls.Label {
0173                             Layout.fillWidth: true
0174                             text: title
0175                             elide: Qt.ElideRight
0176                         }
0177 
0178                         Controls.Label {
0179                             Layout.fillWidth: true
0180                             visible: delegateItem.artistsDisplayString
0181                             color: Kirigami.Theme.disabledTextColor
0182                             text: delegateItem.artistsDisplayString
0183                             elide: Qt.ElideRight
0184                         }
0185                     }
0186 
0187                     Controls.ToolButton {
0188                         icon.name: "overflow-menu"
0189                         text: i18n("More")
0190                         display: Controls.AbstractButton.IconOnly
0191                         onClicked: menu.openForSong(delegateItem.videoId, delegateItem.title, delegateItem.artists, delegateItem.artistsDisplayString)
0192                     }
0193                 }
0194             }
0195         }
0196 
0197         Controls.BusyIndicator {
0198             anchors.centerIn: parent
0199             visible: playlistModel.loading
0200         }
0201     }
0202 }