Skip to content

Commit

Permalink
add Shuffle context menu item to tracklist; unselect tracks on Favori…
Browse files Browse the repository at this point in the history
…tes page by clicking outside
  • Loading branch information
dweymouth committed May 13, 2023
1 parent 4c6d6eb commit 2083af3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions ui/browsing/favoritespage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
4 changes: 2 additions & 2 deletions ui/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions ui/widgets/tracklist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2083af3

Please sign in to comment.