Switch the theme live
Widgets copy their colors when they are created, so they now get role tokens (one unique RGB value per role) instead of colors, and a wrapper around the tcell screen replaces the tokens with the current theme's colors in SetContent. Changing the theme in the Config view swaps that table; the next draw recolors everything. Poster colors that equal a token are nudged off it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019reK4DUGYqDUjniWYJvwUW
This commit is contained in:
@@ -108,8 +108,8 @@ func boolSetting(old *bool, value, def bool) *bool {
|
||||
return &value
|
||||
}
|
||||
|
||||
// settingsView edits the configuration file's settings. Everything except
|
||||
// the theme applies right after saving; the theme at the next start.
|
||||
// settingsView edits the configuration file's settings. Everything applies
|
||||
// right after saving.
|
||||
type settingsView struct {
|
||||
app *App
|
||||
root *tview.Flex
|
||||
@@ -184,7 +184,7 @@ func newSettingsView(app *App) *settingsView {
|
||||
f.AddFormItem(v.covers)
|
||||
v.style = tview.NewDropDown().SetLabel("Poster style").SetOptions(coverStyles, func(string, int) { v.edited() })
|
||||
f.AddFormItem(v.style)
|
||||
v.theme = tview.NewDropDown().SetLabel("Theme (at the next start)").SetOptions(themes, func(string, int) { v.edited() })
|
||||
v.theme = tview.NewDropDown().SetLabel("Theme").SetOptions(themes, func(string, int) { v.edited() })
|
||||
f.AddFormItem(v.theme)
|
||||
v.notify = tview.NewCheckbox().SetLabel("Notify about finished downloads").SetChangedFunc(func(bool) { v.edited() })
|
||||
f.AddFormItem(v.notify)
|
||||
@@ -347,7 +347,7 @@ func (v *settingsView) describe() {
|
||||
} else {
|
||||
b.WriteString("Config file: " + tview.Escape(v.app.cfgPath) + "\n")
|
||||
}
|
||||
b.WriteString("Changes take effect when you save; only the theme waits for the next start.\n")
|
||||
b.WriteString("Changes take effect when you save; nothing needs a restart.\n")
|
||||
if len(v.overridden) > 0 {
|
||||
var names []string
|
||||
for _, env := range v.overridden {
|
||||
@@ -437,13 +437,9 @@ func (v *settingsView) save() {
|
||||
v.report("[red]Saved, but not applied: " + tview.Escape(err.Error()) + "[-]")
|
||||
return
|
||||
}
|
||||
themeChanged := effective.UI.Theme != v.app.cfg.UI.Theme
|
||||
v.app.cfgFile = &raw
|
||||
v.app.applyConfig(effective)
|
||||
v.dirty = false
|
||||
v.report("[green]Saved to " + tview.Escape(v.app.cfgPath) + " and applied.[-]")
|
||||
if themeChanged {
|
||||
v.report("The new theme is used from the next start.")
|
||||
}
|
||||
v.app.Notify(levelSuccess, "Settings saved")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user