From f4a37ec22029fd1c156f37408bda6d9efdd84982 Mon Sep 17 00:00:00 2001 From: seternate Date: Fri, 24 May 2024 21:18:50 +0200 Subject: [PATCH] Removed 'Save' in SettingsBrowser The 'Save' button in the SettingsBrowser was removed. Due to the changed save behaviour it is not neccessary. --- pkg/widget/form.go | 21 ++++++++++++++++----- pkg/widget/settingbrowser.go | 10 +--------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pkg/widget/form.go b/pkg/widget/form.go index b4d64b2..45920eb 100644 --- a/pkg/widget/form.go +++ b/pkg/widget/form.go @@ -57,6 +57,11 @@ func (widget *Form) SetSubmitText(text string) { widget.Refresh() } +func (widget *Form) HideSubmit() { + widget.submit.Hide() + widget.Refresh() +} + func (widget *Form) SetCancelText(text string) { widget.cancel.SetText(text) widget.Refresh() @@ -91,11 +96,17 @@ func (renderer *formRenderer) Layout(size fyne.Size) { item.Resize(fyne.NewSize(size.Width-2*theme.InnerPadding(), item.MinSize().Height)) lastposition = item.Position().Y + item.Size().Height } - buttonSize := fyne.NewSize(fyne.Max(renderer.widget.cancel.MinSize().Width, renderer.widget.submit.MinSize().Width), renderer.widget.submit.MinSize().Height) - renderer.widget.submit.Resize(buttonSize) - renderer.widget.submit.Move(fyne.NewPos(size.Width-theme.InnerPadding()-buttonSize.Width, size.Height-theme.InnerPadding()-buttonSize.Height)) - renderer.widget.cancel.Resize(buttonSize) - renderer.widget.cancel.Move(fyne.NewPos(renderer.widget.submit.Position().X-theme.InnerPadding()-buttonSize.Width, renderer.widget.submit.Position().Y)) + if renderer.widget.submit.Hidden { + buttonSize := fyne.NewSize(renderer.widget.cancel.MinSize().Width, renderer.widget.cancel.MinSize().Height) + renderer.widget.cancel.Resize(buttonSize) + renderer.widget.cancel.Move(fyne.NewPos(size.Width-theme.InnerPadding()-buttonSize.Width, size.Height-theme.InnerPadding()-buttonSize.Height)) + } else { + buttonSize := fyne.NewSize(fyne.Max(renderer.widget.cancel.MinSize().Width, renderer.widget.submit.MinSize().Width), renderer.widget.submit.MinSize().Height) + renderer.widget.submit.Resize(buttonSize) + renderer.widget.submit.Move(fyne.NewPos(size.Width-theme.InnerPadding()-buttonSize.Width, size.Height-theme.InnerPadding()-buttonSize.Height)) + renderer.widget.cancel.Resize(buttonSize) + renderer.widget.cancel.Move(fyne.NewPos(renderer.widget.submit.Position().X-theme.InnerPadding()-buttonSize.Width, renderer.widget.submit.Position().Y)) + } } func (renderer *formRenderer) MinSize() fyne.Size { diff --git a/pkg/widget/settingbrowser.go b/pkg/widget/settingbrowser.go index 561452e..91230e4 100644 --- a/pkg/widget/settingbrowser.go +++ b/pkg/widget/settingbrowser.go @@ -106,16 +106,8 @@ func NewSettingsBrowser(controller *controller.Controller, window fyne.Window) ( } settingsbrowser.form.AppendItem(NewFormItem("Username", settingsbrowser.username)) - settingsbrowser.form.SetSubmitText("Save") + settingsbrowser.form.HideSubmit() settingsbrowser.form.SetCancelText("Reset") - settingsbrowser.form.OnSubmit = func() { - controller.Settings.SetServerURL(settingsbrowser.serverurl.Text) - controller.Settings.SetGameDirectory(settingsbrowser.gamedirectory.Text) - controller.Settings.SetUsername(settingsbrowser.username.Text) - if controller.Settings.Save() == nil { - controller.Status.Info("Settings successfully saved", 3*time.Second) - } - } settingsbrowser.form.OnCancel = func() { settingsbrowser.ResetData() controller.Status.Info("Settings resetted", 3*time.Second)