From d8f762b3c42e2c1d5593f66b62ab38373c780a13 Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Fri, 7 Jun 2019 10:29:49 -0400 Subject: [PATCH] Add context menu for playing/adding songs --- Persephone/Controllers/AlbumDetailView.swift | 17 ++++++++ Persephone/Resources/AlbumDetailView.xib | 44 ++++++++++++++------ 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/Persephone/Controllers/AlbumDetailView.swift b/Persephone/Controllers/AlbumDetailView.swift index d24380d..6a29f35 100644 --- a/Persephone/Controllers/AlbumDetailView.swift +++ b/Persephone/Controllers/AlbumDetailView.swift @@ -27,6 +27,7 @@ class AlbumDetailView: NSViewController { albumTracksView.delegate = self albumTracksView.intercellSpacing = CGSize(width: 0, height: 18) albumTracksView.floatsGroupRows = false + albumTracksView.columnAutoresizingStyle = .sequentialColumnAutoresizingStyle albumCoverView.wantsLayer = true albumCoverView.layer?.cornerRadius = 5 @@ -76,6 +77,22 @@ class AlbumDetailView: NSViewController { App.store.dispatch(MPDPlayTrack(queuePos: queueLength)) } + @IBAction func menuActionPlaySong(_ sender: NSMenuItem) { + guard let song = dataSource.albumSongs[albumTracksView.clickedRow].song + else { return } + + let queueLength = App.store.state.queueState.queue.count + App.store.dispatch(MPDAppendTrack(song: song.mpdSong)) + App.store.dispatch(MPDPlayTrack(queuePos: queueLength)) + } + + @IBAction func menuActionAppendSong(_ sender: NSMenuItem) { + guard let song = dataSource.albumSongs[albumTracksView.clickedRow].song + else { return } + + App.store.dispatch(MPDAppendTrack(song: song.mpdSong)) + } + func getAlbumSongs(for album: Album) { App.mpdClient.getAlbumSongs(for: album.mpdAlbum) { [weak self] (mpdSongs: [MPDClient.MPDSong]) in self?.dataSource.setAlbumSongs( diff --git a/Persephone/Resources/AlbumDetailView.xib b/Persephone/Resources/AlbumDetailView.xib index 17a1cf9..0acb536 100644 --- a/Persephone/Resources/AlbumDetailView.xib +++ b/Persephone/Resources/AlbumDetailView.xib @@ -18,11 +18,11 @@ - + - + @@ -33,7 +33,7 @@ - + @@ -41,7 +41,7 @@ - + @@ -50,7 +50,7 @@ - - + + - + - + @@ -174,7 +174,7 @@ - + @@ -214,17 +214,18 @@ + @@ -245,8 +246,25 @@ - + + + + + + + + + + + + + + + + + +