1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2024-11-22 09:15:18 +00:00

Add better playlist view

I reused the AlbumDetailPage for playlists, as both are very similar. If
they end up being too different, I might want to look into splitting
them up, but for now it will do.
This commit is contained in:
Chris Josten 2022-07-23 01:52:26 +02:00
parent c1e402f411
commit 4a178ee227
No known key found for this signature in database
GPG key ID: A69C050E9FD9FF6A
4 changed files with 41 additions and 16 deletions

View file

@ -89,6 +89,7 @@ function getPageUrl(mediaType, itemType, isFolder) {
case "episode": case "episode":
return Qt.resolvedUrl("pages/itemdetails/EpisodePage.qml") return Qt.resolvedUrl("pages/itemdetails/EpisodePage.qml")
case "musicalbum": case "musicalbum":
case "playlist":
return Qt.resolvedUrl("pages/itemdetails/MusicAlbumPage.qml") return Qt.resolvedUrl("pages/itemdetails/MusicAlbumPage.qml")
case "photo": case "photo":
return Qt.resolvedUrl("pages/itemdetails/PhotoPage.qml") return Qt.resolvedUrl("pages/itemdetails/PhotoPage.qml")

View file

@ -37,6 +37,7 @@ Item {
property alias blurhash : albumArtImage.blurhash property alias blurhash : albumArtImage.blurhash
property bool twoColumns property bool twoColumns
property real aspectRatio property real aspectRatio
property string type
readonly property real smallSize: albumHeader.height readonly property real smallSize: albumHeader.height
readonly property real bigSize: listHeader.width / aspectRatio readonly property real bigSize: listHeader.width / aspectRatio
@ -101,12 +102,22 @@ Item {
width: parent.width - Theme.horizontalPageMargin - height width: parent.width - Theme.horizontalPageMargin - height
title: name title: name
//: Short description of the album: %1 -> album artist, %2 -> amount of songs, %3 -> duration, %4 -> release year //: Short description of the album: %1 -> album artist, %2 -> amount of songs, %3 -> duration, %4 -> release year
description: qsTr("%1\n%2 songs | %3 | %4") description: {
if (type == "MusicAlbum") {
//: Short description of the album: %1 -> album artist, %2 -> amount of songs, %3 -> duration, %4 -> release year
qsTr("%1\n%2 songs | %3 | %4")
.arg(albumArtist) .arg(albumArtist)
.arg(songCount) .arg(songCount)
.arg(Utils.ticksToText(duration)) .arg(Utils.ticksToText(duration))
//: Unknown album release year //: Unknown album release year
.arg(releaseYear >= 0 ? releaseYear : qsTr("Unknown year")) .arg(releaseYear >= 0 ? releaseYear : qsTr("Unknown year"))
} else {
qsTr("Playlist\n%1 songs | %2")
.arg(songCount)
.arg(Utils.ticksToText(duration))
}
}
} }
RemoteImage { RemoteImage {

View file

@ -28,6 +28,7 @@ import "../.."
*/ */
Column { Column {
id: wideAlbumCover
property ListView listview property ListView listview
property real releaseYear property real releaseYear
property alias albumArt: albumArt.source property alias albumArt: albumArt.source
@ -37,6 +38,8 @@ Column {
property string name property string name
property alias blurhash : albumArt.blurhash property alias blurhash : albumArt.blurhash
property bool twoColumns: true property bool twoColumns: true
property real aspectRatio
property string type
Item { width:1; height: Theme.paddingLarge } Item { width:1; height: Theme.paddingLarge }
@ -51,12 +54,21 @@ Column {
leftMargin: 0 leftMargin: 0
rightMargin: 0 rightMargin: 0
title: name title: name
description: {
if (wideAlbumCover.type == "MusicAlbum") {
//: Short description of the album: %1 -> album artist, %2 -> amount of songs, %3 -> duration, %4 -> release year //: Short description of the album: %1 -> album artist, %2 -> amount of songs, %3 -> duration, %4 -> release year
description: qsTr("%1\n%2 songs | %3 | %4") qsTr("%1\n%2 songs | %3 | %4")
.arg(albumArtist) .arg(albumArtist)
.arg(songCount) .arg(songCount)
.arg(Utils.ticksToText(duration)) .arg(Utils.ticksToText(duration))
//: Unknown album release year //: Unknown album release year
.arg(releaseYear >= 0 ? releaseYear : qsTr("Unknown year")) .arg(releaseYear >= 0 ? releaseYear : qsTr("Unknown year"))
} else {
//: Playlist header: %1 -> amount of songs in the playlist, %2 -> Total duration
qsTr("Playlist\n%1 songs | %2")
.arg(songCount)
.arg(Utils.ticksToText(duration))
}
}
} }
} }

View file

@ -38,7 +38,7 @@ BaseDetailPage {
id: collectionModel id: collectionModel
loader: J.UserItemsLoader { loader: J.UserItemsLoader {
apiClient: appWindow.apiClient apiClient: appWindow.apiClient
sortBy: "SortName" sortBy: itemData.type === "MusicAlbum" ? "ParentIndexNumber,IndexNumber,SortName" : undefined
fields: [J.ItemFields.ItemCounts, J.ItemFields.PrimaryImageAspectRatio] fields: [J.ItemFields.ItemCounts, J.ItemFields.PrimaryImageAspectRatio]
parentId: itemData.jellyfinId parentId: itemData.jellyfinId
autoReload: itemData.jellyfinId.length > 0 autoReload: itemData.jellyfinId.length > 0
@ -70,7 +70,7 @@ BaseDetailPage {
onLoaded: bindAlbum(item) onLoaded: bindAlbum(item)
} }
section { section {
property: "parentIndexNumber" property: itemData.type === "MusicAlbum" ? "parentIndexNumber" : undefined
delegate: SectionHeader { delegate: SectionHeader {
text: qsTr("Disc %1").arg(section) text: qsTr("Disc %1").arg(section)
} }
@ -80,7 +80,7 @@ BaseDetailPage {
name: model.name name: model.name
artists: model.artists artists: model.artists
duration: model.runTimeTicks duration: model.runTimeTicks
indexNumber: model.indexNumber indexNumber: itemData.type === "MusicAlbum" ? model.indexNumber : index + 1
onClicked: window.playbackManager.playItemInList(collectionModel, model.index) onClicked: window.playbackManager.playItemInList(collectionModel, model.index)
} }
@ -99,5 +99,6 @@ BaseDetailPage {
item.aspectRatio = Qt.binding(function() { return itemData.primaryImageAspectRatio}) item.aspectRatio = Qt.binding(function() { return itemData.primaryImageAspectRatio})
item.blurhash = Qt.binding(function() { return itemData.imageBlurHashes["Primary"][itemData.imageTags["Primary"]]; }) item.blurhash = Qt.binding(function() { return itemData.imageBlurHashes["Primary"][itemData.imageTags["Primary"]]; })
item.twoColumns = Qt.binding(function() { return _twoColumns }) item.twoColumns = Qt.binding(function() { return _twoColumns })
item.type = Qt.binding(function() { return itemData.type})
} }
} }