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

0001 // SPDX-FileCopyrightText: 2023 Mathis BrĂ¼chert <mbb@kaidan.im>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 
0006 import QtQuick 2.15
0007 import QtQuick.Controls 2.12 as Controls
0008 import QtQuick.Layouts 1.3
0009 import org.kde.kirigami 2.14 as Kirigami
0010 import org.kde.kirigami.delegates as KirigamiDelegates
0011 import org.kde.ytmusic 1.0
0012 
0013 import "components"
0014 
0015 Kirigami.ScrollablePage {
0016     id: root
0017     property alias playlistId: playlistModel.playlistId
0018     SongMenu {
0019         id:menu
0020         pageSpecificActions:[
0021             Kirigami.Action {
0022                 text: i18n("Remove from Playlist")
0023                 icon.name: "list-remove"
0024                 onTriggered:{
0025                     playlistModel.removeSong(menu.videoId, root.playlistId)
0026                 }
0027             }
0028         ]
0029     }
0030 
0031     DoubleActionButton {
0032         id: action
0033         visible: false
0034         property bool shown
0035         shown: !root.flickable.atYBeginning
0036         onShownChanged:
0037             if(shown){
0038                 visible = true
0039                 appear.running = true
0040             } else {
0041                 disappear.running = true
0042             }
0043 
0044         parent: overlay
0045         x: root.width - width - margin
0046         y: root.height - height - margin
0047         NumberAnimation on y {
0048             id: appear
0049             easing.type: Easing.InCubic
0050             running: false
0051             from: root.height
0052             to: root.height - action.height - action.margin
0053             duration: 100
0054         }
0055         NumberAnimation on y {
0056             id: disappear
0057             easing.type: Easing.OutCubic
0058             running: false
0059             from: root.height - action.height - action.margin
0060             to: root.height
0061             duration: 100
0062             onFinished: action.visible = false
0063         }
0064         rightAction: Kirigami.Action {
0065             icon.name: "media-playlist-shuffle"
0066             text: i18n("Shuffle")
0067             onTriggered: UserPlaylistModel.playLocalPlaylist(playlistModel, true)
0068         }
0069         leftAction: Kirigami.Action {
0070             icon.name: "media-playback-start"
0071             text: i18n("Play")
0072             onTriggered: UserPlaylistModel.playLocalPlaylist(playlistModel, false)
0073         }
0074 
0075     }
0076 
0077     ListView {
0078         footer: Item { height: 60 }
0079         Kirigami.PlaceholderMessage {
0080             text: i18n("This playlist is still empty")
0081             anchors.centerIn: parent
0082             visible: parent.count < 1
0083         }
0084 
0085         model: LocalPlaylistModel {
0086             id: playlistModel
0087         }
0088 
0089         header: RowLayout{
0090             spacing: Kirigami.Units.MediumSpacing
0091 
0092             Controls.ToolButton {
0093                 text: i18n("Play")
0094                 icon.name: "media-playback-start"
0095                 onClicked:  UserPlaylistModel.playLocalPlaylist(playlistModel, false)
0096 
0097             }
0098 
0099             Controls.ToolButton {
0100                 text: i18n("Shuffle")
0101                 icon.name: "shuffle"
0102                 onClicked: UserPlaylistModel.playLocalPlaylist(playlistModel, true)
0103 
0104             }
0105             Controls.ToolButton {
0106                 text: i18n("Append to queue")
0107                 icon.name: "media-playlist-append"
0108                 onClicked:  UserPlaylistModel.appendLocalPlaylist(playlistModel, false)
0109 
0110             }
0111             Item {
0112                 Layout.fillWidth: true
0113             }
0114         }
0115 
0116 
0117 
0118         delegate: Controls.ItemDelegate {
0119             id: delegateItem
0120 
0121             required property string title
0122             required property string videoId
0123             required property var artists
0124             required property string artistsDisplayString
0125             required property int index
0126 
0127             width: parent.width
0128 
0129             contentItem: MouseArea {
0130                 implicitHeight: content.implicitHeight
0131                 acceptedButtons: Qt.LeftButton | Qt.RightButton
0132                 onClicked: if (mouse.button === Qt.RightButton) {
0133                                menu.openForSong(delegateItem.videoId, delegateItem.title, delegateItem.artists, delegateItem.artistsDisplayString)
0134                           } else if (mouse.button === Qt.LeftButton) {
0135                                play(videoId)
0136                           }
0137                 RowLayout {
0138                     id: content
0139                     anchors.fill: parent
0140                     ThumbnailSource {
0141                         id: thumbnailSource
0142 
0143                         videoId: delegateItem.videoId
0144                     }
0145 
0146                     RoundedImage {
0147                         source: thumbnailSource.cachedPath
0148                         height: 35
0149                         width: height
0150                         radius: 5
0151                     }
0152                     ColumnLayout {
0153                         Controls.Label {
0154                             text: delegateItem.title
0155                             Layout.fillWidth: true
0156                             elide: Qt.ElideRight
0157 
0158                         }
0159                         Controls.Label {
0160                             Layout.fillWidth: true
0161                             color: Kirigami.Theme.disabledTextColor
0162                             text: delegateItem.artistsDisplayString
0163                             elide: Qt.ElideRight
0164 
0165                         }
0166                     }
0167                 }
0168             }
0169                 Controls.ToolButton {
0170                     icon.name: "overflow-menu"
0171                     text: i18n("More")
0172                     display: Controls.AbstractButton.IconOnly
0173                     onClicked: menu.openForSong(delegateItem.videoId, delegateItem.title, delegateItem.artists, delegateItem.artistsDisplayString)
0174                 }
0175         }
0176 
0177     }
0178 }