add Shuffle context menu item to tracklist; unselect tracks on Favorites page by clicking outside

This commit is contained in:
Drew Weymouth
2023-05-13 16:47:15 -07:00
parent 4c6d6eb162
commit 2083af3935
3 changed files with 16 additions and 4 deletions
+6
View File
@@ -132,6 +132,12 @@ func (a *FavoritesPage) Route() controller.Route {
return controller.FavoritesRoute()
}
func (a *FavoritesPage) Tapped(*fyne.PointEvent) {
if a.tracklistCtr != nil {
a.tracklistCtr.Objects[0].(*widgets.Tracklist).UnselectAll()
}
}
func (a *FavoritesPage) Reload() {
// reload favorite albums view
if a.searchText != "" {
+2 -2
View File
@@ -101,8 +101,8 @@ func (m *Controller) ConnectTracklistActions(tracklist *widgets.Tracklist) {
m.App.PlaybackManager.LoadTracks(tracklist.Tracks, false, false)
m.App.PlaybackManager.PlayTrackAt(idx)
}
tracklist.OnPlaySelection = func(tracks []*subsonic.Child) {
m.App.PlaybackManager.LoadTracks(tracks, false, false)
tracklist.OnPlaySelection = func(tracks []*subsonic.Child, shuffle bool) {
m.App.PlaybackManager.LoadTracks(tracks, false, shuffle)
m.App.PlaybackManager.PlayFromBeginning()
}
tracklist.OnSetFavorite = m.SetTrackFavorites
+8 -2
View File
@@ -60,7 +60,7 @@ type Tracklist struct {
// user action callbacks
OnPlayTrackAt func(int)
OnPlaySelection func(tracks []*subsonic.Child)
OnPlaySelection func(tracks []*subsonic.Child, shuffle bool)
OnAddToQueue func(trackIDs []*subsonic.Child)
OnAddToPlaylist func(trackIDs []string)
OnSetFavorite func(trackIDs []string, fav bool)
@@ -283,7 +283,13 @@ func (t *Tracklist) onShowContextMenu(e *fyne.PointEvent, trackIdx int) {
t.ctxMenu.Items = append(t.ctxMenu.Items,
fyne.NewMenuItem("Play", func() {
if t.OnPlaySelection != nil {
t.OnPlaySelection(t.selectedTracks())
t.OnPlaySelection(t.selectedTracks(), false)
}
}))
t.ctxMenu.Items = append(t.ctxMenu.Items,
fyne.NewMenuItem("Shuffle", func() {
if t.OnPlaySelection != nil {
t.OnPlaySelection(t.selectedTracks(), true)
}
}))
t.ctxMenu.Items = append(t.ctxMenu.Items,