desktop: Made upgrade_to_https Option

This commit is contained in:
Nathan Adams 2024-04-24 23:29:47 +02:00
parent 1771e09e5e
commit f748dd747d
3 changed files with 21 additions and 9 deletions

View File

@ -9,7 +9,6 @@ spoof-swf-url = Spoof SWF URL
proxy = Proxy
upgrade-http = Upgrade HTTP to HTTPS
upgrade-http-check = Upgrade
tcp-connections = TCP Connections
tcp-connections-allow = Allow
@ -73,4 +72,3 @@ custom-framerate = Custom Framerate
custom-framerate-suffix = {" "} fps
dummy-external-interface = Dummy External Interface
dummy-external-interface-enable = Enable

View File

@ -40,6 +40,7 @@ pub struct OpenDialog {
player_version: OptionalField<NumberField<u8>>,
player_runtime: OptionalField<EnumDropdownField<PlayerRuntime>>,
dummy_external_interface: OptionalField<BooleanDropdownField>,
upgrade_to_https: OptionalField<BooleanDropdownField>,
}
impl OpenDialog {
@ -223,6 +224,16 @@ impl OpenDialog {
}),
),
);
let upgrade_to_https = OptionalField::new(
defaults.upgrade_to_https,
BooleanDropdownField::new(
false,
Box::new(|value, locale| match value {
true => text(locale, "enable"),
false => text(locale, "disable"),
}),
),
);
Self {
options: defaults,
@ -243,6 +254,7 @@ impl OpenDialog {
player_version,
player_runtime,
dummy_external_interface,
upgrade_to_https,
}
}
@ -347,10 +359,8 @@ impl OpenDialog {
ui.end_row();
ui.label(text(locale, "upgrade-http"));
ui.checkbox(
&mut self.options.upgrade_to_https,
text(locale, "upgrade-http-check"),
);
self.upgrade_to_https
.ui(ui, &mut self.options.upgrade_to_https, locale);
ui.end_row();
ui.label(text(locale, "tcp-connections"));

View File

@ -48,7 +48,7 @@ pub struct LaunchOptions {
pub proxy: Option<Url>,
pub socket_allowed: HashSet<String>,
pub tcp_connections: Option<SocketMode>,
pub upgrade_to_https: bool,
pub upgrade_to_https: Option<bool>,
pub fullscreen: bool,
pub load_behavior: Option<LoadBehavior>,
pub save_directory: PathBuf,
@ -83,7 +83,11 @@ impl From<&GlobalPreferences> for LaunchOptions {
None
},
proxy: value.cli.proxy.clone(),
upgrade_to_https: value.cli.upgrade_to_https,
upgrade_to_https: if value.cli.upgrade_to_https {
Some(true)
} else {
None
},
fullscreen: value.cli.fullscreen,
load_behavior: value.cli.load_behavior,
save_directory: value.cli.save_directory.clone(),
@ -182,7 +186,7 @@ impl ActivePlayer {
opt.base.to_owned().unwrap_or_else(|| movie_url.clone()),
future_spawner,
opt.proxy.clone(),
opt.upgrade_to_https,
opt.upgrade_to_https.unwrap_or_default(),
opt.open_url_mode,
opt.socket_allowed.clone(),
opt.tcp_connections.unwrap_or(SocketMode::Ask),