Warning, /multimedia/audiotube/src/contents/ui/LocalPlaylistsPage.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.Layouts 1.15 0008 import QtQuick.Controls 2.15 as Controls 0009 0010 import org.kde.kirigami 2.15 as Kirigami 0011 import org.kde.kirigami.delegates as KirigamiDelegates 0012 import org.kde.kirigamiaddons.components 1.0 as Components 0013 0014 import org.kde.ytmusic 1.0 0015 0016 import "dialogs" 0017 0018 Kirigami.ScrollablePage { 0019 id: root 0020 title: i18n("Playlists") 0021 Kirigami.Theme.colorSet: Kirigami.Theme.View 0022 0023 rightPadding: 0 0024 leftPadding: 15 0025 0026 RenamePlaylistDialog{ 0027 id: renamePlaylistDialog 0028 playlistsModel: localPlaylistsModel 0029 } 0030 Components.BottomDrawer{ 0031 id: drawer 0032 0033 parent: applicationWindow().overlay 0034 0035 property var modelData 0036 drawerContentItem: ColumnLayout { 0037 KirigamiDelegates.SubtitleDelegate{ 0038 text: i18n("Rename") 0039 icon.name: "edit-entry" 0040 onClicked: { 0041 renamePlaylistDialog.modelData = drawer.modelData 0042 renamePlaylistDialog.open() 0043 drawer.close() 0044 } 0045 } 0046 KirigamiDelegates.SubtitleDelegate{ 0047 text: i18n("Delete") 0048 icon.name: "delete" 0049 onClicked: { 0050 localPlaylistsModel.deletePlaylist(drawer.modelData.playlistId) 0051 drawer.close() 0052 } 0053 } 0054 } 0055 } 0056 Controls.Menu { 0057 id: menu 0058 property var modelData 0059 Controls.MenuItem { 0060 text: i18n("Rename") 0061 icon.name: "edit-entry" 0062 onTriggered:{ 0063 renamePlaylistDialog.modelData = menu.modelData 0064 renamePlaylistDialog.open() 0065 } 0066 } 0067 Controls.MenuItem { 0068 text: i18n("Delete") 0069 icon.name: "delete" 0070 onTriggered:{ 0071 localPlaylistsModel.deletePlaylist(menu.modelData.playlistId) 0072 } 0073 } 0074 } 0075 0076 GridView { 0077 id: grid 0078 header: RowLayout { 0079 width: parent.width 0080 spacing: Kirigami.Units.mediumSpacing 0081 readonly property bool isWidescreen: width >= Kirigami.Units.gridUnit * 25 0082 Kirigami.Heading { 0083 Layout.topMargin: 20 0084 text: i18n("Playlists") 0085 Layout.alignment: Qt.AlignLeft 0086 leftPadding: 15 0087 } 0088 AddPlaylistDialog { 0089 id: addPlaylistDialog 0090 model: localPlaylistsModel 0091 } 0092 ImportPlaylistDialog { 0093 id: importPlaylistDialog 0094 model: localPlaylistsModel 0095 } 0096 0097 // Spacer 0098 Item { 0099 visible: isWidescreen 0100 Layout.fillWidth: true 0101 } 0102 0103 // Widescreen layout 0104 Controls.ToolButton { 0105 visible: isWidescreen 0106 Layout.topMargin: 20 0107 text: i18n("New Playlist") 0108 Layout.alignment: Qt.AlignRight 0109 icon.name: "list-add" 0110 onClicked: addPlaylistDialog.open() 0111 } 0112 Controls.ToolButton { 0113 visible: isWidescreen 0114 Layout.topMargin: 20 0115 text: i18n("Import Playlist") 0116 Layout.alignment: Qt.AlignRight 0117 icon.name: "download" 0118 onClicked: importPlaylistDialog.open() 0119 } 0120 0121 // Compact layout 0122 Controls.ToolButton { 0123 visible: !isWidescreen 0124 Layout.fillHeight: true 0125 icon.name: "list-add" 0126 Layout.topMargin: 20 0127 Layout.alignment: Qt.AlignRight 0128 onPressed: Kirigami.Settings.isMobile? favDrawer.open() : favMenu.popup() 0129 0130 Controls.Menu { 0131 id: favMenu 0132 Controls.MenuItem { 0133 text: i18n("New Playlist") 0134 icon.name: "list-add" 0135 onTriggered: addPlaylistDialog.open() 0136 } 0137 Controls.MenuItem { 0138 text: i18n("Import Playlist") 0139 icon.name: "download" 0140 onTriggered: importPlaylistDialog.open() 0141 } 0142 } 0143 0144 Components.BottomDrawer { 0145 id: favDrawer 0146 0147 parent: applicationWindow().overlay 0148 0149 drawerContentItem: ColumnLayout { 0150 KirigamiDelegates.SubtitleDelegate{ 0151 text: i18n("New Playlist") 0152 icon.name: "list-add" 0153 onClicked: addPlaylistDialog.open() 0154 } 0155 KirigamiDelegates.SubtitleDelegate{ 0156 text: i18n("Import Playlist") 0157 icon.name: "download" 0158 onClicked: importPlaylistDialog.open() 0159 } 0160 Item{ 0161 Layout.fillHeight: true 0162 } 0163 } 0164 } 0165 } 0166 } 0167 0168 Layout.fillWidth: true 0169 Layout.fillHeight: true 0170 0171 model: LocalPlaylistsModel{ id: localPlaylistsModel } 0172 cellWidth: grid.width/(Math.floor(grid.width/230)) 0173 cellHeight: 280 0174 0175 delegate: ColumnLayout { 0176 id: playlistDelegate 0177 required property var model 0178 required property string playlistId 0179 required property string title 0180 required property string description 0181 required property date createdOn 0182 required property var thumbnailIds 0183 0184 width: grid.cellWidth 0185 0186 AlbumCoverItem { 0187 title: playlistDelegate.title 0188 subtitle: playlistDelegate.description 0189 showIcon: false 0190 0191 Layout.margins: 5 0192 Layout.alignment: Qt.AlignHCenter 0193 0194 onClicked: pageStack.push("qrc:/LocalPlaylistPage.qml", { 0195 "playlistId": playlistDelegate.playlistId, 0196 "title": playlistDelegate.title 0197 }) 0198 0199 onOptionsClicked: { 0200 menu.modelData = playlistDelegate.model 0201 drawer.modelData = playlistDelegate.model 0202 if (Kirigami.Settings.isMobile) { 0203 drawer.open() 0204 } else { 0205 menu.popup() 0206 } 0207 } 0208 0209 LocalPlaylistsModel{id:localPlaylistModel} 0210 0211 ThumbnailSource { 0212 id: thumbnailSource1 0213 videoId: thumbnailIds[0] 0214 } 0215 ThumbnailSource { 0216 id: thumbnailSource2 0217 videoId: thumbnailIds[1] ?? thumbnailIds[0] 0218 } 0219 ThumbnailSource { 0220 id: thumbnailSource3 0221 videoId: thumbnailIds[2] ?? thumbnailIds[0] 0222 } 0223 ThumbnailSource { 0224 id: thumbnailSource4 0225 videoId: thumbnailIds[3] ?? thumbnailIds[0] 0226 } 0227 contentItem: PlaylistCover { 0228 source1: thumbnailSource1.cachedPath 0229 source2: thumbnailSource2.cachedPath 0230 source3: thumbnailSource3.cachedPath 0231 source4: thumbnailSource4.cachedPath 0232 title: playlistDelegate.title 0233 height: 200 0234 width: height 0235 radius: 10 0236 } 0237 } 0238 } 0239 } 0240 } 0241 0242 0243