mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
Deal with album artist when dragging songs
This commit is contained in:
parent
a47cb4a74e
commit
0916496fe5
@ -83,7 +83,7 @@ extension AlbumDetailView: NSTableViewDelegate {
|
|||||||
owner: self
|
owner: self
|
||||||
) as! NSTableCellView
|
) as! NSTableCellView
|
||||||
|
|
||||||
if song.artist != song.album.artist {
|
if song.artist != song.albumArtist {
|
||||||
let string = NSMutableAttributedString()
|
let string = NSMutableAttributedString()
|
||||||
string.append(NSAttributedString(string: song.title))
|
string.append(NSAttributedString(string: song.title))
|
||||||
string.append(NSAttributedString(string: " – " + song.artist, attributes: [.foregroundColor: NSColor.secondaryLabelColor]))
|
string.append(NSAttributedString(string: " – " + song.artist, attributes: [.foregroundColor: NSColor.secondaryLabelColor]))
|
||||||
|
|||||||
@ -50,6 +50,7 @@ class AlbumTracksDataSource: NSObject, NSTableViewDataSource {
|
|||||||
type: .albumSongItem(song.mpdSong.uriString),
|
type: .albumSongItem(song.mpdSong.uriString),
|
||||||
title: song.title,
|
title: song.title,
|
||||||
artist: song.artist,
|
artist: song.artist,
|
||||||
|
albumArtist: song.albumArtist,
|
||||||
album: song.album.title,
|
album: song.album.title,
|
||||||
uri: song.mpdSong.uriString
|
uri: song.mpdSong.uriString
|
||||||
),
|
),
|
||||||
@ -70,10 +71,11 @@ class AlbumTracksDataSource: NSObject, NSTableViewDataSource {
|
|||||||
) { draggingItem, index, stop in
|
) { draggingItem, index, stop in
|
||||||
guard let item = draggingItem.item as? NSPasteboardItem,
|
guard let item = draggingItem.item as? NSPasteboardItem,
|
||||||
let draggedSong = item.draggedSong(forType: .songPasteboardType),
|
let draggedSong = item.draggedSong(forType: .songPasteboardType),
|
||||||
case let (title, artist, album, uri) = (
|
case let (title, artist, album, albumArtist, uri) = (
|
||||||
draggedSong.title,
|
draggedSong.title,
|
||||||
draggedSong.artist,
|
draggedSong.artist,
|
||||||
draggedSong.album,
|
draggedSong.album,
|
||||||
|
draggedSong.albumArtist,
|
||||||
draggedSong.uri
|
draggedSong.uri
|
||||||
)
|
)
|
||||||
else { return }
|
else { return }
|
||||||
@ -83,6 +85,7 @@ class AlbumTracksDataSource: NSObject, NSTableViewDataSource {
|
|||||||
let draggedSongView = DraggedSongView(
|
let draggedSongView = DraggedSongView(
|
||||||
title: title,
|
title: title,
|
||||||
artist: artist,
|
artist: artist,
|
||||||
|
albumArtist: albumArtist,
|
||||||
album: album,
|
album: album,
|
||||||
uri: uri
|
uri: uri
|
||||||
)
|
)
|
||||||
|
|||||||
@ -44,6 +44,7 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
|||||||
type: .queueItem(queueItem.queuePos),
|
type: .queueItem(queueItem.queuePos),
|
||||||
title: queueItem.song.title,
|
title: queueItem.song.title,
|
||||||
artist: queueItem.song.artist,
|
artist: queueItem.song.artist,
|
||||||
|
albumArtist: queueItem.song.albumArtist,
|
||||||
album: queueItem.song.album.title,
|
album: queueItem.song.album.title,
|
||||||
uri: queueItem.song.mpdSong.uriString
|
uri: queueItem.song.mpdSong.uriString
|
||||||
),
|
),
|
||||||
@ -129,10 +130,11 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
|||||||
guard let item = draggingItem.item as? NSPasteboardItem,
|
guard let item = draggingItem.item as? NSPasteboardItem,
|
||||||
let data = item.data(forType: .songPasteboardType),
|
let data = item.data(forType: .songPasteboardType),
|
||||||
let draggedSong = try? PropertyListDecoder().decode(DraggedSong.self, from: data),
|
let draggedSong = try? PropertyListDecoder().decode(DraggedSong.self, from: data),
|
||||||
case let (title, artist, album, uri) = (
|
case let (title, artist, album, albumArtist, uri) = (
|
||||||
draggedSong.title,
|
draggedSong.title,
|
||||||
draggedSong.artist,
|
draggedSong.artist,
|
||||||
draggedSong.album,
|
draggedSong.album,
|
||||||
|
draggedSong.albumArtist,
|
||||||
draggedSong.uri
|
draggedSong.uri
|
||||||
)
|
)
|
||||||
else { return }
|
else { return }
|
||||||
@ -142,6 +144,7 @@ class QueueDataSource: NSObject, NSOutlineViewDataSource {
|
|||||||
let draggedSongView = DraggedSongView(
|
let draggedSongView = DraggedSongView(
|
||||||
title: title,
|
title: title,
|
||||||
artist: artist,
|
artist: artist,
|
||||||
|
albumArtist: albumArtist,
|
||||||
album: album,
|
album: album,
|
||||||
uri: uri
|
uri: uri
|
||||||
)
|
)
|
||||||
|
|||||||
@ -16,12 +16,14 @@ class DraggedSongView: NSViewController {
|
|||||||
|
|
||||||
private let songTitle: String
|
private let songTitle: String
|
||||||
private let songArtist: String
|
private let songArtist: String
|
||||||
|
private let songAlbumArtist: String
|
||||||
private let songAlbum: String
|
private let songAlbum: String
|
||||||
private let songUri: String
|
private let songUri: String
|
||||||
|
|
||||||
init(title: String, artist: String, album: String, uri: String) {
|
init(title: String, artist: String, albumArtist: String, album: String, uri: String) {
|
||||||
songTitle = title
|
songTitle = title
|
||||||
songArtist = artist
|
songArtist = artist
|
||||||
|
songAlbumArtist = albumArtist
|
||||||
songAlbum = album
|
songAlbum = album
|
||||||
songUri = uri
|
songUri = uri
|
||||||
|
|
||||||
@ -60,7 +62,7 @@ class DraggedSongView: NSViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setCoverArt() {
|
func setCoverArt() {
|
||||||
let mpdAlbum = MPDClient.MPDAlbum(title: songAlbum, artist: songArtist)
|
let mpdAlbum = MPDClient.MPDAlbum(title: songAlbum, artist: songAlbumArtist)
|
||||||
|
|
||||||
let provider = MPDAlbumArtImageDataProvider(
|
let provider = MPDAlbumArtImageDataProvider(
|
||||||
songUri: songUri,
|
songUri: songUri,
|
||||||
|
|||||||
@ -73,7 +73,7 @@ extension MPDClient {
|
|||||||
|
|
||||||
let mpdAlbum = MPDAlbum(
|
let mpdAlbum = MPDAlbum(
|
||||||
title: mpdSong.album.title,
|
title: mpdSong.album.title,
|
||||||
artist: mpdSong.album.artist,
|
artist: mpdSong.albumArtist,
|
||||||
firstSong: mpdSong,
|
firstSong: mpdSong,
|
||||||
date: mpdSong.date
|
date: mpdSong.date
|
||||||
)
|
)
|
||||||
|
|||||||
@ -10,6 +10,7 @@ struct DraggedSong: Codable {
|
|||||||
var type: DraggedSongType
|
var type: DraggedSongType
|
||||||
var title: String
|
var title: String
|
||||||
var artist: String
|
var artist: String
|
||||||
|
var albumArtist: String
|
||||||
var album: String
|
var album: String
|
||||||
var uri: String
|
var uri: String
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,10 @@ struct Song {
|
|||||||
return mpdSong.getTag(.artist)
|
return mpdSong.getTag(.artist)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var albumArtist: String {
|
||||||
|
return mpdSong.getTag(.albumArtist)
|
||||||
|
}
|
||||||
|
|
||||||
var duration: Time {
|
var duration: Time {
|
||||||
return Time(timeInSeconds: mpdSong.duration)
|
return Time(timeInSeconds: mpdSong.duration)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user