mirror of https://github.com/wayvr-org/wayvr.git
skybox downloader: apply button for downloaded skymaps
This commit is contained in:
parent
90c4567505
commit
bf7276b2dd
|
|
@ -172,6 +172,7 @@
|
||||||
"PROCESS_LIST": "Process list",
|
"PROCESS_LIST": "Process list",
|
||||||
"REFRESH": "Refresh",
|
"REFRESH": "Refresh",
|
||||||
"REMOVE": "Remove",
|
"REMOVE": "Remove",
|
||||||
|
"APPLY": "Apply",
|
||||||
"RELOAD_FROM_DISK": "Reload from disk",
|
"RELOAD_FROM_DISK": "Reload from disk",
|
||||||
"SETTINGS": "Settings",
|
"SETTINGS": "Settings",
|
||||||
"SHOW": "Show",
|
"SHOW": "Show",
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
views::{self, ViewTrait, ViewUpdateParams},
|
views::{self, ViewTrait, ViewUpdateParams},
|
||||||
};
|
};
|
||||||
|
use anyhow::Context;
|
||||||
use wgui::{
|
use wgui::{
|
||||||
assets::AssetPath,
|
assets::AssetPath,
|
||||||
components::button::ComponentButton,
|
components::button::ComponentButton,
|
||||||
|
|
@ -20,7 +21,7 @@ use wgui::{
|
||||||
task::Tasks,
|
task::Tasks,
|
||||||
widget::{image::WidgetImage, label::WidgetLabel},
|
widget::{image::WidgetImage, label::WidgetLabel},
|
||||||
};
|
};
|
||||||
use wlx_common::{async_executor::AsyncExecutor, config_io};
|
use wlx_common::{async_executor::AsyncExecutor, config_io, dash_interface::ConfigChangeKind};
|
||||||
|
|
||||||
pub struct Params<'a> {
|
pub struct Params<'a> {
|
||||||
pub globals: &'a WguiGlobals,
|
pub globals: &'a WguiGlobals,
|
||||||
|
|
@ -41,6 +42,7 @@ enum Task {
|
||||||
DownloadFinished,
|
DownloadFinished,
|
||||||
RunDownload(SkymapResolution),
|
RunDownload(SkymapResolution),
|
||||||
RemoveFile(SkymapResolution),
|
RemoveFile(SkymapResolution),
|
||||||
|
SetSkymap(SkymapResolution),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct View {
|
pub struct View {
|
||||||
|
|
@ -109,6 +111,19 @@ impl ViewTrait for View {
|
||||||
Task::RemoveFile(resolution) => {
|
Task::RemoveFile(resolution) => {
|
||||||
self.remove_file(resolution)?;
|
self.remove_file(resolution)?;
|
||||||
}
|
}
|
||||||
|
Task::SetSkymap(resolution) => {
|
||||||
|
let skymap_file_path = self
|
||||||
|
.entry
|
||||||
|
.get_destination_path(resolution)
|
||||||
|
.context("Skymap not found" /* you shouldn't really see this, like ever. */)?;
|
||||||
|
|
||||||
|
par.general_config.skybox_texture = config_io::get_skymaps_root()
|
||||||
|
.join(skymap_file_path)
|
||||||
|
.to_str()
|
||||||
|
.context("Skymap filename not valid UTF-8")?
|
||||||
|
.into();
|
||||||
|
*par.config_change_kind = Some(ConfigChangeKind::EnvironmentBlend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,6 +252,7 @@ impl View {
|
||||||
fn show_dialog_box_action(&mut self, resolution: SkymapResolution) -> anyhow::Result<()> {
|
fn show_dialog_box_action(&mut self, resolution: SkymapResolution) -> anyhow::Result<()> {
|
||||||
const ACTION_REMOVE: &'static str = "remove";
|
const ACTION_REMOVE: &'static str = "remove";
|
||||||
const ACTION_DOWNLOAD_AGAIN: &'static str = "download_again";
|
const ACTION_DOWNLOAD_AGAIN: &'static str = "download_again";
|
||||||
|
const ACTION_APPLY: &'static str = "apply";
|
||||||
|
|
||||||
let tasks = self.tasks.clone();
|
let tasks = self.tasks.clone();
|
||||||
|
|
||||||
|
|
@ -257,6 +273,11 @@ impl View {
|
||||||
icon: "dashboard/download.svg",
|
icon: "dashboard/download.svg",
|
||||||
action: ACTION_DOWNLOAD_AGAIN,
|
action: ACTION_DOWNLOAD_AGAIN,
|
||||||
},
|
},
|
||||||
|
views::dialog_box::ButtonEntry {
|
||||||
|
content: Translation::from_translation_key("APPLY"),
|
||||||
|
icon: "dashboard/check.svg",
|
||||||
|
action: ACTION_APPLY,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
on_action_click: Box::new(move |action| match action {
|
on_action_click: Box::new(move |action| match action {
|
||||||
ACTION_REMOVE => {
|
ACTION_REMOVE => {
|
||||||
|
|
@ -267,6 +288,10 @@ impl View {
|
||||||
tasks.push(Task::RunDownload(resolution));
|
tasks.push(Task::RunDownload(resolution));
|
||||||
tasks.push(Task::Refresh);
|
tasks.push(Task::Refresh);
|
||||||
}
|
}
|
||||||
|
ACTION_APPLY => {
|
||||||
|
tasks.push(Task::SetSkymap(resolution));
|
||||||
|
tasks.push(Task::Refresh);
|
||||||
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue