add OnPlayQueueChange hook
This commit is contained in:
@@ -49,6 +49,10 @@ type CanShowPlayTime interface {
|
||||
OnPlayTimeUpdate(curTime, totalTime float64)
|
||||
}
|
||||
|
||||
type CanShowPlayQueue interface {
|
||||
OnPlayQueueChange()
|
||||
}
|
||||
|
||||
type BrowsingPane struct {
|
||||
widget.BaseWidget
|
||||
|
||||
@@ -80,6 +84,7 @@ func NewBrowsingPane(app *backend.App, contr *controller.Controller) *BrowsingPa
|
||||
b.reload = widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), b.Reload)
|
||||
b.app.PlaybackManager.OnSongChange(b.onSongChange)
|
||||
b.app.PlaybackManager.OnPlayTimeUpdate(b.onPlayTimeUpdate)
|
||||
b.app.PlaybackManager.OnQueueChange(b.onQueueChange)
|
||||
bkgrnd := myTheme.NewThemedRectangle(myTheme.ColorNamePageBackground)
|
||||
b.pageContainer = container.NewStack(bkgrnd, layout.NewSpacer())
|
||||
b.settingsBtn = widget.NewButtonWithIcon("", theme.SettingsIcon(), func() {
|
||||
@@ -222,6 +227,15 @@ func (b *BrowsingPane) onPlayTimeUpdate(cur, total float64) {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BrowsingPane) onQueueChange() {
|
||||
if b.curPage == nil {
|
||||
return
|
||||
}
|
||||
if p, ok := b.curPage.(CanShowPlayQueue); ok {
|
||||
p.OnPlayQueueChange()
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BrowsingPane) addPageToHistory(p Page, truncate bool) {
|
||||
if truncate {
|
||||
// allow garbage collection of pages that will be removed from the history
|
||||
|
||||
@@ -135,6 +135,10 @@ func (a *FullscreenPage) OnSongChange(song, lastScrobbledIfAny *mediaprovider.Tr
|
||||
})
|
||||
}
|
||||
|
||||
func (a *FullscreenPage) OnPlayQueueChange() {
|
||||
a.Reload()
|
||||
}
|
||||
|
||||
func (a *FullscreenPage) Reload() {
|
||||
a.queue = a.pm.GetPlayQueue()
|
||||
a.queueList.SetTracks(a.queue)
|
||||
|
||||
Reference in New Issue
Block a user