mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2026-03-15 14:03:17 +08:00
finish config_basic.go
This commit is contained in:
@@ -1,20 +1,54 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"AynaLivePlayer/config"
|
||||
"AynaLivePlayer/controller"
|
||||
"AynaLivePlayer/i18n"
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/data/binding"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
type bascicConfig struct{}
|
||||
|
||||
func (b bascicConfig) Title() string {
|
||||
return "Basic"
|
||||
type bascicConfig struct {
|
||||
panel fyne.CanvasObject
|
||||
}
|
||||
|
||||
func (b bascicConfig) Description() string {
|
||||
return "Basic configuration"
|
||||
func (b *bascicConfig) Title() string {
|
||||
return i18n.T("gui.config.basic.title")
|
||||
}
|
||||
|
||||
func (b bascicConfig) Create() fyne.CanvasObject {
|
||||
//TODO implement me
|
||||
panic("implement me")
|
||||
func (b *bascicConfig) Description() string {
|
||||
return i18n.T("gui.config.basic.description")
|
||||
}
|
||||
|
||||
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(
|
||||
i18n.T("gui.config.basic.random_playlist.user"),
|
||||
binding.BindBool(&controller.UserPlaylist.Config.RandomNext)),
|
||||
widget.NewCheckWithData(
|
||||
i18n.T("gui.config.basic.random_playlist.system"),
|
||||
binding.BindBool(&controller.SystemPlaylist.Config.RandomNext)),
|
||||
)
|
||||
devices := controller.GetAudioDevices()
|
||||
deviceDesc := make([]string, len(devices))
|
||||
deviceDesc2Name := make(map[string]string)
|
||||
for i, device := range devices {
|
||||
deviceDesc[i] = device.Description
|
||||
deviceDesc2Name[device.Description] = device.Name
|
||||
}
|
||||
deviceSel := widget.NewSelect(deviceDesc, func(s string) {
|
||||
controller.SetAudioDevice(deviceDesc2Name[s])
|
||||
})
|
||||
deviceSel.Selected = config.Player.AudioDevice
|
||||
outputDevice := container.NewBorder(nil, nil,
|
||||
widget.NewLabel(i18n.T("gui.config.basic.audio_device")), nil,
|
||||
deviceSel)
|
||||
b.panel = container.NewVBox(randomPlaylist, outputDevice)
|
||||
return b.panel
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ type ConfigLayout interface {
|
||||
|
||||
var App fyne.App
|
||||
var MainWindow fyne.Window
|
||||
var ConfigList = []ConfigLayout{}
|
||||
var ConfigList = []ConfigLayout{&bascicConfig{}}
|
||||
|
||||
func l() *logrus.Entry {
|
||||
return logger.Logger.WithField("Module", MODULE_GUI)
|
||||
|
||||
@@ -141,6 +141,7 @@ func registerPlayControllerHandler() {
|
||||
l().Error("fail to register handler for progress bar with property idle-active")
|
||||
}
|
||||
|
||||
PlayController.Progress.Max = 0
|
||||
PlayController.Progress.OnChanged = func(f float64) {
|
||||
controller.Seek(f/10, false)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func (b *playlistOperationButton) Tapped(e *fyne.PointEvent) {
|
||||
func newPlaylistOperationButton() *playlistOperationButton {
|
||||
b := &playlistOperationButton{Index: 0}
|
||||
deleteItem := fyne.NewMenuItem(i18n.T("gui.player.playlist.op.delete"), func() {
|
||||
fmt.Println("delete", b.Index)
|
||||
controller.UserPlaylist.Delete(b.Index)
|
||||
})
|
||||
topItem := fyne.NewMenuItem(i18n.T("gui.player.playlist.op.top"), func() {
|
||||
controller.UserPlaylist.Move(b.Index, 0)
|
||||
|
||||
Reference in New Issue
Block a user