Warning, /multimedia/audiotube/src/contents/ui/LibraryPage.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.Window 2.15 0007 import QtQuick.Controls 2.12 as Controls 0008 import QtQuick.Layouts 1.3 0009 import org.kde.kirigami 2.19 as Kirigami 0010 import org.kde.kirigami.delegates as KirigamiDelegates 0011 import org.kde.kirigamiaddons.components 1.0 as Components 0012 0013 import org.kde.ytmusic 1.0 0014 import "dialogs" 0015 0016 Kirigami.ScrollablePage { 0017 objectName: "libraryPage" 0018 Kirigami.Theme.colorSet: Kirigami.Theme.View 0019 title: "AudioTube" 0020 readonly property bool isWidescreen: width >= Kirigami.Units.gridUnit * 30 0021 0022 rightPadding: 0 0023 leftPadding: 0 0024 0025 SongMenu { 0026 id: menu 0027 } 0028 ColumnLayout { 0029 RowLayout { 0030 Layout.fillWidth: true 0031 Kirigami.Heading { 0032 text: i18n("Favourites") 0033 Layout.alignment: Qt.AlignLeft 0034 leftPadding: 15 0035 } 0036 0037 Controls.ToolButton { 0038 visible: isWidescreen 0039 text: i18n("Play") 0040 icon.name: "media-playback-start" 0041 onClicked: UserPlaylistModel.playFavourites(Library.favourites, false) 0042 } 0043 0044 Controls.ToolButton { 0045 visible: isWidescreen 0046 text: i18n("Shuffle") 0047 icon.name: "shuffle" 0048 onClicked: UserPlaylistModel.playFavourites(Library.favourites, true) 0049 } 0050 0051 // Spacer 0052 Item { 0053 visible: !isWidescreen 0054 Layout.fillWidth: true 0055 } 0056 0057 Controls.ToolButton { 0058 Layout.fillHeight: true 0059 icon.name: "view-more-symbolic" 0060 onPressed: Kirigami.Settings.isMobile? favDrawer.open() : favMenu.popup() 0061 Controls.Menu { 0062 id: favMenu 0063 Controls.MenuItem { 0064 visible: !isWidescreen 0065 text: i18n("Play") 0066 icon.name: "media-playback-start" 0067 onTriggered: UserPlaylistModel.playFavourites(Library.favourites, false) 0068 } 0069 Controls.MenuItem { 0070 visible: !isWidescreen 0071 text: i18n("Shuffle") 0072 icon.name: "shuffle" 0073 onTriggered: UserPlaylistModel.playFavourites(Library.favourites, true) 0074 } 0075 Controls.MenuItem { 0076 text: i18n("Append to queue") 0077 icon.name: "media-playlist-append" 0078 onTriggered: UserPlaylistModel.appendFavourites(Library.favourites,false) 0079 } 0080 } 0081 0082 Components.BottomDrawer { 0083 id: favDrawer 0084 0085 parent: applicationWindow().overlay 0086 0087 drawerContentItem: ColumnLayout { 0088 KirigamiDelegates.SubtitleDelegate { 0089 Layout.fillWidth: true 0090 0091 text: i18n("Play") 0092 icon.name: "media-playback-start" 0093 onClicked: { 0094 UserPlaylistModel.playFavourites(Library.favourites, false) 0095 favDrawer.close() 0096 } 0097 } 0098 KirigamiDelegates.SubtitleDelegate { 0099 Layout.fillWidth: true 0100 0101 text: i18n("Shuffle") 0102 icon.name: "shuffle" 0103 onClicked: { 0104 UserPlaylistModel.playFavourites(Library.favourites, true) 0105 favDrawer.close() 0106 } 0107 } 0108 KirigamiDelegates.SubtitleDelegate { 0109 Layout.fillWidth: true 0110 0111 text: i18n("Append to queue") 0112 icon.name: "media-playlist-append" 0113 onClicked: { 0114 UserPlaylistModel.appendFavourites(Library.favourites,false) 0115 favDrawer.close() 0116 } 0117 } 0118 Item { 0119 Layout.fillHeight: true 0120 } 0121 } 0122 } 0123 0124 } 0125 Item { 0126 visible: isWidescreen 0127 Layout.fillWidth: true 0128 } 0129 Controls.ToolButton { 0130 text: i18n("Show All") 0131 Layout.alignment: Qt.AlignRight 0132 icon.name: "arrow-right" 0133 onClicked: { 0134 pageStack.push(pool.loadPageWithProperties("qrc:/PlaybackHistory.qml#favourites", { 0135 "title": i18n("Favourites"), 0136 "objectName": "favourites" 0137 })) 0138 } 0139 } 0140 } 0141 0142 Kirigami.Icon { 0143 id: favouritesPlaceholder 0144 0145 visible: favouriteRepeater.count === 0 0146 Layout.margins: 20 0147 isMask: true 0148 opacity:0.4 0149 color: Kirigami.Theme.hoverColor 0150 Layout.alignment: Qt.AlignHCenter 0151 Layout.fillWidth: true 0152 implicitWidth: 190 0153 implicitHeight: 190 0154 0155 source: "qrc:/resources/favourites_placeholder.svg" 0156 0157 Controls.Label { 0158 visible: favouriteRepeater.count === 0 0159 color: Kirigami.Theme.disabledTextColor 0160 text: i18n("No Favourites Yet") 0161 0162 font { 0163 bold: true 0164 pointSize: 15 0165 } 0166 0167 anchors.centerIn: favouritesPlaceholder 0168 } 0169 } 0170 0171 HorizontalCoverView { 0172 id: favouriteRepeater 0173 0174 Layout.fillWidth: true 0175 0176 model: Library.favourites 0177 delegate: ColumnLayout { 0178 id: delegateItem 0179 required property string title 0180 required property var artists 0181 required property string artistsDisplayString 0182 required property string videoId 0183 required property int index 0184 0185 Layout.fillWidth: false 0186 Layout.maximumWidth: 200 0187 0188 ThumbnailSource { 0189 id: thumbnailSource 0190 videoId: delegateItem.videoId 0191 } 0192 0193 AlbumCoverItem { 0194 Layout.fillWidth: true 0195 Layout.fillHeight: true 0196 0197 onClicked: play(delegateItem.videoId) 0198 onOptionsClicked: menu.openForSong(delegateItem.videoId, 0199 delegateItem.title, 0200 delegateItem.artists, 0201 delegateItem.artistsDisplayString) 0202 0203 title: delegateItem.title 0204 subtitle: delegateItem.artistsDisplayString 0205 0206 contentItem: RoundedImage { 0207 source: thumbnailSource.cachedPath 0208 anchors.fill: parent 0209 radius: 10 0210 } 0211 } 0212 0213 Item { 0214 height: 5 0215 } 0216 } 0217 } 0218 Item { 0219 height: 20 0220 } 0221 0222 RowLayout { 0223 Layout.fillWidth: true 0224 0225 Kirigami.Heading { 0226 text: i18n("Most played") 0227 Layout.alignment: Qt.AlignLeft 0228 leftPadding: 15 0229 } 0230 0231 Controls.ToolButton { 0232 visible: isWidescreen 0233 text: i18n("Play") 0234 icon.name: "media-playback-start" 0235 onClicked: UserPlaylistModel.playPlaybackHistory(Library.mostPlayed, false) 0236 } 0237 0238 Controls.ToolButton { 0239 visible: isWidescreen 0240 text: i18n("Shuffle") 0241 icon.name: "shuffle" 0242 onClicked: UserPlaylistModel.playPlaybackHistory(Library.mostPlayed, true) 0243 } 0244 0245 // Spacer 0246 Item { 0247 visible: !isWidescreen 0248 Layout.fillWidth: true 0249 } 0250 0251 Controls.ToolButton { 0252 Layout.fillHeight: true 0253 icon.name: "view-more-symbolic" 0254 onPressed: Kirigami.Settings.isMobile? recDrawer.open() : recMenu.popup() 0255 Controls.Menu { 0256 id: recMenu 0257 Controls.MenuItem { 0258 visible: !isWidescreen 0259 text: i18n("Play") 0260 icon.name: "media-playback-start" 0261 onTriggered: UserPlaylistModel.playPlaybackHistory(Library.mostPlayed, false) 0262 } 0263 Controls.MenuItem { 0264 visible: !isWidescreen 0265 text: i18n("Shuffle") 0266 icon.name: "shuffle" 0267 onTriggered: UserPlaylistModel.playPlaybackHistory(Library.mostPlayed, true) 0268 } 0269 Controls.MenuItem { 0270 text: i18n("Append to queue") 0271 icon.name: "media-playlist-append" 0272 onTriggered: UserPlaylistModel.appendPlaybackHistory(Library.mostPlayed, false) 0273 } 0274 } 0275 0276 Components.BottomDrawer{ 0277 id: recDrawer 0278 0279 parent: applicationWindow().overlay 0280 0281 drawerContentItem: ColumnLayout { 0282 KirigamiDelegates.SubtitleDelegate{ 0283 text: i18n("Play") 0284 icon.name: "media-playback-start" 0285 onClicked: { 0286 UserPlaylistModel.playPlaybackHistory(Library.mostPlayed, false) 0287 recDrawer.close() 0288 } 0289 0290 } 0291 KirigamiDelegates.SubtitleDelegate{ 0292 text: i18n("Shuffle") 0293 icon.name: "shuffle" 0294 onClicked: { 0295 UserPlaylistModel.playPlaybackHistory(Library.mostPlayed, true) 0296 recDrawer.close() 0297 } 0298 } 0299 KirigamiDelegates.SubtitleDelegate{ 0300 text: i18n("Append to queue") 0301 icon.name: "media-playlist-append" 0302 onClicked: { 0303 UserPlaylistModel.appendPlaybackHistory(Library.mostPlayed, false) 0304 recDrawer.close() 0305 } 0306 } 0307 Item{ 0308 Layout.fillHeight: true 0309 } 0310 0311 } 0312 } 0313 0314 } 0315 Item { 0316 visible: isWidescreen 0317 Layout.fillWidth: true 0318 } 0319 Controls.ToolButton { 0320 text: i18n("Show All") 0321 Layout.alignment: Qt.AlignRight 0322 icon.name: "arrow-right" 0323 onClicked: { 0324 pageStack.push(pool.loadPageWithProperties("qrc:/PlaybackHistory.qml#history", { 0325 "title": i18n("Played Songs"), 0326 "objectName": "history" 0327 })) 0328 } 0329 } 0330 } 0331 Kirigami.Icon { 0332 visible: mostPlayedRepeater.count === 0 0333 Layout.margins: 20 0334 isMask: true 0335 opacity:0.4 0336 color: Kirigami.Theme.hoverColor 0337 id:playedPlaceholder 0338 Layout.alignment: Qt.AlignHCenter 0339 Layout.fillWidth: true 0340 implicitWidth: 190 0341 implicitHeight: 190 0342 source: "qrc:/resources/played_placeholder.svg" 0343 0344 Controls.Label { 0345 visible: mostPlayedRepeater.count === 0 0346 color: Kirigami.Theme.disabledTextColor 0347 anchors.centerIn:playedPlaceholder 0348 font.bold: true 0349 font.pointSize: 15 0350 text: i18n("No Songs Played Yet") 0351 } 0352 } 0353 0354 HorizontalCoverView { 0355 id: mostPlayedRepeater 0356 0357 Layout.fillWidth: true 0358 model: Library.mostPlayed 0359 delegate: ColumnLayout { 0360 id: mpdelegateItem 0361 required property string title 0362 required property var artists 0363 required property string artistsDisplayString 0364 required property string videoId 0365 0366 Layout.fillWidth: false 0367 Layout.maximumWidth: 200 0368 0369 ThumbnailSource { 0370 id: mpthumbnailSource 0371 videoId: mpdelegateItem.videoId 0372 } 0373 0374 AlbumCoverItem { 0375 Layout.fillWidth: true 0376 Layout.fillHeight: true 0377 0378 onClicked: play(mpdelegateItem.videoId) 0379 onOptionsClicked: menu.openForSong(mpdelegateItem.videoId, 0380 mpdelegateItem.title, 0381 mpdelegateItem.artists, 0382 mpdelegateItem.artistsDisplayString) 0383 0384 title: mpdelegateItem.title 0385 subtitle: mpdelegateItem.artistsDisplayString 0386 0387 contentItem: RoundedImage { 0388 source: mpthumbnailSource.cachedPath 0389 anchors.fill: parent 0390 radius: 10 0391 } 0392 } 0393 0394 Item { 0395 height: 5 0396 } 0397 } 0398 } 0399 Item { 0400 height: 20 0401 } 0402 RowLayout { 0403 Layout.fillWidth: true 0404 Kirigami.Heading { 0405 text: i18n("Playlists") 0406 Layout.alignment: Qt.AlignLeft 0407 leftPadding: 15 0408 } 0409 0410 0411 // Spacer 0412 Item { 0413 Layout.fillWidth: true 0414 } 0415 0416 Controls.ToolButton { 0417 text: i18n("Show All") 0418 Layout.alignment: Qt.AlignRight 0419 icon.name: "arrow-right" 0420 onClicked: {pageStack.push("qrc:/LocalPlaylistsPage.qml", { 0421 "objectName": "playlists" 0422 })} 0423 } 0424 } 0425 0426 Kirigami.Icon { 0427 id: playlistsPlaceholder 0428 0429 visible: playlistsRepeater.count === 0 0430 Layout.margins: 20 0431 isMask: true 0432 opacity:0.4 0433 color: Kirigami.Theme.hoverColor 0434 Layout.alignment: Qt.AlignHCenter 0435 Layout.fillWidth: true 0436 implicitWidth: 190 0437 implicitHeight: 190 0438 0439 source: "qrc:/resources/playlist_placeholder.svg" 0440 0441 Controls.Label { 0442 visible: favouriteRepeater.count === 0 0443 color: Kirigami.Theme.disabledTextColor 0444 text: i18n("No Playlists Yet") 0445 0446 font { 0447 bold: true 0448 pointSize: 15 0449 } 0450 0451 anchors.centerIn: playlistsPlaceholder 0452 } 0453 } 0454 0455 RenamePlaylistDialog{ 0456 id: renamePlaylistDialog 0457 playlistsModel: localPlaylistsModel 0458 } 0459 Components.BottomDrawer{ 0460 id: playlistDrawer 0461 0462 parent: applicationWindow().overlay 0463 0464 property var modelData 0465 drawerContentItem: ColumnLayout { 0466 KirigamiDelegates.SubtitleDelegate{ 0467 text: i18n("Rename") 0468 icon.name: "edit-entry" 0469 onClicked: { 0470 renamePlaylistDialog.modelData = playlistDrawer.modelData 0471 renamePlaylistDialog.open() 0472 playlistDrawer.close() 0473 } 0474 } 0475 KirigamiDelegates.SubtitleDelegate{ 0476 text: i18n("Delete") 0477 icon.name: "delete" 0478 onClicked: { 0479 localPlaylistsModel.deletePlaylist(playlistDrawer.modelData.playlistId) 0480 playlistDrawer.close() 0481 } 0482 } 0483 } 0484 } 0485 Controls.Menu { 0486 id: playlistMenu 0487 property var modelData 0488 Controls.MenuItem { 0489 text: i18n("Rename") 0490 icon.name: "edit-entry" 0491 onTriggered:{ 0492 renamePlaylistDialog.modelData = playlistMenu.modelData 0493 renamePlaylistDialog.open() 0494 } 0495 } 0496 Controls.MenuItem { 0497 text: i18n("Delete") 0498 icon.name: "delete" 0499 onTriggered:{ 0500 localPlaylistsModel.deletePlaylist(playlistMenu.modelData.playlistId) 0501 } 0502 } 0503 } 0504 0505 HorizontalCoverView { 0506 id: playlistsRepeater 0507 Layout.fillWidth: true 0508 model: LocalPlaylistsModel { 0509 id: localPlaylistsModel 0510 } 0511 delegate: ColumnLayout { 0512 id: playlistDelegate 0513 required property var model 0514 required property string playlistId 0515 required property string title 0516 required property string description 0517 required property date createdOn 0518 required property var thumbnailIds 0519 0520 Layout.fillWidth: false 0521 Layout.maximumWidth: 200 0522 Layout.preferredWidth: 200 0523 0524 AlbumCoverItem { 0525 Layout.fillWidth: true 0526 Layout.fillHeight: true 0527 0528 title: playlistDelegate.title 0529 subtitle: playlistDelegate.description 0530 showIcon: false 0531 0532 LocalPlaylistsModel{id:localPlaylistModel} 0533 0534 ThumbnailSource { 0535 id: thumbnailSource1 0536 videoId: thumbnailIds[0] ?? "" 0537 } 0538 ThumbnailSource { 0539 id: thumbnailSource2 0540 videoId: thumbnailIds[1] ?? thumbnailIds[0] ?? "" 0541 } 0542 ThumbnailSource { 0543 id: thumbnailSource3 0544 videoId: thumbnailIds[2] ?? thumbnailIds[0] ?? "" 0545 } 0546 ThumbnailSource { 0547 id: thumbnailSource4 0548 videoId: thumbnailIds[3] ?? thumbnailIds[0] ?? "" 0549 } 0550 contentItem: PlaylistCover { 0551 source1: thumbnailSource1.cachedPath 0552 source2: thumbnailSource2.cachedPath 0553 source3: thumbnailSource3.cachedPath 0554 source4: thumbnailSource4.cachedPath 0555 title: playlistDelegate.title 0556 height: 200 0557 width: height 0558 radius: 10 0559 } 0560 0561 onClicked: pageStack.push("qrc:/LocalPlaylistPage.qml", { 0562 "playlistId": playlistDelegate.playlistId, 0563 "title": playlistDelegate.title 0564 }) 0565 0566 onOptionsClicked:{ 0567 playlistMenu.modelData = playlistDelegate.model 0568 playlistDrawer.modelData = playlistDelegate.model 0569 Kirigami.Settings.isMobile? playlistDrawer.open() : playlistMenu.popup() 0570 } 0571 } 0572 } 0573 } 0574 } 0575 }