add remove from playlist support
This commit is contained in:
@@ -50,6 +50,9 @@ func NewPlaylistPage(
|
|||||||
a.header = NewPlaylistPageHeader(a)
|
a.header = NewPlaylistPageHeader(a)
|
||||||
a.tracklist = widgets.NewTracklist(nil)
|
a.tracklist = widgets.NewTracklist(nil)
|
||||||
a.tracklist.AutoNumber = true
|
a.tracklist.AutoNumber = true
|
||||||
|
a.tracklist.AuxiliaryMenuItems = []*fyne.MenuItem{
|
||||||
|
fyne.NewMenuItem("Remove from playlist", a.onRemoveSelectedFromPlaylist),
|
||||||
|
}
|
||||||
// connect tracklist actions
|
// connect tracklist actions
|
||||||
a.tracklist.OnPlayTrackAt = a.onPlayTrackAt
|
a.tracklist.OnPlayTrackAt = a.onPlayTrackAt
|
||||||
a.tracklist.OnAddToQueue = func(tracks []*subsonic.Child) { a.pm.LoadTracks(tracks, true) }
|
a.tracklist.OnAddToQueue = func(tracks []*subsonic.Child) { a.pm.LoadTracks(tracks, true) }
|
||||||
@@ -114,6 +117,11 @@ func (a *PlaylistPage) loadAsync() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *PlaylistPage) onRemoveSelectedFromPlaylist() {
|
||||||
|
a.sm.Server.UpdatePlaylistTracks(a.playlistID, nil, a.tracklist.SelectedTrackIndexes())
|
||||||
|
go a.Reload()
|
||||||
|
}
|
||||||
|
|
||||||
type PlaylistPageHeader struct {
|
type PlaylistPageHeader struct {
|
||||||
widget.BaseWidget
|
widget.BaseWidget
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ type Tracklist struct {
|
|||||||
|
|
||||||
Tracks []*subsonic.Child
|
Tracks []*subsonic.Child
|
||||||
AutoNumber bool
|
AutoNumber bool
|
||||||
|
// must be set before the context menu is shown for the first time
|
||||||
|
AuxiliaryMenuItems []*fyne.MenuItem
|
||||||
|
|
||||||
// user action callbacks
|
// user action callbacks
|
||||||
OnPlayTrackAt func(int)
|
OnPlayTrackAt func(int)
|
||||||
@@ -219,6 +221,10 @@ func (t *Tracklist) onShowContextMenu(e *fyne.PointEvent, trackIdx int) {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
if len(t.AuxiliaryMenuItems) > 0 {
|
||||||
|
t.ctxMenu.Items = append(t.ctxMenu.Items, fyne.NewMenuItemSeparator())
|
||||||
|
t.ctxMenu.Items = append(t.ctxMenu.Items, t.AuxiliaryMenuItems...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
widget.ShowPopUpMenuAtPosition(t.ctxMenu, fyne.CurrentApp().Driver().CanvasForObject(t), e.AbsolutePosition)
|
widget.ShowPopUpMenuAtPosition(t.ctxMenu, fyne.CurrentApp().Driver().CanvasForObject(t), e.AbsolutePosition)
|
||||||
}
|
}
|
||||||
@@ -240,3 +246,7 @@ func (t *Tracklist) selectedTrackIDs() []string {
|
|||||||
}
|
}
|
||||||
return tracks
|
return tracks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Tracklist) SelectedTrackIndexes() []int {
|
||||||
|
return t.selectionMgr.GetSelection()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user