Changes to partition stage in respect to intall stage.

This commit is contained in:
2026-06-06 00:27:55 +02:00
parent 4d8c9540d0
commit ed6ffcdee1
+15 -1
View File
@@ -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) { 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: u16 = ((part.size.b() as f32 / dev_size.b() as f32) * 11.0) as u16;
let fill_ratio = fill_ratio.max(1); let fill_ratio = fill_ratio.max(1);
@@ -82,6 +84,7 @@ pub struct PartitionStage {
swap_mode: Option<SwapMode>, swap_mode: Option<SwapMode>,
use_zram: bool, use_zram: bool,
secure_boot: bool, secure_boot: bool,
encrypt_drive: bool,
secure_boot_in_setup_mode: bool, secure_boot_in_setup_mode: bool,
custom_swap_size_mb: u32, custom_swap_size_mb: u32,
custom_swap_size_str: String, custom_swap_size_str: String,
@@ -97,6 +100,7 @@ pub enum Message {
SelectSwapMode(SwapMode), SelectSwapMode(SwapMode),
ToggleZram(bool), ToggleZram(bool),
ToggleSecureBoot(bool), ToggleSecureBoot(bool),
ToggleEncrypDrive(bool),
SwapSizeFieldChange(String), SwapSizeFieldChange(String),
SwapSizeIncrement, SwapSizeIncrement,
SwapSizeDecrement, SwapSizeDecrement,
@@ -152,6 +156,7 @@ impl PartitionStage {
swap_mode: Some(SwapMode::SwapNoHibernate), swap_mode: Some(SwapMode::SwapNoHibernate),
use_zram: true, use_zram: true,
secure_boot: false, secure_boot: false,
encrypt_drive: false,
secure_boot_in_setup_mode: sec_boot_setup, secure_boot_in_setup_mode: sec_boot_setup,
custom_swap_size_mb: 1024, custom_swap_size_mb: 1024,
custom_swap_size_str: "1024MB".into(), custom_swap_size_str: "1024MB".into(),
@@ -233,6 +238,7 @@ impl PartitionStage {
.add_val_u64("swap_size_mb", swap_size.mb()) .add_val_u64("swap_size_mb", swap_size.mb())
.add_val_bool("use_zram", self.use_zram) .add_val_bool("use_zram", self.use_zram)
.add_val_bool("secure_boot", self.secure_boot) .add_val_bool("secure_boot", self.secure_boot)
.add_val_bool("encrypt_drive", self.encrypt_drive)
} }
pub fn update(&mut self, message: Message) -> StageAction { pub fn update(&mut self, message: Message) -> StageAction {
@@ -255,7 +261,7 @@ impl PartitionStage {
let swap_size: KiraSize = self.get_swap_size(); let swap_size: KiraSize = self.get_swap_size();
self.generated_disk_parts = Some( 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 .part_list
.iter() .iter()
.map(|part_info| part_to_ct_params(part_info, dev.size)) .map(|part_info| part_to_ct_params(part_info, dev.size))
@@ -274,6 +280,10 @@ impl PartitionStage {
self.secure_boot = t; self.secure_boot = t;
StageAction::None StageAction::None
}, },
Message::ToggleEncrypDrive(t) => {
self.encrypt_drive = t;
StageAction::None
},
Message::ToggleZram(t) => { Message::ToggleZram(t) => {
self.use_zram = t; self.use_zram = t;
self.gen_layout(); self.gen_layout();
@@ -376,6 +386,10 @@ impl PartitionStage {
widget::rule::horizontal(2), widget::rule::horizontal(2),
use_sec_boot_checkbox, use_sec_boot_checkbox,
widget::rule::horizontal(2), 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, selected_dev_content,
dev_parts_content, dev_parts_content,
] ]