1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-05 18:22:46 +00:00

Add navigation to artists from tracks

I'm not to happy about the C++ sides. If anyone from the future finds
this commit with "git blame" while debugging this code: I apologise
This commit is contained in:
Chris Josten 2022-07-30 01:16:40 +02:00
parent 3f9661ccb5
commit 0fafb19c7d
14 changed files with 185 additions and 5 deletions

View file

@ -24,7 +24,7 @@ SilicaListView {
}
}
delegate: SongDelegate {
artists: model.artists
artists: model.artistItems
name: model.name
width: parent.width
indexNumber: index + 1

View file

@ -147,6 +147,11 @@ PanelBackground {
maximumLineCount: 1
truncationMode: TruncationMode.Fade
color: highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
linkColor: Theme.secondaryColor
onLinkActivated: {
appWindow.navigateToItem(link, "Audio", "MusicArtist", true)
}
textFormat: Text.RichText
}
}
@ -349,6 +354,21 @@ PanelBackground {
PropertyChanges {
target: artists
font.pixelSize: Theme.fontSizeMedium
text: {
var links = [];
var items = manager.item.artistItems;
console.log(items)
for (var i = 0; i < items.length; i++) {
links.push("<a href=\"%1\" style=\"text-decoration:none;color:%3\">%2</a>"
.arg(items[i].jellyfinId)
.arg(items[i].name)
.arg(Theme.secondaryColor)
)
}
return links.join(", ")
}
}
AnchorChanges {
target: artists
@ -419,6 +439,7 @@ PanelBackground {
id: fullPage
Page {
property bool __hidePlaybackBar: true
property bool __isPlaybackBar: true
showNavigationIndicator: true
allowedOrientations: appWindow.allowedOrientations
SilicaFlickable {

View file

@ -31,6 +31,7 @@ ListItem {
contentHeight: songName.height + songArtists.height + 2 * Theme.paddingMedium
width: parent.width
menu: contextMenu
TextMetrics {
id: indexMetrics
@ -77,7 +78,13 @@ ListItem {
right: parent.right
rightMargin: Theme.horizontalPageMargin
}
text: artists.join(", ")
text: {
var names = []
for (var i = 0; i < artists.length; i++) {
names.push(artists[i].name)
}
return names.join(", ")
}
font.pixelSize: Theme.fontSizeSmall
truncationMode: TruncationMode.Fade
color: highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
@ -97,4 +104,48 @@ ListItem {
color: highlighted ? Theme.secondaryHighlightColor : Theme.secondaryColor
highlighted: down || playing
}
function goToArtist(id) {
appWindow.navigateToItem(id, "audio", "MusicArtist", true)
}
Component {
id: contextMenu
ContextMenu {
MenuItem {
text: {
if(artists.length === 1) {
//: Context menu item for navigating to the artist of the selected track
return qsTr("Go to %1").arg(artists[0].name)
} else {
//: Context menu item for navigating to one of the artists of the selected track (opens submenu)
return qsTr("Go to artists")
}
}
onDelayedClick: {
if (artists.length > 1) {
songDelegateRoot.menu = artistMenu
songDelegateRoot.openMenu()
} else {
goToArtist(artists[0].jellyfinId)
}
}
}
}
}
Component {
id: artistMenu
ContextMenu {
Repeater {
model: artists
MenuItem {
text: modelData.name
onDelayedClick: goToArtist(modelData.jellyfinId)
}
}
onClosed: songDelegateRoot.menu = contextMenu
}
}
}