diff --git a/Cargo.toml b/Cargo.toml index 29881ae..b3ba8aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ gettext-rs = { version = "0.7.0", features = ["gettext-system"] } git2 = "0.19.0" gtk4 = { version = "0.9.0", features = ["v4_10"] } lazy_static = "1.5.0" -libadwaita = { version = "0.7.0", features = ["v1_4"] } +libadwaita = { version = "0.7.0", features = ["v1_5"] } libmonado-rs = { git = "https://github.com/technobaboo/libmonado-rs" } rusb = "0.9.4" nix = { version = "0.29.0", features = ["fs", "signal"] } diff --git a/src/ui/app.rs b/src/ui/app.rs index 93e64a5..53ef02f 100644 --- a/src/ui/app.rs +++ b/src/ui/app.rs @@ -42,7 +42,7 @@ use crate::stateless_action; use crate::steam_linux_runtime_injector::{ restore_runtime_entrypoint, set_runtime_entrypoint_launch_opts_from_profile, }; -use crate::ui::build_window::{BuildWindowMsg, BuildWindowOutMsg}; +use crate::ui::build_window::{BuildWindowInit, BuildWindowMsg, BuildWindowOutMsg}; use crate::ui::debug_view::{DebugViewInit, DebugViewOutMsg}; use crate::ui::libsurvive_setup_window::LibsurviveSetupMsg; use crate::ui::main_view::{MainView, MainViewInit, MainViewOutMsg}; @@ -935,8 +935,9 @@ impl SimpleComponent for App { .launch(()) .detach(), build_window: BuildWindow::builder() - .transient_for(&root) - .launch(()) + .launch(BuildWindowInit { + parent: root.clone().upcast(), + }) .forward(sender.input_sender(), |msg| match msg { BuildWindowOutMsg::CancelBuild => Msg::CancelBuild, }), diff --git a/src/ui/build_window.rs b/src/ui/build_window.rs index 5aa1809..492e6cb 100644 --- a/src/ui/build_window.rs +++ b/src/ui/build_window.rs @@ -1,7 +1,6 @@ -use crate::ui::SENDER_IO_ERR_MSG; - use super::term_widget::TermWidget; -use gtk::prelude::*; +use crate::ui::SENDER_IO_ERR_MSG; +use adw::prelude::*; use relm4::prelude::*; #[derive(Debug, PartialEq, Eq, Clone)] @@ -18,11 +17,13 @@ pub struct BuildWindow { build_status: BuildStatus, #[tracker::do_not_track] - pub win: Option, + pub win: Option, #[tracker::do_not_track] build_status_label: Option, #[tracker::do_not_track] term: TermWidget, + #[tracker::do_not_track] + parent: gtk::Widget, } #[derive(Debug)] @@ -39,19 +40,27 @@ pub enum BuildWindowOutMsg { CancelBuild, } +#[derive(Debug)] +pub struct BuildWindowInit { + pub parent: gtk::Widget, +} + #[relm4::component(pub)] impl SimpleComponent for BuildWindow { - type Init = (); + type Init = BuildWindowInit; type Input = BuildWindowMsg; type Output = BuildWindowOutMsg; view! { #[name(win)] - adw::Window { - set_modal: true, - set_default_size: (520, 400), - set_hide_on_close: true, - adw::ToolbarView { + adw::Dialog { + set_presentation_mode: adw::DialogPresentationMode::BottomSheet, + set_content_height: 2000, + set_content_width: 1000, + #[track = "model.changed(BuildWindow::can_close())"] + set_can_close: model.can_close, + #[wrap(Some)] + set_child: tbview = &adw::ToolbarView { set_top_bar_style: adw::ToolbarStyle::Flat, set_bottom_bar_style: adw::ToolbarStyle::Flat, set_vexpand: true, @@ -129,7 +138,7 @@ impl SimpleComponent for BuildWindow { self.term.set_color_scheme(); sender.input(BuildWindowMsg::UpdateBuildStatus(BuildStatus::Building)); self.term.clear(); - self.win.as_ref().unwrap().present(); + self.win.as_ref().unwrap().present(Some(&self.parent)); } Self::Input::UpdateTitle(t) => { self.set_title(t); @@ -161,7 +170,7 @@ impl SimpleComponent for BuildWindow { } fn init( - _init: Self::Init, + init: Self::Init, root: Self::Root, sender: ComponentSender, ) -> ComponentParts { @@ -172,6 +181,7 @@ impl SimpleComponent for BuildWindow { build_status: BuildStatus::Building, win: None, build_status_label: None, + parent: init.parent, term: { let t = TermWidget::new(); t.container.add_css_class("card"); diff --git a/src/ui/profile_editor.rs b/src/ui/profile_editor.rs index 2be89c7..6e11198 100644 --- a/src/ui/profile_editor.rs +++ b/src/ui/profile_editor.rs @@ -19,11 +19,13 @@ use std::{cell::RefCell, path::PathBuf, rc::Rc}; pub struct ProfileEditor { profile: Rc>, #[tracker::do_not_track] - win: Option, + win: Option, #[tracker::do_not_track] env_rows: AsyncFactoryVecDeque, #[tracker::do_not_track] xrservice_cmake_flags_rows: AsyncFactoryVecDeque, + #[tracker::do_not_track] + parent: gtk::Window, } #[derive(Debug)] @@ -56,14 +58,12 @@ impl SimpleComponent for ProfileEditor { view! { #[name(win)] - adw::Window { - set_modal: true, - set_transient_for: Some(&init.root_win), + adw::Dialog { #[track = "model.changed(Self::profile())"] - set_title: Some(model.profile.borrow().name.as_str()), - set_default_height: 500, - set_default_width: 600, - adw::ToolbarView { + set_title: model.profile.borrow().name.as_str(), + set_follows_content_size: true, + #[wrap(Some)] + set_child: tbview = &adw::ToolbarView { set_top_bar_style: adw::ToolbarStyle::Flat, set_hexpand: true, set_vexpand: true, @@ -354,7 +354,7 @@ impl SimpleComponent for ProfileEditor { match message { Self::Input::Present => { - self.win.as_ref().unwrap().present(); + self.win.as_ref().unwrap().present(Some(&self.parent)); } Self::Input::SaveProfile => { let prof = self.profile.borrow(); @@ -367,7 +367,7 @@ impl SimpleComponent for ProfileEditor { alert( "Profile validation failed", Some("Check the values you set and try again"), - Some(&self.win.as_ref().unwrap().clone().upcast::()), + Some(&self.parent), ); } } @@ -534,6 +534,7 @@ impl SimpleComponent for ProfileEditor { ProfileEditorMsg::XrServiceCmakeFlagsDelete(name) } }), + parent: init.root_win.clone(), tracker: 0, }; { diff --git a/src/ui/wivrn_conf_editor.rs b/src/ui/wivrn_conf_editor.rs index 6c7027a..9b5aaf4 100644 --- a/src/ui/wivrn_conf_editor.rs +++ b/src/ui/wivrn_conf_editor.rs @@ -25,7 +25,7 @@ use relm4::{factory::AsyncFactoryVecDeque, prelude::*}; pub struct WivrnConfEditor { conf: WivrnConfig, #[tracker::do_not_track] - win: Option, + win: Option, #[tracker::do_not_track] pub encoder_models: Option>, #[tracker::do_not_track] @@ -36,6 +36,8 @@ pub struct WivrnConfEditor { bitrate_row: Option, #[tracker::do_not_track] wivrn_encoder_presets_win: Option>, + #[tracker::do_not_track] + parent: gtk::Window, } #[derive(Debug)] @@ -61,13 +63,10 @@ impl SimpleComponent for WivrnConfEditor { view! { #[name(win)] - adw::Window { - set_modal: true, - set_transient_for: Some(&init.root_win), - set_title: Some("WiVRn Configuration"), - set_default_height: 500, - set_default_width: 600, - adw::ToolbarView { + adw::Dialog { + set_title: "WiVRn Configuration", + #[wrap(Some)] + set_child: tbview = &adw::ToolbarView { set_top_bar_style: adw::ToolbarStyle::Flat, set_hexpand: true, set_vexpand: true, @@ -185,7 +184,7 @@ impl SimpleComponent for WivrnConfEditor { match message { Self::Input::Present => { self.set_conf(get_wivrn_config()); - self.win.as_ref().unwrap().present(); + self.win.as_ref().unwrap().present(Some(&self.parent)); } Self::Input::OpenEncoderPresetsWin => { self.wivrn_encoder_presets_win @@ -269,6 +268,7 @@ impl SimpleComponent for WivrnConfEditor { scaley_row: None, bitrate_row: None, wivrn_encoder_presets_win: None, + parent: init.root_win, tracker: 0, }; diff --git a/src/ui/wivrn_encoder_presets_win.rs b/src/ui/wivrn_encoder_presets_win.rs index 9608504..48f8b16 100644 --- a/src/ui/wivrn_encoder_presets_win.rs +++ b/src/ui/wivrn_encoder_presets_win.rs @@ -7,9 +7,9 @@ use crate::file_builders::{ use super::SENDER_IO_ERR_MSG; -#[tracker::track] pub struct WivrnEncoderPresetsWin { - win: Option, + win: Option, + parent: gtk::Widget, } #[derive(Debug)] @@ -24,7 +24,7 @@ pub enum WivrnEncoderPresetsWinOutMsg { } pub struct WivrnEncoderPresetsWinInit { - pub parent_win: gtk::Window, + pub parent_win: gtk::Widget, } #[relm4::component(pub)] @@ -35,14 +35,11 @@ impl SimpleComponent for WivrnEncoderPresetsWin { view! { #[name(win)] - adw::Window { - set_modal: true, - set_hide_on_close: true, - set_transient_for: Some(&init.parent_win), - set_title: Some("WiVRn Encoder Presets"), - set_default_height: 400, - set_default_width: 300, - adw::ToolbarView { + adw::Dialog { + set_title: "WiVRn Encoder Presets", + set_presentation_mode: adw::DialogPresentationMode::BottomSheet, + #[wrap(Some)] + set_child: tbview = &adw::ToolbarView { set_top_bar_style: adw::ToolbarStyle::Flat, set_hexpand: true, set_vexpand: true, @@ -52,20 +49,16 @@ impl SimpleComponent for WivrnEncoderPresetsWin { #[wrap(Some)] set_content: prefpage = &adw::PreferencesPage { set_title: "Encoder Presets", - add: prefgrp = &adw::PreferencesGroup { - - } + add: prefgrp = &adw::PreferencesGroup {} } }, } } fn update(&mut self, message: Self::Input, sender: ComponentSender) { - self.reset(); - match message { Self::Input::Present => { - self.win.as_ref().unwrap().present(); + self.win.as_ref().unwrap().present(Some(&self.parent)); } Self::Input::Selected(preset) => { sender @@ -83,7 +76,7 @@ impl SimpleComponent for WivrnEncoderPresetsWin { ) -> ComponentParts { let mut model = Self { win: None, - tracker: 0, + parent: init.parent_win, }; let widgets = view_output!();