add autoplay UI toggle
This commit is contained in:
+4
-1
@@ -102,7 +102,7 @@ func NewBottomPanel(pm *backend.PlaybackManager, im *backend.ImageManager, contr
|
||||
pm.SeekFraction(f)
|
||||
})
|
||||
|
||||
bp.AuxControls = widgets.NewAuxControls(pm.Volume(), pm.GetLoopMode())
|
||||
bp.AuxControls = widgets.NewAuxControls(pm.Volume(), pm.GetLoopMode(), pm.IsAutoplay())
|
||||
pm.OnLoopModeChange(bp.AuxControls.SetLoopMode)
|
||||
pm.OnVolumeChange(bp.AuxControls.VolumeControl.SetVolume)
|
||||
bp.AuxControls.VolumeControl.OnSetVolume = func(v int) {
|
||||
@@ -111,6 +111,9 @@ func NewBottomPanel(pm *backend.PlaybackManager, im *backend.ImageManager, contr
|
||||
bp.AuxControls.OnChangeLoopMode(func() {
|
||||
pm.SetNextLoopMode()
|
||||
})
|
||||
bp.AuxControls.OnChangeAutoplay = func(autoplay bool) {
|
||||
pm.SetAutoplay(autoplay)
|
||||
}
|
||||
bp.AuxControls.OnShowPlayQueue(contr.ShowPopUpPlayQueue)
|
||||
|
||||
bp.imageLoader = util.NewThumbnailLoader(im, bp.NowPlaying.SetImage)
|
||||
|
||||
@@ -160,6 +160,7 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
||||
repeatMode = "All"
|
||||
}
|
||||
app.Config.Playback.RepeatMode = repeatMode
|
||||
app.Config.Playback.Autoplay = app.PlaybackManager.IsAutoplay()
|
||||
app.SavePlayQueueIfEnabled()
|
||||
app.SaveConfigFile()
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ var (
|
||||
|
||||
AlbumIcon fyne.Resource = theme.NewThemedResource(res.ResDiscSvg)
|
||||
ArtistIcon fyne.Resource = theme.NewThemedResource(res.ResPeopleSvg)
|
||||
AutoplayIcon fyne.Resource = theme.NewThemedResource(res.ResInfinitySvg)
|
||||
RadioIcon fyne.Resource = theme.NewThemedResource(res.ResBroadcastSvg)
|
||||
FavoriteIcon fyne.Resource = theme.NewThemedResource(res.ResHeartFilledSvg)
|
||||
NotFavoriteIcon fyne.Resource = theme.NewThemedResource(res.ResHeartOutlineSvg)
|
||||
|
||||
@@ -18,21 +18,34 @@ import (
|
||||
type AuxControls struct {
|
||||
widget.BaseWidget
|
||||
|
||||
OnChangeAutoplay func(autoplay bool)
|
||||
|
||||
VolumeControl *VolumeControl
|
||||
autoplay *IconButton
|
||||
loop *IconButton
|
||||
showQueue *IconButton
|
||||
|
||||
container *fyne.Container
|
||||
}
|
||||
|
||||
func NewAuxControls(initialVolume int, initialLoopMode backend.LoopMode) *AuxControls {
|
||||
func NewAuxControls(initialVolume int, initialLoopMode backend.LoopMode, initialAutoplay bool) *AuxControls {
|
||||
a := &AuxControls{
|
||||
VolumeControl: NewVolumeControl(initialVolume),
|
||||
autoplay: NewIconButton(myTheme.AutoplayIcon, nil),
|
||||
loop: NewIconButton(myTheme.RepeatIcon, nil),
|
||||
showQueue: NewIconButton(myTheme.PlayQueueIcon, nil),
|
||||
}
|
||||
a.loop.IconSize = IconButtonSizeSmaller
|
||||
a.loop.SetToolTip(lang.L("Repeat"))
|
||||
a.loop.Highlighted = initialAutoplay
|
||||
//a.autoplay.IconSize = IconButtonSizeSmaller
|
||||
a.autoplay.SetToolTip(lang.L("Autoplay"))
|
||||
a.autoplay.OnTapped = func() {
|
||||
a.SetAutoplay(!a.autoplay.Highlighted)
|
||||
if a.OnChangeAutoplay != nil {
|
||||
a.OnChangeAutoplay(a.autoplay.Highlighted)
|
||||
}
|
||||
}
|
||||
a.SetLoopMode(initialLoopMode)
|
||||
a.showQueue.IconSize = IconButtonSizeSmaller
|
||||
a.showQueue.SetToolTip(lang.L("Show play queue"))
|
||||
@@ -43,7 +56,7 @@ func NewAuxControls(initialVolume int, initialLoopMode backend.LoopMode) *AuxCon
|
||||
a.VolumeControl,
|
||||
container.New(
|
||||
layout.NewCustomPaddedHBoxLayout(theme.Padding()*1.5),
|
||||
layout.NewSpacer(), a.loop, a.showQueue, util.NewHSpace(5)),
|
||||
layout.NewSpacer(), a.autoplay, a.loop, a.showQueue, util.NewHSpace(5)),
|
||||
layout.NewSpacer(),
|
||||
),
|
||||
)
|
||||
@@ -73,6 +86,14 @@ func (a *AuxControls) SetLoopMode(mode backend.LoopMode) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *AuxControls) SetAutoplay(autoplay bool) {
|
||||
if autoplay == a.autoplay.Highlighted {
|
||||
return
|
||||
}
|
||||
a.autoplay.Highlighted = autoplay
|
||||
a.autoplay.Refresh()
|
||||
}
|
||||
|
||||
func (a *AuxControls) OnShowPlayQueue(f func()) {
|
||||
a.showQueue.OnTapped = f
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user