Addin saving of previos stages for easy going back.
This commit is contained in:
+25
-30
@@ -71,6 +71,7 @@ struct KiraState {
|
|||||||
current_view: Views,
|
current_view: Views,
|
||||||
toml_config: toml::Table,
|
toml_config: toml::Table,
|
||||||
config: KiraConfig,
|
config: KiraConfig,
|
||||||
|
stages_save: Vec<Views>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const CONFIG_PATH_STR: &str = "kira_config.toml";
|
const CONFIG_PATH_STR: &str = "kira_config.toml";
|
||||||
@@ -97,6 +98,7 @@ impl KiraState {
|
|||||||
config: KiraConfig {
|
config: KiraConfig {
|
||||||
config_trail: Vec::new(),
|
config_trail: Vec::new(),
|
||||||
},
|
},
|
||||||
|
stages_save: Vec::new(),
|
||||||
},
|
},
|
||||||
Task::done(Message::Start),
|
Task::done(Message::Start),
|
||||||
)
|
)
|
||||||
@@ -136,7 +138,8 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
|||||||
match wlc_view.update(wlc_msg) {
|
match wlc_view.update(wlc_msg) {
|
||||||
StageAction::Next(welcome_res) => {
|
StageAction::Next(welcome_res) => {
|
||||||
k_state.config.config_trail.push(welcome_res);
|
k_state.config.config_trail.push(welcome_res);
|
||||||
k_state.current_view = Views::License(license::LicenseStage {});
|
let s_state = std::mem::replace(&mut k_state.current_view, Views::License(license::LicenseStage {}));
|
||||||
|
k_state.stages_save.push(s_state);
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
StageAction::Abort => iced::exit(),
|
StageAction::Abort => iced::exit(),
|
||||||
@@ -152,13 +155,13 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
|||||||
match action {
|
match action {
|
||||||
StageAction::Next(license_res) => {
|
StageAction::Next(license_res) => {
|
||||||
k_state.config.config_trail.push(license_res);
|
k_state.config.config_trail.push(license_res);
|
||||||
k_state.current_view =
|
let s_state = std::mem::replace(&mut k_state.current_view, Views::Network(network::NetworkStage::new(&k_state.toml_config)));
|
||||||
Views::Network(network::NetworkStage::new(&k_state.toml_config));
|
k_state.stages_save.push(s_state);
|
||||||
Task::done(Message::Network(network::Message::CheckNetwork))
|
Task::done(Message::Network(network::Message::CheckNetwork))
|
||||||
}
|
}
|
||||||
StageAction::Abort => iced::exit(),
|
StageAction::Abort => iced::exit(),
|
||||||
StageAction::Back => {
|
StageAction::Back => {
|
||||||
k_state.current_view = Views::Welcome(WelcomeStage::new());
|
k_state.current_view = k_state.stages_save.pop().unwrap();
|
||||||
k_state.config.config_trail.pop();
|
k_state.config.config_trail.pop();
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
@@ -176,12 +179,12 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
|||||||
network::UpdateResult::StageAction(action) => match action {
|
network::UpdateResult::StageAction(action) => match action {
|
||||||
StageAction::Next(network_res) => {
|
StageAction::Next(network_res) => {
|
||||||
k_state.config.config_trail.push(network_res);
|
k_state.config.config_trail.push(network_res);
|
||||||
k_state.current_view =
|
let s_state = std::mem::replace(&mut k_state.current_view,Views::TimeZone(stages::timezone::TimeZoneStage::new()));
|
||||||
Views::TimeZone(stages::timezone::TimeZoneStage::new());
|
k_state.stages_save.push(s_state);
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
StageAction::Back => {
|
StageAction::Back => {
|
||||||
k_state.current_view = Views::License(license::LicenseStage {});
|
k_state.current_view = k_state.stages_save.pop().unwrap();
|
||||||
k_state.config.config_trail.pop();
|
k_state.config.config_trail.pop();
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
@@ -198,16 +201,15 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
|||||||
match action {
|
match action {
|
||||||
StageAction::Next(tz_res) => {
|
StageAction::Next(tz_res) => {
|
||||||
k_state.config.config_trail.push(tz_res);
|
k_state.config.config_trail.push(tz_res);
|
||||||
k_state.current_view =
|
let s_state = std::mem::replace(&mut k_state.current_view,Views::Locale(stages::locale::LocaleStage::new(&k_state.config)));
|
||||||
Views::Locale(stages::locale::LocaleStage::new(&k_state.config));
|
k_state.stages_save.push(s_state);
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
StageAction::Abort => iced::exit(),
|
StageAction::Abort => iced::exit(),
|
||||||
StageAction::Back => {
|
StageAction::Back => {
|
||||||
k_state.config.config_trail.pop();
|
k_state.config.config_trail.pop();
|
||||||
k_state.current_view =
|
k_state.current_view = k_state.stages_save.pop().unwrap();
|
||||||
Views::Network(network::NetworkStage::new(&k_state.toml_config));
|
Task::none()
|
||||||
Task::done(Message::Network(network::Message::CheckNetwork))
|
|
||||||
}
|
}
|
||||||
StageAction::None => Task::none(),
|
StageAction::None => Task::none(),
|
||||||
}
|
}
|
||||||
@@ -220,14 +222,13 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
|||||||
match locale_view.update(locale_msg) {
|
match locale_view.update(locale_msg) {
|
||||||
StageAction::Next(locale_res) => {
|
StageAction::Next(locale_res) => {
|
||||||
k_state.config.config_trail.push(locale_res);
|
k_state.config.config_trail.push(locale_res);
|
||||||
k_state.current_view =
|
let s_state = std::mem::replace(&mut k_state.current_view,Views::Keyboard(stages::keyboard::KeyboardStage::new()));
|
||||||
Views::Keyboard(stages::keyboard::KeyboardStage::new());
|
k_state.stages_save.push(s_state);
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
StageAction::Back => {
|
StageAction::Back => {
|
||||||
k_state.config.config_trail.pop();
|
k_state.config.config_trail.pop();
|
||||||
k_state.current_view =
|
k_state.current_view = k_state.stages_save.pop().unwrap();
|
||||||
Views::TimeZone(stages::timezone::TimeZoneStage::new());
|
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
_ => Task::none(),
|
_ => Task::none(),
|
||||||
@@ -243,7 +244,8 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
|||||||
match stages::partition::PartitionStage::new(&k_state.toml_config) {
|
match stages::partition::PartitionStage::new(&k_state.toml_config) {
|
||||||
Ok(part_stage) => {
|
Ok(part_stage) => {
|
||||||
k_state.config.config_trail.push(keyboard_res);
|
k_state.config.config_trail.push(keyboard_res);
|
||||||
k_state.current_view = Views::Partition(part_stage);
|
let s_state = std::mem::replace(&mut k_state.current_view,Views::Partition(part_stage));
|
||||||
|
k_state.stages_save.push(s_state);
|
||||||
}
|
}
|
||||||
Err(ex) => {
|
Err(ex) => {
|
||||||
log::error!("Error, cannot init partition stage: {}", ex);
|
log::error!("Error, cannot init partition stage: {}", ex);
|
||||||
@@ -253,8 +255,7 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
|||||||
}
|
}
|
||||||
StageAction::Back => {
|
StageAction::Back => {
|
||||||
k_state.config.config_trail.pop();
|
k_state.config.config_trail.pop();
|
||||||
k_state.current_view =
|
k_state.current_view = k_state.stages_save.pop().unwrap();
|
||||||
Views::Locale(stages::locale::LocaleStage::new(&k_state.config));
|
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
_ => Task::none(),
|
_ => Task::none(),
|
||||||
@@ -268,13 +269,13 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
|||||||
match partition_view.update(partition_msg) {
|
match partition_view.update(partition_msg) {
|
||||||
StageAction::Next(partition_res) => {
|
StageAction::Next(partition_res) => {
|
||||||
k_state.config.config_trail.push(partition_res);
|
k_state.config.config_trail.push(partition_res);
|
||||||
k_state.current_view = Views::Security(stages::security::SecurityStage::new());
|
let s_state = std::mem::replace(&mut k_state.current_view,Views::Security(stages::security::SecurityStage::new()));
|
||||||
|
k_state.stages_save.push(s_state);
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
StageAction::Back => {
|
StageAction::Back => {
|
||||||
k_state.config.config_trail.pop();
|
k_state.config.config_trail.pop();
|
||||||
k_state.current_view =
|
k_state.current_view = k_state.stages_save.pop().unwrap();
|
||||||
Views::Keyboard(stages::keyboard::KeyboardStage::new());
|
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
_ => Task::none(),
|
_ => Task::none(),
|
||||||
@@ -288,18 +289,12 @@ fn update(k_state: &mut KiraState, message: Message) -> Task<Message> {
|
|||||||
match security_view.update(security_msg) {
|
match security_view.update(security_msg) {
|
||||||
StageAction::Next(security_res) => {
|
StageAction::Next(security_res) => {
|
||||||
k_state.config.config_trail.push(security_res);
|
k_state.config.config_trail.push(security_res);
|
||||||
|
//let s_state = std::mem::replace(&mut k_state.current_view,
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
StageAction::Back => {
|
StageAction::Back => {
|
||||||
k_state.config.config_trail.pop();
|
k_state.config.config_trail.pop();
|
||||||
match stages::partition::PartitionStage::new(&k_state.toml_config) {
|
k_state.current_view = k_state.stages_save.pop().unwrap();
|
||||||
Ok(part_stage) => {
|
|
||||||
k_state.current_view = Views::Partition(part_stage);
|
|
||||||
}
|
|
||||||
Err(ex) => {
|
|
||||||
log::error!("Error, cannot init partition stage: {}", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
_ => Task::none(),
|
_ => Task::none(),
|
||||||
|
|||||||
Reference in New Issue
Block a user