mirror of
https://github.com/an-anime-team/sleepy-launcher.git
synced 2025-03-15 06:28:27 +03:00
feat(ui): added blank components downloading page to first run window
As well were experimentally changed buttons styles to "pills" (large'n'round). Maybe I'll revert this change later
This commit is contained in:
parent
4f560eaa5e
commit
cd3614df83
11 changed files with 179 additions and 10 deletions
|
@ -31,7 +31,6 @@ impl SimpleAsyncComponent for ComponentGroup {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::redundant_clone)]
|
||||
async fn init(
|
||||
init: Self::Init,
|
||||
root: Self::Root,
|
||||
|
|
|
@ -34,7 +34,6 @@ impl<T: std::fmt::Debug + Clone + 'static> SimpleAsyncComponent for ComponentsLi
|
|||
group = adw::PreferencesGroup {}
|
||||
}
|
||||
|
||||
#[allow(clippy::redundant_clone)]
|
||||
async fn init(
|
||||
init: Self::Init,
|
||||
root: Self::Root,
|
||||
|
|
|
@ -50,7 +50,6 @@ pub enum AppMsg {
|
|||
|
||||
#[relm4::component(async, pub)]
|
||||
impl SimpleAsyncComponent for ProgressBar {
|
||||
/// (caption, display_progress, display_fraction, visible)
|
||||
type Init = ProgressBarInit;
|
||||
type Input = AppMsg;
|
||||
type Output = ();
|
||||
|
@ -89,7 +88,6 @@ impl SimpleAsyncComponent for ProgressBar {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::redundant_clone)]
|
||||
async fn init(
|
||||
init: Self::Init,
|
||||
root: Self::Root,
|
||||
|
|
|
@ -74,7 +74,6 @@ impl SimpleAsyncComponent for ComponentVersion {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::redundant_clone)]
|
||||
async fn init(
|
||||
init: Self::Init,
|
||||
root: Self::Root,
|
||||
|
|
|
@ -176,13 +176,14 @@ impl SimpleAsyncComponent for DefaultPathsApp {
|
|||
|
||||
gtk::Button {
|
||||
set_label: "Continue",
|
||||
add_css_class: "suggested-action",
|
||||
set_css_classes: &["suggested-action", "pill"],
|
||||
|
||||
connect_clicked => DefaultPathsAppMsg::Continue
|
||||
},
|
||||
|
||||
gtk::Button {
|
||||
set_label: "Exit",
|
||||
add_css_class: "pill",
|
||||
|
||||
connect_clicked => DefaultPathsAppMsg::Exit
|
||||
}
|
||||
|
|
|
@ -120,13 +120,14 @@ impl SimpleAsyncComponent for DependenciesApp {
|
|||
|
||||
gtk::Button {
|
||||
set_label: "Check",
|
||||
add_css_class: "suggested-action",
|
||||
set_css_classes: &["suggested-action", "pill"],
|
||||
|
||||
connect_clicked => DependenciesAppMsg::Continue
|
||||
},
|
||||
|
||||
gtk::Button {
|
||||
set_label: "Exit",
|
||||
add_css_class: "pill",
|
||||
|
||||
connect_clicked => DependenciesAppMsg::Exit
|
||||
}
|
||||
|
|
163
src/ui/first_run/download_components.rs
Normal file
163
src/ui/first_run/download_components.rs
Normal file
|
@ -0,0 +1,163 @@
|
|||
use relm4::prelude::*;
|
||||
use relm4::component::*;
|
||||
|
||||
use adw::prelude::*;
|
||||
|
||||
use anime_launcher_sdk::components::wine;
|
||||
use anime_launcher_sdk::components::dxvk;
|
||||
|
||||
use super::main::FirstRunAppMsg;
|
||||
use crate::ui::components::*;
|
||||
|
||||
pub struct DownloadComponentsApp {
|
||||
progress_bar: AsyncController<ProgressBar>,
|
||||
|
||||
wine_versions: Vec<wine::Version>,
|
||||
dxvk_versions: Vec<dxvk::Version>,
|
||||
|
||||
downloading: bool
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum DownloadComponentsAppMsg {
|
||||
Download,
|
||||
Exit
|
||||
}
|
||||
|
||||
#[relm4::component(async, pub)]
|
||||
impl SimpleAsyncComponent for DownloadComponentsApp {
|
||||
type Init = ();
|
||||
type Input = DownloadComponentsAppMsg;
|
||||
type Output = FirstRunAppMsg;
|
||||
|
||||
view! {
|
||||
adw::PreferencesPage {
|
||||
set_hexpand: true,
|
||||
|
||||
add = &adw::PreferencesGroup {
|
||||
gtk::Label {
|
||||
set_label: "Download components",
|
||||
set_margin_top: 16,
|
||||
add_css_class: "title-1"
|
||||
}
|
||||
},
|
||||
|
||||
add = &adw::PreferencesGroup {
|
||||
set_valign: gtk::Align::Center,
|
||||
set_vexpand: true,
|
||||
|
||||
#[watch]
|
||||
set_visible: !model.downloading,
|
||||
|
||||
adw::ComboRow {
|
||||
set_title: "Wine version",
|
||||
|
||||
#[watch]
|
||||
set_model: Some(>k::StringList::new(model.wine_versions.iter()
|
||||
.map(|version| version.title.as_ref())
|
||||
.collect::<Vec<&str>>()
|
||||
.as_slice()))
|
||||
},
|
||||
|
||||
adw::ComboRow {
|
||||
set_title: "DXVK version",
|
||||
|
||||
#[watch]
|
||||
set_model: Some(>k::StringList::new(model.dxvk_versions.iter()
|
||||
.map(|version| version.version.as_ref())
|
||||
.collect::<Vec<&str>>()
|
||||
.as_slice()))
|
||||
}
|
||||
},
|
||||
|
||||
add = &adw::PreferencesGroup {
|
||||
set_valign: gtk::Align::Center,
|
||||
set_vexpand: true,
|
||||
|
||||
#[watch]
|
||||
set_visible: !model.downloading,
|
||||
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Horizontal,
|
||||
set_halign: gtk::Align::Center,
|
||||
set_spacing: 8,
|
||||
|
||||
gtk::Button {
|
||||
set_label: "Download",
|
||||
set_css_classes: &["suggested-action", "pill"],
|
||||
|
||||
connect_clicked => DownloadComponentsAppMsg::Download
|
||||
},
|
||||
|
||||
gtk::Button {
|
||||
set_label: "Exit",
|
||||
add_css_class: "pill",
|
||||
|
||||
connect_clicked => DownloadComponentsAppMsg::Exit
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
add = &adw::PreferencesGroup {
|
||||
set_valign: gtk::Align::Center,
|
||||
set_vexpand: true,
|
||||
|
||||
#[watch]
|
||||
set_visible: model.downloading,
|
||||
|
||||
gtk::Box {
|
||||
set_orientation: gtk::Orientation::Horizontal,
|
||||
set_halign: gtk::Align::Center,
|
||||
set_spacing: 20,
|
||||
set_margin_top: 64,
|
||||
|
||||
append = model.progress_bar.widget(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn init(
|
||||
_init: Self::Init,
|
||||
root: Self::Root,
|
||||
_sender: AsyncComponentSender<Self>,
|
||||
) -> AsyncComponentParts<Self> {
|
||||
let model = Self {
|
||||
progress_bar: ProgressBar::builder()
|
||||
.launch(ProgressBarInit {
|
||||
caption: None,
|
||||
display_progress: true,
|
||||
display_fraction: true,
|
||||
visible: true
|
||||
})
|
||||
.detach(),
|
||||
|
||||
wine_versions: wine::get_groups()[0].versions.clone().into_iter().filter(|version| version.recommended).collect(),
|
||||
dxvk_versions: dxvk::get_groups()[0].versions.clone().into_iter().filter(|version| version.recommended).collect(),
|
||||
|
||||
downloading: false
|
||||
};
|
||||
|
||||
model.progress_bar.widget().set_width_request(360);
|
||||
|
||||
let widgets = view_output!();
|
||||
|
||||
AsyncComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
async fn update(&mut self, msg: Self::Input, sender: AsyncComponentSender<Self>) {
|
||||
match msg {
|
||||
#[allow(unused_must_use)]
|
||||
DownloadComponentsAppMsg::Download => {
|
||||
self.downloading = true;
|
||||
|
||||
// sender.output(Self::Output::ScrollToChooseVoiceovers);
|
||||
}
|
||||
|
||||
DownloadComponentsAppMsg::Exit => {
|
||||
// TODO: relm4 has some function for it
|
||||
std::process::exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ use super::welcome::*;
|
|||
use super::tos_warning::*;
|
||||
use super::dependencies::*;
|
||||
use super::default_paths::*;
|
||||
use super::download_components::*;
|
||||
|
||||
pub static mut MAIN_WINDOW: Option<adw::Window> = None;
|
||||
|
||||
|
@ -18,6 +19,7 @@ pub struct FirstRunApp {
|
|||
tos_warning: AsyncController<TosWarningApp>,
|
||||
dependencies: AsyncController<DependenciesApp>,
|
||||
default_paths: AsyncController<DefaultPathsApp>,
|
||||
download_components: AsyncController<DownloadComponentsApp>,
|
||||
|
||||
toast_overlay: adw::ToastOverlay,
|
||||
carousel: adw::Carousel,
|
||||
|
@ -70,6 +72,7 @@ impl SimpleComponent for FirstRunApp {
|
|||
append = model.tos_warning.widget(),
|
||||
append = model.dependencies.widget(),
|
||||
append = model.default_paths.widget(),
|
||||
append = model.download_components.widget(),
|
||||
},
|
||||
|
||||
adw::CarouselIndicatorDots {
|
||||
|
@ -108,6 +111,10 @@ impl SimpleComponent for FirstRunApp {
|
|||
.launch(())
|
||||
.forward(sender.input_sender(), std::convert::identity),
|
||||
|
||||
download_components: DownloadComponentsApp::builder()
|
||||
.launch(())
|
||||
.forward(sender.input_sender(), std::convert::identity),
|
||||
|
||||
toast_overlay,
|
||||
carousel,
|
||||
|
||||
|
@ -151,7 +158,7 @@ impl SimpleComponent for FirstRunApp {
|
|||
FirstRunAppMsg::ScrollToDownloadComponents => {
|
||||
self.title = String::from("Download components");
|
||||
|
||||
self.carousel.scroll_to(self.welcome.widget(), true);
|
||||
self.carousel.scroll_to(self.download_components.widget(), true);
|
||||
}
|
||||
|
||||
FirstRunAppMsg::ScrollToChooseVoiceovers => {
|
||||
|
|
|
@ -3,3 +3,4 @@ pub mod welcome;
|
|||
pub mod tos_warning;
|
||||
pub mod dependencies;
|
||||
pub mod default_paths;
|
||||
pub mod download_components;
|
||||
|
|
|
@ -102,13 +102,14 @@ impl SimpleAsyncComponent for TosWarningApp {
|
|||
|
||||
gtk::Button {
|
||||
set_label: "Continue",
|
||||
add_css_class: "suggested-action",
|
||||
set_css_classes: &["suggested-action", "pill"],
|
||||
|
||||
connect_clicked => TosWarningAppMsg::Continue
|
||||
},
|
||||
|
||||
gtk::Button {
|
||||
set_label: "Exit",
|
||||
add_css_class: "pill",
|
||||
|
||||
connect_clicked => TosWarningAppMsg::Exit
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ impl SimpleAsyncComponent for WelcomeApp {
|
|||
|
||||
gtk::Button {
|
||||
set_label: "Continue",
|
||||
add_css_class: "suggested-action",
|
||||
set_css_classes: &["suggested-action", "pill"],
|
||||
|
||||
connect_clicked => WelcomeAppMsg::Continue
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue