Add advanced menu item that tells how to edit the config via command line
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
KemoNine 2020-09-04 19:06:04 -04:00
parent b0764b684a
commit a33f8b7539

View file

@ -141,6 +141,7 @@ func ConfigGui(config *koanf.Koanf) {
menu.AddItem("Intervals", "", '2', nil)
menu.AddItem("WiFi", "", '3', nil)
menu.AddItem("HDMI On/Off", "", '5', nil)
menu.AddItem("Advanced", "", '6', nil)
// Setup base var for main column so the menu setup is easier to manage
main := tview.NewFlex().
@ -224,6 +225,13 @@ func ConfigGui(config *koanf.Koanf) {
app.SetFocus(menu)
})
// Advanced config form
advancedForm := tview.NewForm()
advancedForm.AddButton("Go Back", func() {
main.Clear()
app.SetFocus(menu)
})
// Setup menu selection handler
menu.SetSelectedFunc(func(index int, title string, desc string, shortcut rune) {
if title == "Select Albums" {
@ -252,6 +260,13 @@ func ConfigGui(config *koanf.Koanf) {
main.AddItem(tview.NewTextView().SetText("These values are date+time combos\n\nPlease see https://www.freedesktop.org/software/systemd/man/systemd.time.html for details\n\nONLY adjust the times (24h format) if unsure of what to change"), 0, 1, false)
app.SetFocus(hdmiForm)
}
if title == "Advanced" {
main.SetTitle("Advanced Configuration")
main.Clear()
main.AddItem(tview.NewTextView().SetText("For advanced configuration edit /etc/default/pf.toml via the command line. There are a few config values that are DANGEROUS to adjust and not exposed through this ui."), 0, 1, false)
main.AddItem(advancedForm, 0, 1, false)
app.SetFocus(advancedForm)
}
})
// Side bar fields
@ -410,10 +425,12 @@ func ConfigGui(config *koanf.Koanf) {
intervalField, intervalButton := intervalsForm.GetFocusedItemIndex()
wifiField, wifiButton := wifiConfigForm.GetFocusedItemIndex()
hdmiField, hdmiButton := hdmiForm.GetFocusedItemIndex()
advancedField, advancedButton := advancedForm.GetFocusedItemIndex()
if wifiField != -1 || wifiButton != -1 ||
albumField != -1 || albumButton != -1 ||
intervalField != -1 || intervalButton != -1 ||
hdmiField != -1 || hdmiButton != -1 {
hdmiField != -1 || hdmiButton != -1 ||
advancedField != -1 || advancedButton != -1{
switch event.Key() {
case tcell.KeyUp:
return tcell.NewEventKey(tcell.KeyBacktab, 0, event.Modifiers())
@ -464,6 +481,6 @@ func ConfigGui(config *koanf.Koanf) {
// Show UI and panic if there are any errors
if err := app.SetRoot(pages, true).SetFocus(primitivesThatCanFocus[currentFocus]).EnableMouse(false).Run(); err != nil {
log.Fatalf("Failed to run UI : ", err)
log.Fatalf("Failed to run UI : %s", err)
}
}