Fix #496: Persist repeat mode setting across restarts

This commit is contained in:
Drew Weymouth
2025-01-01 14:23:02 -08:00
parent 16d8cb4a58
commit 6572e74aa8
8 changed files with 46 additions and 8 deletions
+1 -1
View File
@@ -102,7 +102,7 @@ func NewBottomPanel(pm *backend.PlaybackManager, im *backend.ImageManager, contr
pm.SeekFraction(f)
})
bp.AuxControls = widgets.NewAuxControls(pm.Volume())
bp.AuxControls = widgets.NewAuxControls(pm.Volume(), pm.GetLoopMode())
pm.OnLoopModeChange(bp.AuxControls.SetLoopMode)
pm.OnVolumeChange(bp.AuxControls.VolumeControl.SetVolume)
bp.AuxControls.VolumeControl.OnSetVolume = func(v int) {
+8
View File
@@ -147,6 +147,14 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
// TODO: when all shutdowns exit cleanly, remove these lines
// as they are already executed in app.Shutdown()
app.Config.LocalPlayback.Volume = app.LocalPlayer.GetVolume()
repeatMode := "None"
switch app.PlaybackManager.GetLoopMode() {
case backend.LoopOne:
repeatMode = "One"
case backend.LoopAll:
repeatMode = "All"
}
app.Config.Playback.RepeatMode = repeatMode
app.SavePlayQueueIfEnabled()
app.SaveConfigFile()
+2 -1
View File
@@ -25,7 +25,7 @@ type AuxControls struct {
container *fyne.Container
}
func NewAuxControls(initialVolume int) *AuxControls {
func NewAuxControls(initialVolume int, initialLoopMode backend.LoopMode) *AuxControls {
a := &AuxControls{
VolumeControl: NewVolumeControl(initialVolume),
loop: NewIconButton(myTheme.RepeatIcon, nil),
@@ -33,6 +33,7 @@ func NewAuxControls(initialVolume int) *AuxControls {
}
a.loop.IconSize = IconButtonSizeSmaller
a.loop.SetToolTip(lang.L("Repeat"))
a.SetLoopMode(initialLoopMode)
a.showQueue.IconSize = IconButtonSizeSmaller
a.showQueue.SetToolTip(lang.L("Show play queue"))
a.container = container.NewHBox(
+9 -4
View File
@@ -120,10 +120,7 @@ func (i *IconButton) iconSize() fyne.Size {
}
}
func (i *IconButton) Refresh() {
if i.img == nil {
return
}
func (i *IconButton) updateColor() {
if i.Highlighted || i.focused {
i.themed.ColorName = theme.ColorNamePrimary
} else if i.hovered {
@@ -131,6 +128,13 @@ func (i *IconButton) Refresh() {
} else {
i.themed.ColorName = myTheme.ColorNameIconButton
}
}
func (i *IconButton) Refresh() {
if i.img == nil {
return
}
i.updateColor()
i.img.SetMinSize(i.iconSize())
i.img.Refresh()
}
@@ -141,6 +145,7 @@ func (i *IconButton) CreateRenderer() fyne.WidgetRenderer {
i.img = canvas.NewImageFromResource(i.themed)
i.img.FillMode = canvas.ImageFillContain
i.img.SetMinSize(i.iconSize())
i.updateColor()
}
return widget.NewSimpleRenderer(container.NewCenter(i.img))
}