Warning, /multimedia/audiotube/src/contents/ui/ArtistPage.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 org.kde.kirigami 2.14 as Kirigami
0007 import QtQuick.Controls 2.14 as Controls
0008 import QtQuick.Layouts 1.3
0009 
0010 import "components"
0011 
0012 import org.kde.ytmusic 1.0
0013 
0014 Kirigami.ScrollablePage {
0015     id: root
0016     property string channelId
0017     property string radioId
0018     property string shuffleId
0019     title: artistModel.title
0020 
0021     SongMenu {
0022         id: menu
0023     }
0024 
0025     DoubleActionButton {
0026         id: action
0027         visible: false
0028         property bool shown
0029         shown: !root.flickable.atYBeginning
0030         onShownChanged:
0031             if(shown){
0032                 visible = true
0033                 appear.running = true
0034             } else {
0035                 disappear.running = true
0036             }
0037 
0038         parent: overlay
0039         x: root.width - width - margin
0040         y: root.height - height - margin
0041         NumberAnimation on y {
0042             id: appear
0043             easing.type: Easing.InCubic
0044             running: false
0045             from: root.height
0046             to: root.height - action.height - action.margin
0047             duration: 100
0048         }
0049         NumberAnimation on y {
0050             id: disappear
0051             easing.type: Easing.OutCubic
0052             running: false
0053             from: root.height - action.height - action.margin
0054             to: root.height
0055             duration: 100
0056             onFinished: action.visible = false
0057         }
0058         rightAction: Kirigami.Action {
0059             icon.name: "media-playlist-shuffle"
0060             onTriggered: playPlaylist(shuffleId)
0061             text: "Shuffle"
0062         }
0063         leftAction: Kirigami.Action {
0064             icon.name: "radio"
0065             onTriggered: playPlaylist(radioId)
0066             text: "Radio"
0067         }
0068 
0069     }
0070 
0071     ListView {
0072         id: songList
0073         footer: Item { height: 60 }
0074         header: ListHeader {
0075             visibleActions: [
0076                 Kirigami.Action {
0077                     text: i18n("Radio")
0078                     icon.name: "radio"
0079                     onTriggered: playPlaylist(radioId)
0080                     visible: radioId
0081                 },
0082                 Kirigami.Action {
0083                     text: i18n("Shuffle")
0084                     icon.name: "media-playlist-shuffle"
0085                     onTriggered: playPlaylist(shuffleId)
0086                     visible: shuffleId
0087                 }
0088             ]
0089             overflowActions: [
0090                 Kirigami.Action {
0091                     text: i18n("Open in Browser")
0092                     icon.name: "internet-services"
0093                     onTriggered: Qt.openUrlExternally(artistModel.webUrl)
0094                 },
0095                 Kirigami.Action {
0096                     text: i18n("Share")
0097                     icon.name: "emblem-shared-symbolic"
0098                     onTriggered: {
0099                         openShareMenu(artistModel.title, artistModel.webUrl)
0100                     }
0101                 }
0102             ]
0103             title: artistModel.title
0104             imageSourceURL: artistModel.thumbnailUrl
0105             subtitle: i18n("Artist")
0106             rounded: true
0107             width: songList.width
0108 
0109         }
0110 
0111         reuseItems: true
0112 
0113         model: ArtistModel {
0114             id: artistModel
0115 
0116             channelId: root.channelId
0117 
0118             onOpenAlbum: (browseId) => {
0119                 pageStack.push("qrc:/AlbumPage.qml", {
0120                     "browseId": browseId
0121                 })
0122             }
0123 
0124             onOpenSong: (videoId) => {
0125                 play(videoId)
0126             }
0127 
0128             onOpenVideo: (videoId, title) => {
0129                 videoPlayMessage.text = i18n("Video playback is not supported yet. Do you want to play only the audio of \"%1\"?", title)
0130                 videoPlayMessage.visible = true
0131                 videoPlayMessage.okAction = () => {
0132                     play(videoId)
0133                     videoPlayMessage.visible = false
0134                 }
0135                 videoPlayMessage.cancelAction = () => {
0136                     videoPlayMessage.visible = false
0137                 }
0138             }
0139         }
0140 
0141         section.property: "type"
0142         section.delegate: Kirigami.ListSectionHeader {
0143             width: parent.width
0144 
0145             text: {
0146                 switch(parseInt(section)) {
0147                 case ArtistModel.Album:
0148                     return i18n("Albums")
0149                 case ArtistModel.Single:
0150                     return i18n("Singles")
0151                 case ArtistModel.Song:
0152                     return i18n("Songs")
0153                 case ArtistModel.Video:
0154                     return i18n("Videos")
0155                 }
0156             }
0157         }
0158 
0159         delegate: Controls.ItemDelegate {
0160             id: delegateItem
0161 
0162             required property string title
0163             required property int type
0164             required property int index
0165             required property var artists
0166             required property string videoId
0167             required property string thumbnailUrl
0168 
0169             width: parent.width
0170 
0171             contentItem: MouseArea {
0172                 implicitHeight: content.implicitHeight
0173                 acceptedButtons: Qt.LeftButton | Qt.RightButton
0174                 onClicked: (mouse) => {
0175                     if (mouse.button === Qt.RightButton) {
0176                        if (type === ArtistModel.Song) {
0177                            menu.openForSong(delegateItem.videoId, delegateItem.title, delegateItem.artists, artistModel.title)
0178                         }
0179                    } else if (mouse.button === Qt.LeftButton) {
0180                         artistModel.triggerItem(index)
0181                    }
0182                 }
0183                 RowLayout {
0184                     id: content
0185                     anchors.fill: parent
0186                     RoundedImage {
0187                         source: delegateItem.thumbnailUrl
0188                         height: 35
0189                         width: height
0190                         radius: 5
0191                     }
0192 
0193                     Controls.Label {
0194                         Layout.fillWidth: true
0195                         text: delegateItem.title
0196                         elide: Qt.ElideRight
0197                     }
0198 
0199                     Controls.ToolButton {
0200                         icon.name: "overflow-menu"
0201                         text: i18n("More")
0202                         display: Controls.AbstractButton.IconOnly
0203                         visible: type === ArtistModel.Song
0204                         onClicked: menu.openForSong(delegateItem.videoId, delegateItem.title, delegateItem.artists, artistModel.title)
0205                     }
0206                 }
0207             }
0208         }
0209 
0210         Controls.BusyIndicator {
0211             anchors.centerIn: parent
0212             visible: artistModel.loading
0213         }
0214     }
0215 
0216     footer: ConfirmationMessage {
0217         id: videoPlayMessage
0218     }
0219 }