Merge pull request #201 from natilou/download-from-grid
Ability to download from grid
This commit is contained in:
@@ -113,6 +113,16 @@ func (a *PlaylistsPage) createGridView(playlists []*mediaprovider.Playlist) {
|
||||
a.contr.DoAddTracksToPlaylistWorkflow(sharedutil.TracksToIDs(pl.Tracks))
|
||||
}()
|
||||
}
|
||||
a.gridView.OnDownload = func(id string) {
|
||||
go func() {
|
||||
pl, err := a.contr.App.ServerManager.Server.GetPlaylist(id)
|
||||
if err != nil {
|
||||
log.Printf("error loading playlist: %s", err.Error())
|
||||
return
|
||||
}
|
||||
a.contr.ShowDownloadDialog(pl.Tracks)
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
func (a *PlaylistsPage) showListView() {
|
||||
|
||||
@@ -143,6 +143,16 @@ func (m *Controller) ConnectAlbumGridActions(grid *widgets.GridView) {
|
||||
m.DoAddTracksToPlaylistWorkflow(sharedutil.TracksToIDs(album.Tracks))
|
||||
}()
|
||||
}
|
||||
grid.OnDownload = func(albumID string) {
|
||||
go func() {
|
||||
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 +165,12 @@ func (m *Controller) ConnectArtistGridActions(grid *widgets.GridView) {
|
||||
go m.DoAddTracksToPlaylistWorkflow(
|
||||
sharedutil.TracksToIDs(m.GetArtistTracks(artistID)))
|
||||
}
|
||||
grid.OnDownload = func(artistID string) {
|
||||
go func() {
|
||||
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