Ability to download from grid
- Adding the option to download the album or tracks in grid view from Artist and Album pages.
This commit is contained in:
@@ -143,6 +143,14 @@ func (m *Controller) ConnectAlbumGridActions(grid *widgets.GridView) {
|
||||
m.DoAddTracksToPlaylistWorkflow(sharedutil.TracksToIDs(album.Tracks))
|
||||
}()
|
||||
}
|
||||
grid.OnDownload = func(albumID string) {
|
||||
album, err := m.App.ServerManager.Server.GetAlbum(albumID)
|
||||
if err != nil {
|
||||
log.Printf("error loading album: %s", err.Error())
|
||||
return
|
||||
}
|
||||
m.ShowDownloadDialog(album.Tracks)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Controller) ConnectArtistGridActions(grid *widgets.GridView) {
|
||||
@@ -155,6 +163,10 @@ func (m *Controller) ConnectArtistGridActions(grid *widgets.GridView) {
|
||||
go m.DoAddTracksToPlaylistWorkflow(
|
||||
sharedutil.TracksToIDs(m.GetArtistTracks(artistID)))
|
||||
}
|
||||
grid.OnDownload = func(artistID string) {
|
||||
tracks := m.GetArtistTracks(artistID)
|
||||
m.ShowDownloadDialog(tracks)
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Controller) GetArtistTracks(artistID string) []*mediaprovider.Track {
|
||||
|
||||
@@ -89,6 +89,7 @@ type GridViewState struct {
|
||||
OnPlay func(id string, shuffle bool)
|
||||
OnAddToQueue func(id string)
|
||||
OnAddToPlaylist func(id string)
|
||||
OnDownload func(id string)
|
||||
OnShowItemPage func(id string)
|
||||
OnShowSecondaryPage func(id string)
|
||||
|
||||
@@ -217,6 +218,11 @@ func (g *GridView) createGridWrap() {
|
||||
g.OnAddToPlaylist(card.ItemID())
|
||||
}
|
||||
}
|
||||
card.OnDownload = func() {
|
||||
if g.OnDownload != nil {
|
||||
g.OnDownload(card.itemID)
|
||||
}
|
||||
}
|
||||
return card
|
||||
},
|
||||
// update func
|
||||
|
||||
@@ -129,6 +129,7 @@ type GridViewItem struct {
|
||||
OnPlay func(shuffle bool)
|
||||
OnAddToQueue func()
|
||||
OnAddToPlaylist func()
|
||||
OnDownload func()
|
||||
OnShowItemPage func()
|
||||
OnShowSecondaryPage func()
|
||||
}
|
||||
@@ -173,7 +174,8 @@ func (g *GridViewItem) showContextMenu(pos fyne.Position) {
|
||||
fyne.NewMenuItem("Play", func() { g.onPlay(false) }),
|
||||
fyne.NewMenuItem("Shuffle", func() { g.onPlay(true) }),
|
||||
fyne.NewMenuItem("Add to queue", g.onAddToQueue),
|
||||
fyne.NewMenuItem("Add to playlist...", g.onAddToPlaylist)),
|
||||
fyne.NewMenuItem("Add to playlist...", g.onAddToPlaylist),
|
||||
fyne.NewMenuItem("Download", g.onDownload)),
|
||||
fyne.CurrentApp().Driver().CanvasForObject(g))
|
||||
}
|
||||
g.menu.ShowAtPosition(pos)
|
||||
@@ -218,3 +220,9 @@ func (g *GridViewItem) onAddToPlaylist() {
|
||||
g.OnAddToPlaylist()
|
||||
}
|
||||
}
|
||||
|
||||
func (g *GridViewItem) onDownload() {
|
||||
if g.OnDownload != nil {
|
||||
g.OnDownload()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user