From now on, if you try to leave setup without making any change, you won't be prompted whether to save configuration or not

This commit is contained in:
veeso
2021-07-16 15:32:39 +02:00
parent 59c6567ff3
commit e1109fff15
5 changed files with 57 additions and 9 deletions

View File

@@ -36,12 +36,28 @@ use tuirealm::tui::style::Color;
use tuirealm::{Payload, Value};
impl SetupActivity {
/// ### action_on_esc
///
/// On <ESC>, if there are changes in the configuration, the quit dialog must be shown, otherwise
/// we can exit without any problem
pub(super) fn action_on_esc(&mut self) {
if self.config_changed() {
self.mount_quit();
} else {
self.exit_reason = Some(super::ExitReason::Quit);
}
}
/// ### action_save_all
///
/// Save all configurations. If current tab can load values, they will be loaded, otherwise they'll just be saved
/// Save all configurations. If current tab can load values, they will be loaded, otherwise they'll just be saved.
/// Once all the configuration has been changed, set config_changed to false
pub(super) fn action_save_all(&mut self) -> Result<(), String> {
self.action_save_config()?;
self.action_save_theme()
self.action_save_theme()?;
// Set config changed to false
self.set_config_changed(false);
Ok(())
}
/// ### action_save_config