1mod welcome;
4pub use welcome::WelcomePage;
5
6mod install_dir;
7pub use install_dir::InstallDirPage;
8
9mod eula;
10pub use eula::{EulaPage, EulaTxt};
11
12mod status;
13pub use status::{StatusPage, StatusTaskInfoFnArgs};
14
15mod finish;
16pub use finish::{FinishAction, FinishPage};
17
18mod failed;
19pub use failed::{FailedPage, FailedTaskInfoFnArgs};
20
21use zng_ext_l10n::l10n;
22use zng_ext_setup::task::{SetupTask, TaskTypeId};
23use zng_wgt::prelude::*;
24
25use crate::{SETUP_OP_VAR, SetupOp};
26
27#[derive(Clone, Debug, PartialEq)]
29#[non_exhaustive]
30pub struct TaskInfo {
31 pub id: (TaskTypeId, Txt),
33
34 pub info: VarEq<Txt>,
36}
37impl TaskInfo {
38 pub fn new(task_type_id: impl Into<TaskTypeId>, task_instance_name: impl Into<Txt>, info: impl IntoVar<Txt>) -> Self {
40 Self {
41 id: (task_type_id.into(), task_instance_name.into()),
42 info: VarEq(info.into_var()),
43 }
44 }
45
46 pub fn try_from_type(task_type_id: impl Into<TaskTypeId>, task_instance_name: impl Into<Txt>) -> Option<Self> {
48 Self::try_from_ty_impl((task_type_id.into(), task_instance_name.into()))
49 }
50 fn try_from_ty_impl(id: (TaskTypeId, Txt)) -> Option<Self> {
51 if id.0 == zng_ext_setup::task::ExtractTar::task_type_id() || id.0 == zng_ext_setup::task::CopyCurrentExe::task_type_id() {
52 let info = SETUP_OP_VAR.flat_map(|op| match op {
53 SetupOp::Install | SetupOp::Update | SetupOp::Repair => l10n!("status/default-info.extract-files", "Extract files"),
54 SetupOp::Uninstall => l10n!("status/default-info.remove-files", "Remove files"),
55 });
56 return Some(TaskInfo { id, info: VarEq(info) });
57 }
58
59 #[cfg(any(windows, target_os = "linux"))]
60 if id.0 == zng_ext_setup::task::CreateShortcut::task_type_id() {
61 let info = SETUP_OP_VAR.flat_map(|op| match op {
62 SetupOp::Install | SetupOp::Update | SetupOp::Repair => l10n!("status/default-info.create-shortcut", "Create shortcut"),
63 SetupOp::Uninstall => l10n!("status/default-info.remove-shortcut", "Remove shortcut"),
64 });
65 return Some(TaskInfo { id, info: VarEq(info) });
66 }
67
68 #[cfg(windows)]
69 if id.0 == zng_ext_setup::task::RegisterUninstaller::task_type_id() {
70 let info = SETUP_OP_VAR.flat_map(|op| match op {
71 SetupOp::Install | SetupOp::Update | SetupOp::Repair => {
72 l10n!("status/default-info.register-uninstaller", "Register uninstaller")
73 }
74 SetupOp::Uninstall => l10n!("status/default-info.unregister-uninstaller", "Unregister uninstaller"),
75 });
76 return Some(TaskInfo { id, info: VarEq(info) });
77 }
78
79 None
80 }
81}