Fix #223: open Settings dialog to last active tab

This commit is contained in:
Drew Weymouth
2023-07-19 14:58:27 -07:00
parent 1465479f2a
commit bd15866e02
2 changed files with 32 additions and 0 deletions
+2
View File
@@ -28,6 +28,7 @@ type AppConfig struct {
EnableSystemTray bool
CloseToSystemTray bool
StartupPage string
SettingsTab string
AllowMultiInstance bool
// Experimental - may be removed in future
@@ -124,6 +125,7 @@ func DefaultConfig(appVersionTag string) *Config {
EnableSystemTray: true,
CloseToSystemTray: false,
StartupPage: "Albums",
SettingsTab: "General",
AllowMultiInstance: false,
},
AlbumPage: AlbumPageConfig{
+30
View File
@@ -63,9 +63,11 @@ func NewSettingsDialog(
s.createEqualizerTab(equalizerBands),
s.createExperimentalTab(window),
)
tabs.SelectIndex(s.getActiveTabNumFromConfig())
// workaround issue where inactivated tabs don't fully update when theme setting is changed
tabs.OnSelected = func(ti *container.TabItem) {
ti.Content.Refresh()
s.saveSelectedTab(tabs.SelectedIndex())
}
s.promptText = widget.NewRichTextWithText("")
s.content = container.NewVBox(tabs, widget.NewSeparator(),
@@ -453,3 +455,31 @@ func (s *SettingsDialog) onAudioExclusiveSettingsChanged() {
func (s *SettingsDialog) CreateRenderer() fyne.WidgetRenderer {
return widget.NewSimpleRenderer(s.content)
}
func (s *SettingsDialog) saveSelectedTab(tabNum int) {
var tabName string
switch tabNum {
case 0:
tabName = "General"
case 1:
tabName = "Playback"
case 2:
tabName = "Equalizer"
case 3:
tabName = "Experimental"
}
s.config.Application.SettingsTab = tabName
}
func (s *SettingsDialog) getActiveTabNumFromConfig() int {
switch s.config.Application.SettingsTab {
case "Playback":
return 1
case "Equalizer":
return 2
case "Experimental":
return 3
default:
return 0
}
}