diff --git a/src/stages/partition/mod.rs b/src/stages/partition/mod.rs index fcef97b..c97bdcd 100644 --- a/src/stages/partition/mod.rs +++ b/src/stages/partition/mod.rs @@ -68,6 +68,8 @@ fn part_type_to_color(t: &FSType) -> Color { } } +/// Converts PartInfo into data for ColorBar widget +/// fn part_to_ct_params(part: &PartInfo, dev_size: KiraSize) -> (String, u16, Color) { let fill_ratio: u16 = ((part.size.b() as f32 / dev_size.b() as f32) * 11.0) as u16; let fill_ratio = fill_ratio.max(1); @@ -82,6 +84,7 @@ pub struct PartitionStage { swap_mode: Option, use_zram: bool, secure_boot: bool, + encrypt_drive: bool, secure_boot_in_setup_mode: bool, custom_swap_size_mb: u32, custom_swap_size_str: String, @@ -97,6 +100,7 @@ pub enum Message { SelectSwapMode(SwapMode), ToggleZram(bool), ToggleSecureBoot(bool), + ToggleEncrypDrive(bool), SwapSizeFieldChange(String), SwapSizeIncrement, SwapSizeDecrement, @@ -152,6 +156,7 @@ impl PartitionStage { swap_mode: Some(SwapMode::SwapNoHibernate), use_zram: true, secure_boot: false, + encrypt_drive: false, secure_boot_in_setup_mode: sec_boot_setup, custom_swap_size_mb: 1024, custom_swap_size_str: "1024MB".into(), @@ -233,6 +238,7 @@ impl PartitionStage { .add_val_u64("swap_size_mb", swap_size.mb()) .add_val_bool("use_zram", self.use_zram) .add_val_bool("secure_boot", self.secure_boot) + .add_val_bool("encrypt_drive", self.encrypt_drive) } pub fn update(&mut self, message: Message) -> StageAction { @@ -255,7 +261,7 @@ impl PartitionStage { let swap_size: KiraSize = self.get_swap_size(); self.generated_disk_parts = Some( - PartLayout::gen_classic_layout(dev.clone(), KiraSize::new_mb(512), swap_size) + PartLayout::gen_classic_layout(dev.clone(), KiraSize::new_mb(128), swap_size) .part_list .iter() .map(|part_info| part_to_ct_params(part_info, dev.size)) @@ -274,6 +280,10 @@ impl PartitionStage { self.secure_boot = t; StageAction::None }, + Message::ToggleEncrypDrive(t) => { + self.encrypt_drive = t; + StageAction::None + }, Message::ToggleZram(t) => { self.use_zram = t; self.gen_layout(); @@ -376,6 +386,10 @@ impl PartitionStage { widget::rule::horizontal(2), use_sec_boot_checkbox, widget::rule::horizontal(2), + widget::checkbox(self.encrypt_drive) + .label(t!("partition.encrypt_drive")) + .on_toggle(Message::ToggleEncrypDrive), + widget::rule::horizontal(2), selected_dev_content, dev_parts_content, ]