Warning, /multimedia/audiotube/src/contents/ui/PlaybackHistory.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2022 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.15 0007 import QtQuick.Controls 2.15 as Controls 0008 0009 import org.kde.kirigami 2.15 as Kirigami 0010 0011 import org.kde.ytmusic 1.0 0012 0013 import "components" 0014 0015 Kirigami.ScrollablePage { 0016 id: playbackHistoryPage 0017 title: i18n("Unknown list of songs") 0018 property QtObject dataModel: (objectName == "history") ? Library.playbackHistory : (objectName == "favourites" ? Library.favourites : null) 0019 0020 DoubleActionButton { 0021 id: action 0022 visible: false 0023 property bool shown 0024 shown: !playbackHistoryPage.flickable.atYBeginning 0025 onShownChanged: 0026 if(shown){ 0027 visible = true 0028 appear.running = true 0029 } else { 0030 disappear.running = true 0031 } 0032 0033 parent: overlay 0034 x: playbackHistoryPage.width - width - margin 0035 y: playbackHistoryPage.height - height - margin 0036 NumberAnimation on y { 0037 id: appear 0038 easing.type: Easing.InCubic 0039 running: false 0040 from: playbackHistoryPage.height 0041 to: playbackHistoryPage.height - action.height - action.margin 0042 duration: 100 0043 } 0044 NumberAnimation on y { 0045 id: disappear 0046 easing.type: Easing.OutCubic 0047 running: false 0048 from: playbackHistoryPage.height - action.height - action.margin 0049 to: playbackHistoryPage.height 0050 duration: 100 0051 onFinished: action.visible = false 0052 } 0053 rightAction: Kirigami.Action { 0054 icon.name: "media-playlist-shuffle" 0055 text: i18n("Shuffle") 0056 onTriggered: { 0057 if(playbackHistoryPage.objectName == "favourites") { 0058 UserPlaylistModel.playFavourites(Library.favourites, true) 0059 } 0060 else if(playbackHistoryPage.objectName == "history") { 0061 onClicked: UserPlaylistModel.playPlaybackHistory(playbackHistoryPage.dataModel, true) 0062 } 0063 } 0064 } 0065 leftAction: Kirigami.Action { 0066 icon.name: "media-playback-start" 0067 text: i18n("Play") 0068 onTriggered: { 0069 if(playbackHistoryPage.objectName == "favourites") { 0070 UserPlaylistModel.playFavourites(Library.favourites, false) 0071 } 0072 else if(playbackHistoryPage.objectName == "history") { 0073 onClicked: UserPlaylistModel.playPlaybackHistory(playbackHistoryPage.dataModel, false) 0074 } 0075 } 0076 } 0077 0078 } 0079 0080 SongMenu { 0081 id: menu 0082 } 0083 ListView { 0084 footer: Item { height: 60 } 0085 header: RowLayout { 0086 spacing: Kirigami.Units.mediumSpacing 0087 0088 Controls.ToolButton { 0089 text: i18n("Play") 0090 icon.name: "media-playback-start" 0091 onClicked: { 0092 if(playbackHistoryPage.objectName == "favourites") { 0093 UserPlaylistModel.playFavourites(Library.favourites, false) 0094 } 0095 else if(playbackHistoryPage.objectName == "history") { 0096 onClicked: UserPlaylistModel.playPlaybackHistory(playbackHistoryPage.dataModel, false) 0097 } 0098 } 0099 } 0100 0101 Controls.ToolButton { 0102 text: i18n("Shuffle") 0103 icon.name: "shuffle" 0104 onClicked: { 0105 if(playbackHistoryPage.objectName == "favourites") { 0106 UserPlaylistModel.playFavourites(Library.favourites, true) 0107 } 0108 else if(playbackHistoryPage.objectName == "history") { 0109 onClicked: UserPlaylistModel.playPlaybackHistory(playbackHistoryPage.dataModel, true) 0110 } 0111 } 0112 } 0113 Controls.ToolButton { 0114 text: i18n("Append to queue") 0115 icon.name: "media-playlist-append" 0116 onClicked: { 0117 if(playbackHistoryPage.objectName == "favourites") { 0118 UserPlaylistModel.appendFavourites(Library.favourites,false) 0119 } 0120 else if(playbackHistoryPage.objectName == "history") { 0121 UserPlaylistModel.appendPlaybackHistory(playbackHistoryPage.dataModel, false) 0122 } 0123 } 0124 } 0125 Item { 0126 Layout.fillWidth: true 0127 } 0128 } 0129 0130 id: listView 0131 reuseItems: true 0132 0133 Kirigami.PlaceholderMessage { 0134 visible: listView.count < 1 0135 text: i18n("No songs here yet") 0136 anchors.centerIn: parent 0137 } 0138 0139 model: playbackHistoryPage.dataModel 0140 0141 delegate: Controls.ItemDelegate { 0142 id: delegateItem 0143 0144 required property string title 0145 required property string videoId 0146 required property var artists 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: mouse => { 0156 if (mouse.button === Qt.RightButton) { 0157 menu.openForSong(delegateItem.videoId, delegateItem.title, delegateItem.artists, delegateItem.artistsDisplayString) 0158 } else if (mouse.button === Qt.LeftButton) { 0159 play(videoId) 0160 } 0161 } 0162 RowLayout { 0163 id: content 0164 anchors.fill: parent 0165 ThumbnailSource { 0166 id: thumbnailSource 0167 0168 videoId: delegateItem.videoId 0169 } 0170 0171 RoundedImage { 0172 source: thumbnailSource.cachedPath 0173 height: 35 0174 width: height 0175 radius: 5 0176 } 0177 ColumnLayout { 0178 Controls.Label { 0179 text: delegateItem.title 0180 Layout.fillWidth: true 0181 elide: Qt.ElideRight 0182 0183 } 0184 Controls.Label { 0185 Layout.fillWidth: true 0186 color: Kirigami.Theme.disabledTextColor 0187 text: delegateItem.artistsDisplayString 0188 elide: Qt.ElideRight 0189 0190 } 0191 } 0192 0193 Controls.ToolButton { 0194 icon.name: "overflow-menu" 0195 text: i18n("More") 0196 display: Controls.AbstractButton.IconOnly 0197 onClicked: menu.openForSong(delegateItem.videoId, delegateItem.title, delegateItem.artists, delegateItem.artistsDisplayString) 0198 } 0199 } 0200 } 0201 } 0202 } 0203 }