default configs to zeros when not exists

This commit is contained in:
Salem Yaslem 2024-12-04 22:43:06 +03:00
parent 58ed310a2b
commit 7f036c2049

View File

@ -170,7 +170,7 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
format_chooser_combobox.append(Some("avi"), &get_bundle("avi-format", None));
format_chooser_combobox.append(Some("wmv"), &get_bundle("wmv-format", None));
format_chooser_combobox.append(Some("nut"), &get_bundle("nut-format", None));
format_chooser_combobox.set_active(Some(config_management::get("default", "format").parse::<u32>().unwrap()));
format_chooser_combobox.set_active(Some(config_management::get("default", "format").parse::<u32>().unwrap_or(0u32)));
// Get audio sources
let input_device = host_audio_device.input_devices().unwrap();
@ -373,17 +373,17 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
("frame-{}",
&format_chooser_combobox.active().unwrap().to_string()))
.parse::<f64>()
.unwrap(),
.unwrap_or(0f64),
);
audio_bitrate_spin.set_value(
config_management::get("default", "audiobitrate")
.parse::<f64>()
.unwrap(),
.unwrap_or(0f64),
);
delay_spin.set_value(
config_management::get("default", "delay")
.parse::<f64>()
.unwrap(),
.unwrap_or(0f64),
);
video_bitrate_spin.set_value(
config_management::get("default",
@ -391,7 +391,7 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
("videobitrate-{}",
&format_chooser_combobox.active().unwrap().to_string()))
.parse::<f64>()
.unwrap(),
.unwrap_or(0f64),
);
let _format_chooser_combobox = format_chooser_combobox.clone();
@ -411,7 +411,7 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
("frame-{}",
&format_chooser_combobox.active().unwrap().to_string()))
.parse::<f64>()
.unwrap(),
.unwrap_or(0f64),
);
_video_bitrate_spin.set_value(
config_management::get("default",
@ -419,7 +419,7 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
("videobitrate-{}",
&format_chooser_combobox.active().unwrap().to_string()))
.parse::<f64>()
.unwrap(),
.unwrap_or(0f64),
);
}
});