begin work on settings dialog
This commit is contained in:
@@ -304,6 +304,18 @@ func (c *Controller) ShowAboutDialog() {
|
||||
pop.Show()
|
||||
}
|
||||
|
||||
func (c *Controller) ShowSettingsDialog() {
|
||||
dlg := dialogs.NewSettingsDialog(c.App.Config)
|
||||
pop := widget.NewModalPopUp(dlg, c.MainWindow.Canvas())
|
||||
dlg.OnDismiss = func() {
|
||||
pop.Hide()
|
||||
c.doModalClosed()
|
||||
}
|
||||
c.ClosePopUpOnEscape(pop)
|
||||
c.haveModal = true
|
||||
pop.Show()
|
||||
}
|
||||
|
||||
func (c *Controller) trySetPasswordAndConnectToServer(server *backend.ServerConfig, password string) error {
|
||||
if err := c.App.ServerManager.SetServerPassword(server, password); err != nil {
|
||||
log.Printf("error setting keyring credentials: %v", err)
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package dialogs
|
||||
|
||||
import (
|
||||
"supersonic/backend"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/data/binding"
|
||||
"fyne.io/fyne/v2/layout"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
var boldStyle = widget.RichTextStyle{TextStyle: fyne.TextStyle{Bold: true}}
|
||||
|
||||
type SettingsDialog struct {
|
||||
widget.BaseWidget
|
||||
|
||||
OnReplayGainSettingsChanged func()
|
||||
OnAudioExclusiveSettingChanged func()
|
||||
OnDismiss func()
|
||||
|
||||
config *backend.Config
|
||||
|
||||
content fyne.CanvasObject
|
||||
}
|
||||
|
||||
func NewSettingsDialog(config *backend.Config) *SettingsDialog {
|
||||
s := &SettingsDialog{config: config}
|
||||
s.ExtendBaseWidget(s)
|
||||
|
||||
replayGainSelect := widget.NewSelect([]string{"None", "Album", "Track"}, nil)
|
||||
|
||||
tabs := container.NewAppTabs(
|
||||
container.NewTabItem("General", container.NewVBox(
|
||||
widget.NewRichText(&widget.TextSegment{Text: "Scrobbling", Style: boldStyle}),
|
||||
widget.NewCheckWithData("Send playback statistics to server", binding.BindBool(&config.Scrobbling.Enabled)))),
|
||||
container.NewTabItem("Playback", container.NewVBox(
|
||||
widget.NewRichText(&widget.TextSegment{Text: "ReplayGain", Style: boldStyle}),
|
||||
container.New(layout.NewFormLayout(),
|
||||
widget.NewLabel("ReplayGain mode"), replayGainSelect,
|
||||
widget.NewLabel("Prevent clipping"), widget.NewCheckWithData("", binding.BindBool(&config.ReplayGain.PreventClipping)),
|
||||
),
|
||||
widget.NewSeparator(),
|
||||
widget.NewCheckWithData("Audio exclusive mode", binding.BindBool(&config.LocalPlayback.AudioExclusive)))),
|
||||
)
|
||||
s.content = container.NewVBox(tabs, widget.NewSeparator(),
|
||||
container.NewHBox(layout.NewSpacer(), widget.NewButton("Close", func() {
|
||||
if s.OnDismiss != nil {
|
||||
s.OnDismiss()
|
||||
}
|
||||
})))
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *SettingsDialog) CreateRenderer() fyne.WidgetRenderer {
|
||||
return widget.NewSimpleRenderer(s.content)
|
||||
}
|
||||
@@ -108,6 +108,7 @@ func NewMainWindow(fyneApp fyne.App, appName, appVersion string, app *backend.Ap
|
||||
}
|
||||
}()
|
||||
})
|
||||
m.BrowsingPane.AddSettingsMenuItem("Settings...", m.Controller.ShowSettingsDialog)
|
||||
m.BrowsingPane.AddSettingsMenuItem("About...", m.Controller.ShowAboutDialog)
|
||||
m.addNavigationButtons()
|
||||
m.BrowsingPane.DisableNavigationButtons()
|
||||
|
||||
Reference in New Issue
Block a user