Skip to content

Commit

Permalink
Fixed reset device name button in config
Browse files Browse the repository at this point in the history
  • Loading branch information
syllith committed May 11, 2024
1 parent f466379 commit eb16cdc
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ import (
)

type DeviceConfig struct {
Name string
IsShown bool
Name string
IsShown bool
OriginalName string
}

type AppSettings struct {
Expand Down Expand Up @@ -325,18 +326,25 @@ func genConfigForm() fyne.CanvasObject {
if !exists {
//. Config did not exist,using default
config = DeviceConfig{
Name: device.Name,
IsShown: true,
Name: device.Name,
IsShown: true,
OriginalName: device.Name,
}
}

//* Create new name entry
newNameEntry := &widget.Entry{
PlaceHolder: "Device Name",
ActionItem: fyneCustom.NewColorButton("", color.RGBA{68, 72, 81, 255}, theme.MediaReplayIcon(), func() {}),
Text: config.Name,
}

//* Create reset button
resetButton := fyneCustom.NewColorButton("", color.RGBA{68, 72, 81, 255}, theme.MediaReplayIcon(), func() {
newNameEntry.SetText(config.OriginalName)
})

newNameEntry.ActionItem = resetButton

//* Create show/hide checkbox
showHideCheckbox := &widget.Check{
Text: "Shown",
Expand Down Expand Up @@ -367,8 +375,9 @@ func genConfigForm() fyne.CanvasObject {
showHideCheckbox := form.Items[i*2+1].Widget.(*widget.Check)

settings.DeviceNames[audioDevices[i].Id] = DeviceConfig{
Name: newNameEntry.Text,
IsShown: showHideCheckbox.Checked,
Name: newNameEntry.Text,
IsShown: showHideCheckbox.Checked,
OriginalName: audioDevices[i].Name,
}

settings.HideAfterSelection = hideAfterSelectionCheckbox.Checked
Expand Down

0 comments on commit eb16cdc

Please sign in to comment.