mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-16 15:08:17 +08:00
rewrite using IoC and DI
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"AynaLivePlayer/config"
|
||||
"AynaLivePlayer/common/i18n"
|
||||
"AynaLivePlayer/controller"
|
||||
"AynaLivePlayer/i18n"
|
||||
"AynaLivePlayer/model"
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/data/binding"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
@@ -26,16 +25,33 @@ func (b *bascicConfig) CreatePanel() fyne.CanvasObject {
|
||||
if b.panel != nil {
|
||||
return b.panel
|
||||
}
|
||||
|
||||
randomPlaylist := container.NewHBox(
|
||||
widget.NewLabel(i18n.T("gui.config.basic.random_playlist")),
|
||||
widget.NewCheckWithData(
|
||||
newCheckInit(
|
||||
i18n.T("gui.config.basic.random_playlist.user"),
|
||||
binding.BindBool(&controller.UserPlaylist.Config.RandomNext)),
|
||||
widget.NewCheckWithData(
|
||||
func(b bool) {
|
||||
l().Infof("Set random playlist for user: %t", b)
|
||||
if b {
|
||||
controller.Instance.Playlists().GetCurrent().Model().Mode = model.PlaylistModeRandom
|
||||
} else {
|
||||
controller.Instance.Playlists().GetCurrent().Model().Mode = model.PlaylistModeNormal
|
||||
}
|
||||
},
|
||||
controller.Instance.Playlists().GetCurrent().Model().Mode == model.PlaylistModeRandom),
|
||||
newCheckInit(
|
||||
i18n.T("gui.config.basic.random_playlist.system"),
|
||||
binding.BindBool(&controller.SystemPlaylist.Config.RandomNext)),
|
||||
func(b bool) {
|
||||
l().Infof("Set random playlist for system: %t", b)
|
||||
if b {
|
||||
controller.Instance.Playlists().GetDefault().Model().Mode = model.PlaylistModeRandom
|
||||
} else {
|
||||
controller.Instance.Playlists().GetDefault().Model().Mode = model.PlaylistModeNormal
|
||||
}
|
||||
},
|
||||
controller.Instance.Playlists().GetDefault().Model().Mode == model.PlaylistModeRandom),
|
||||
)
|
||||
devices := controller.GetAudioDevices()
|
||||
devices := controller.Instance.PlayControl().GetAudioDevices()
|
||||
deviceDesc := make([]string, len(devices))
|
||||
deviceDesc2Name := make(map[string]string)
|
||||
for i, device := range devices {
|
||||
@@ -43,17 +59,20 @@ func (b *bascicConfig) CreatePanel() fyne.CanvasObject {
|
||||
deviceDesc2Name[device.Description] = device.Name
|
||||
}
|
||||
deviceSel := widget.NewSelect(deviceDesc, func(s string) {
|
||||
controller.SetAudioDevice(deviceDesc2Name[s])
|
||||
controller.Instance.PlayControl().SetAudioDevice(deviceDesc2Name[s])
|
||||
})
|
||||
deviceSel.Selected = config.Player.AudioDevice
|
||||
deviceSel.Selected = controller.Instance.PlayControl().GetCurrentAudioDevice()
|
||||
outputDevice := container.NewBorder(nil, nil,
|
||||
widget.NewLabel(i18n.T("gui.config.basic.audio_device")), nil,
|
||||
deviceSel)
|
||||
skipPlaylist := container.NewHBox(
|
||||
widget.NewLabel(i18n.T("gui.config.basic.skip_playlist")),
|
||||
widget.NewCheckWithData(
|
||||
newCheckInit(
|
||||
i18n.T("gui.config.basic.skip_playlist.prompt"),
|
||||
binding.BindBool(&config.Player.SkipPlaylist),
|
||||
func(b bool) {
|
||||
controller.Instance.PlayControl().SetSkipPlaylist(b)
|
||||
},
|
||||
controller.Instance.PlayControl().GetSkipPlaylist(),
|
||||
),
|
||||
)
|
||||
b.panel = container.NewVBox(randomPlaylist, outputDevice, skipPlaylist)
|
||||
|
||||
Reference in New Issue
Block a user