aboutsummaryrefslogtreecommitdiff
path: root/app/ui/hub.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-08-25 21:02:21 -0400
committerhistoria <historiavg@proton.me>2026-08-25 21:02:21 -0400
commit4c3e78c39c81d2997e88b84e1b5a25b244e870e4 (patch)
tree92c8df5cf5cf240da00d481df1d82105b69feb22 /app/ui/hub.py
parentd453d88d1d40c5e54af07ceb89c8c18d09cfdb0e (diff)
downloadtts-audiobook-generator-4c3e78c39c81d2997e88b84e1b5a25b244e870e4.tar.gz
feat: prompt to save settings when going back from settings menu
Diffstat (limited to 'app/ui/hub.py')
-rw-r--r--app/ui/hub.py32
1 files changed, 22 insertions, 10 deletions
diff --git a/app/ui/hub.py b/app/ui/hub.py
index cad9a9d..de8b861 100644
--- a/app/ui/hub.py
+++ b/app/ui/hub.py
@@ -405,17 +405,29 @@ class _Hub:
# -- settings -------------------------------------------------------
def screen_settings(self):
- result = tui.form(self.stdscr, "Settings", _settings_fields(),
- back_value=tui.Wizard.BACK)
- if result is tui.Wizard.BACK or result is None:
- return tui.Wizard.BACK
- try:
- _apply_settings(result)
- except ValueError as exc:
- tui.flash(self.stdscr, str(exc), "err")
+ fields = _settings_fields()
+ while True:
+ result = tui.form(self.stdscr, "Settings", fields,
+ back_value=tui.Wizard.BACK)
+ if not (result is tui.Wizard.BACK or result is None):
+ # Save pressed: apply as before, no prompt.
+ try:
+ _apply_settings(result)
+ except ValueError as exc:
+ tui.flash(self.stdscr, str(exc), "err")
+ return tui.Wizard.BACK
+ # q/Esc (or the Cancel button) left the form without saving:
+ # ask whether the edits should be kept before discarding them.
+ answer = tui.confirm_yn_cancel(self.stdscr, "Save settings?")
+ if answer == "cancel":
+ continue # back into the form, edits intact
+ if answer == "yes":
+ values = {field["key"]: field["value"] for field in fields}
+ try:
+ _apply_settings(values)
+ except ValueError as exc:
+ tui.flash(self.stdscr, str(exc), "err")
return tui.Wizard.BACK
- tui.flash(self.stdscr, "Settings saved.", "ok")
- return tui.Wizard.BACK
# -- servers --------------------------------------------------------