add track info menu item to PlayQueueList and NowPlayingCard
This commit is contained in:
@@ -78,6 +78,11 @@ func NewBottomPanel(pm *backend.PlaybackManager, im *backend.ImageManager, contr
|
|||||||
bp.NowPlaying.OnTrackNameTapped = func() {
|
bp.NowPlaying.OnTrackNameTapped = func() {
|
||||||
contr.NavigateTo(controller.NowPlayingRoute(pm.NowPlaying().Metadata().ID))
|
contr.NavigateTo(controller.NowPlayingRoute(pm.NowPlaying().Metadata().ID))
|
||||||
}
|
}
|
||||||
|
bp.NowPlaying.OnShowTrackInfo = func() {
|
||||||
|
if tr, ok := pm.NowPlaying().(*mediaprovider.Track); ok {
|
||||||
|
contr.ShowTrackInfoDialog(tr)
|
||||||
|
}
|
||||||
|
}
|
||||||
bp.NowPlaying.OnShare = func() {
|
bp.NowPlaying.OnShare = func() {
|
||||||
if tr, ok := pm.NowPlaying().(*mediaprovider.Track); ok {
|
if tr, ok := pm.NowPlaying().(*mediaprovider.Track); ok {
|
||||||
contr.ShowShareDialog(tr.ID)
|
contr.ShowShareDialog(tr.ID)
|
||||||
|
|||||||
@@ -150,6 +150,7 @@ func (c *Controller) ConnectPlayQueuelistActions(list *widgets.PlayQueueList) {
|
|||||||
c.App.PlaybackManager.UpdatePlayQueue(newTracks)
|
c.App.PlaybackManager.UpdatePlayQueue(newTracks)
|
||||||
}
|
}
|
||||||
list.OnDownload = c.ShowDownloadDialog
|
list.OnDownload = c.ShowDownloadDialog
|
||||||
|
list.OnShowTrackInfo = c.ShowTrackInfoDialog
|
||||||
list.OnShare = func(tracks []*mediaprovider.Track) {
|
list.OnShare = func(tracks []*mediaprovider.Track) {
|
||||||
if len(tracks) > 0 {
|
if len(tracks) > 0 {
|
||||||
c.ShowShareDialog(tracks[0].ID)
|
c.ShowShareDialog(tracks[0].ID)
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package widgets
|
package widgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fyne.io/fyne/v2/lang"
|
|
||||||
"image"
|
"image"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2/lang"
|
||||||
|
|
||||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||||
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
myTheme "github.com/dweymouth/supersonic/ui/theme"
|
||||||
"github.com/dweymouth/supersonic/ui/util"
|
"github.com/dweymouth/supersonic/ui/util"
|
||||||
@@ -37,6 +38,7 @@ type NowPlayingCard struct {
|
|||||||
OnSetRating func(rating int)
|
OnSetRating func(rating int)
|
||||||
OnSetFavorite func(favorite bool)
|
OnSetFavorite func(favorite bool)
|
||||||
OnAddToPlaylist func()
|
OnAddToPlaylist func()
|
||||||
|
OnShowTrackInfo func()
|
||||||
OnShare func()
|
OnShare func()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +112,12 @@ func (n *NowPlayingCard) onAddToPlaylist() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *NowPlayingCard) onShowTrackInfo() {
|
||||||
|
if n.OnShowTrackInfo != nil {
|
||||||
|
n.OnShowTrackInfo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (n *NowPlayingCard) onShare() {
|
func (n *NowPlayingCard) onShare() {
|
||||||
if n.OnShare != nil {
|
if n.OnShare != nil {
|
||||||
n.OnShare()
|
n.OnShare()
|
||||||
@@ -164,10 +172,12 @@ func (n *NowPlayingCard) showMenu(btnPos fyne.Position) {
|
|||||||
unfavorite.Icon = myTheme.NotFavoriteIcon
|
unfavorite.Icon = myTheme.NotFavoriteIcon
|
||||||
playlist := fyne.NewMenuItem(lang.L("Add to playlist")+"...", func() { n.onAddToPlaylist() })
|
playlist := fyne.NewMenuItem(lang.L("Add to playlist")+"...", func() { n.onAddToPlaylist() })
|
||||||
playlist.Icon = myTheme.PlaylistIcon
|
playlist.Icon = myTheme.PlaylistIcon
|
||||||
|
info := fyne.NewMenuItem(lang.L("Show info")+"...", func() { n.onShowTrackInfo() })
|
||||||
|
info.Icon = theme.InfoIcon()
|
||||||
share := fyne.NewMenuItem(lang.L("Share")+"...", func() { n.onShare() })
|
share := fyne.NewMenuItem(lang.L("Share")+"...", func() { n.onShare() })
|
||||||
share.Icon = myTheme.ShareIcon
|
share.Icon = myTheme.ShareIcon
|
||||||
|
|
||||||
m := fyne.NewMenu("", favorite, unfavorite, n.ratingMenu, playlist, share)
|
m := fyne.NewMenu("", favorite, unfavorite, n.ratingMenu, playlist, info, share)
|
||||||
n.menu = widget.NewPopUpMenu(m, fyne.CurrentApp().Driver().CanvasForObject(n))
|
n.menu = widget.NewPopUpMenu(m, fyne.CurrentApp().Driver().CanvasForObject(n))
|
||||||
}
|
}
|
||||||
menuSize := n.menu.MinSize()
|
menuSize := n.menu.MinSize()
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package widgets
|
package widgets
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fyne.io/fyne/v2/lang"
|
|
||||||
"image"
|
"image"
|
||||||
"slices"
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2/lang"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/canvas"
|
"fyne.io/fyne/v2/canvas"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
@@ -47,6 +48,7 @@ type PlayQueueList struct {
|
|||||||
OnSetRating func(trackIDs []string, rating int)
|
OnSetRating func(trackIDs []string, rating int)
|
||||||
OnRemoveFromQueue func(idxs []int)
|
OnRemoveFromQueue func(idxs []int)
|
||||||
OnDownload func(tracks []*mediaprovider.Track, downloadName string)
|
OnDownload func(tracks []*mediaprovider.Track, downloadName string)
|
||||||
|
OnShowTrackInfo func(track *mediaprovider.Track)
|
||||||
OnShare func(tracks []*mediaprovider.Track)
|
OnShare func(tracks []*mediaprovider.Track)
|
||||||
OnShowArtistPage func(artistID string)
|
OnShowArtistPage func(artistID string)
|
||||||
OnReorderItems func(idxs []int, reorderTo int)
|
OnReorderItems func(idxs []int, reorderTo int)
|
||||||
@@ -55,6 +57,7 @@ type PlayQueueList struct {
|
|||||||
menu *widget.PopUpMenu // ctx menu for when only tracks are selected
|
menu *widget.PopUpMenu // ctx menu for when only tracks are selected
|
||||||
radiosMenu *widget.PopUpMenu // ctx menu for when selection contains radios
|
radiosMenu *widget.PopUpMenu // ctx menu for when selection contains radios
|
||||||
ratingSubmenu *fyne.MenuItem
|
ratingSubmenu *fyne.MenuItem
|
||||||
|
infoMenuItem *fyne.MenuItem
|
||||||
shareMenuItem *fyne.MenuItem
|
shareMenuItem *fyne.MenuItem
|
||||||
|
|
||||||
nowPlayingID string
|
nowPlayingID string
|
||||||
@@ -259,6 +262,7 @@ func (p *PlayQueueList) onShowContextMenu(e *fyne.PointEvent, trackIdx int) {
|
|||||||
if allTracks {
|
if allTracks {
|
||||||
p.ensureTracksMenu()
|
p.ensureTracksMenu()
|
||||||
p.ratingSubmenu.Disabled = p.DisableRating
|
p.ratingSubmenu.Disabled = p.DisableRating
|
||||||
|
p.infoMenuItem.Disabled = len(selected) != 1
|
||||||
p.shareMenuItem.Disabled = p.DisableSharing || len(selected) != 1
|
p.shareMenuItem.Disabled = p.DisableSharing || len(selected) != 1
|
||||||
menu = p.menu
|
menu = p.menu
|
||||||
} else {
|
} else {
|
||||||
@@ -290,6 +294,12 @@ func (p *PlayQueueList) ensureTracksMenu() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
download.Icon = theme.DownloadIcon()
|
download.Icon = theme.DownloadIcon()
|
||||||
|
p.infoMenuItem = fyne.NewMenuItem(lang.L("Show info")+"...", func() {
|
||||||
|
if p.OnShowTrackInfo != nil {
|
||||||
|
p.OnShowTrackInfo(p.selectedTracks()[0])
|
||||||
|
}
|
||||||
|
})
|
||||||
|
p.infoMenuItem.Icon = theme.InfoIcon()
|
||||||
p.shareMenuItem = fyne.NewMenuItem(lang.L("Share")+"...", func() {
|
p.shareMenuItem = fyne.NewMenuItem(lang.L("Share")+"...", func() {
|
||||||
if p.OnShare != nil {
|
if p.OnShare != nil {
|
||||||
p.OnShare(p.selectedTracks())
|
p.OnShare(p.selectedTracks())
|
||||||
@@ -316,6 +326,7 @@ func (p *PlayQueueList) ensureTracksMenu() {
|
|||||||
menuItems = append(menuItems,
|
menuItems = append(menuItems,
|
||||||
playlist,
|
playlist,
|
||||||
download,
|
download,
|
||||||
|
p.infoMenuItem,
|
||||||
p.shareMenuItem,
|
p.shareMenuItem,
|
||||||
fyne.NewMenuItemSeparator(),
|
fyne.NewMenuItemSeparator(),
|
||||||
favorite,
|
favorite,
|
||||||
|
|||||||
Reference in New Issue
Block a user