feat: hide wivrn configuration under the menu, enable/disable it depending on selected profile; update wivrn configuration doc link; add warning in wivrn config dialog

This commit is contained in:
Gabriele Musco 2024-07-22 13:15:20 +02:00
commit 2addb6ae63
3 changed files with 68 additions and 74 deletions

View file

@ -109,6 +109,8 @@ pub struct App {
#[tracker::do_not_track]
wivrn_appimage_warn_shown: bool,
#[tracker::do_not_track]
configure_wivrn_action: gtk::gio::SimpleAction,
}
#[derive(Debug)]
@ -659,6 +661,8 @@ impl SimpleComponent for App {
);
self.wivrn_appimage_warn_shown = true;
}
self.configure_wivrn_action
.set_enabled(prof.xrservice_type == XRServiceType::Wivrn);
if prof.uuid == self.config.selected_profile_uuid {
return;
}
@ -762,6 +766,64 @@ impl SimpleComponent for App {
});
}
let mut actions = RelmActionGroup::<AppActionGroup>::new();
stateless_action!(
actions,
BuildProfileAction,
clone!(@strong sender => move |_| {
sender.input_sender().emit(Msg::BuildProfile(false));
})
);
stateless_action!(
actions,
BuildProfileCleanAction,
clone!(@strong sender => move |_| {
sender.input_sender().emit(Msg::BuildProfile(true));
})
);
stateless_action!(
actions,
QuitAction,
clone!(@strong sender => move |_| {
sender.input(Msg::Quit);
})
);
stateless_action!(
actions,
DebugOpenDataAction,
clone!(@strong sender => move |_| {
sender.input(Msg::DebugOpenData);
})
);
stateless_action!(
actions,
DebugOpenPrefixAction,
clone!(@strong sender => move |_| {
sender.input(Msg::DebugOpenPrefix);
})
);
stateless_action!(
actions,
DebugCopyEnvVarsAction,
clone!(@strong sender => move |_| {
sender.input(Msg::DebugCopyEnvVars);
})
);
// this bypasses the macro because I need the underlying gio action
// to enable/disable it in update()
let configure_wivrn_action = {
let action = RelmAction::<ConfigureWivrnAction>::new_stateless(
clone!(@strong sender => move |_| {
sender.input(Msg::OpenWivrnConfig);
}),
);
let ret = action.gio_action().clone();
actions.add_action(action);
ret.set_enabled(false);
ret
};
let mut model = App {
tracker: 0,
application: init.application,
@ -780,7 +842,6 @@ impl SimpleComponent for App {
MainViewOutMsg::DeleteProfile => Msg::DeleteProfile,
MainViewOutMsg::SaveProfile(p) => Msg::SaveProfile(p),
MainViewOutMsg::OpenLibsurviveSetup => Msg::OpenLibsurviveSetup,
MainViewOutMsg::OpenWivrnConfig => Msg::OpenWivrnConfig,
}),
debug_view: DebugView::builder().launch(DebugViewInit {}).forward(
sender.input_sender(),
@ -816,59 +877,16 @@ impl SimpleComponent for App {
wivrn_conf_editor: None,
skip_depcheck: false,
wivrn_appimage_warn_shown: false,
configure_wivrn_action,
};
let widgets = view_output!();
let mut actions = RelmActionGroup::<AppActionGroup>::new();
stateless_action!(
actions,
BuildProfileAction,
clone!(@strong sender => move |_| {
sender.input_sender().emit(Msg::BuildProfile(false));
})
);
stateless_action!(
actions,
BuildProfileCleanAction,
clone!(@strong sender => move |_| {
sender.input_sender().emit(Msg::BuildProfile(true));
})
);
{
let abd_sender = model.about_dialog.sender().clone();
stateless_action!(actions, AboutAction, move |_| {
abd_sender.send(()).unwrap();
});
}
stateless_action!(
actions,
QuitAction,
clone!(@strong sender => move |_| {
sender.input(Msg::Quit);
})
);
stateless_action!(
actions,
DebugOpenDataAction,
clone!(@strong sender => move |_| {
sender.input(Msg::DebugOpenData);
})
);
stateless_action!(
actions,
DebugOpenPrefixAction,
clone!(@strong sender => move |_| {
sender.input(Msg::DebugOpenPrefix);
})
);
stateless_action!(
actions,
DebugCopyEnvVarsAction,
clone!(@strong sender => move |_| {
sender.input(Msg::DebugCopyEnvVars);
})
);
actions.add_action(RelmAction::<DebugViewToggleAction>::new_stateful(
&model.enable_debug_view,
clone!(@strong sender => move |_, state| {
@ -912,6 +930,7 @@ new_stateless_action!(pub BuildProfileAction, AppActionGroup, "buildprofile");
new_stateless_action!(pub BuildProfileCleanAction, AppActionGroup, "buildprofileclean");
new_stateless_action!(pub QuitAction, AppActionGroup, "quit");
new_stateful_action!(pub DebugViewToggleAction, AppActionGroup, "debugviewtoggle", (), bool);
new_stateless_action!(pub ConfigureWivrnAction, AppActionGroup, "configurewivrn");
new_stateless_action!(pub DebugOpenDataAction, AppActionGroup, "debugopendata");
new_stateless_action!(pub DebugOpenPrefixAction, AppActionGroup, "debugopenprefix");

View file

@ -11,7 +11,8 @@ use crate::gpu_profile::{get_amd_gpu_power_profile, GpuPowerProfile};
use crate::profile::{LighthouseDriver, Profile, XRServiceType};
use crate::steamvr_utils::chaperone_info_exists;
use crate::ui::app::{
AboutAction, BuildProfileAction, BuildProfileCleanAction, DebugViewToggleAction,
AboutAction, BuildProfileAction, BuildProfileCleanAction, ConfigureWivrnAction,
DebugViewToggleAction,
};
use crate::ui::profile_editor::ProfileEditorInit;
use crate::ui::steamvr_calibration_box::SteamVrCalibrationBoxMsg;
@ -76,7 +77,6 @@ pub enum MainViewOutMsg {
DeleteProfile,
SaveProfile(Profile),
OpenLibsurviveSetup,
OpenWivrnConfig,
}
pub struct MainViewInit {
@ -113,6 +113,7 @@ impl SimpleComponent for MainView {
"_Debug View" => DebugViewToggleAction,
"_Build Profile" => BuildProfileAction,
"C_lean Build Profile" => BuildProfileCleanAction,
"Configure _WiVRn" => ConfigureWivrnAction,
},
section! {
"_About" => AboutAction,
@ -296,32 +297,6 @@ impl SimpleComponent for MainView {
model.steam_launch_options_box.widget(),
model.install_wivrn_box.widget(),
gtk::Box {
set_orientation: gtk::Orientation::Horizontal,
set_hexpand: true,
set_vexpand: false,
set_spacing: 12,
add_css_class: "card",
add_css_class: "padded",
#[track = "model.changed(Self::selected_profile())"]
set_visible: model.selected_profile.xrservice_type == XRServiceType::Wivrn,
gtk::Label {
add_css_class: "heading",
set_hexpand: true,
set_xalign: 0.0,
set_label: "Configure WiVRn",
set_wrap: true,
set_wrap_mode: gtk::pango::WrapMode::Word,
},
gtk::Button {
add_css_class: "suggested-action",
set_label: "Configure",
set_halign: gtk::Align::End,
connect_clicked[sender] => move |_| {
sender.output(Self::Output::OpenWivrnConfig).expect("Sender output failed");
}
},
},
model.steamvr_calibration_box.widget(),
gtk::Box {

View file

@ -82,7 +82,7 @@ impl SimpleComponent for WivrnConfEditor {
set_content: pref_page = &adw::PreferencesPage {
set_hexpand: true,
set_vexpand: true,
set_description: "<a href=\"https://github.com/Meumeu/WiVRn#encoders\">WiVRn Configuration Documentation</a>",
set_description: "<b>Warning</b>: you likely don't need to change the default configuration, this is for advanced users only. Proceed at your own risk!\n\n<a href=\"https://github.com/Meumeu/WiVRn/blob/master/docs/configuration.md\">WiVRn Configuration Documentation</a>",
add: scalegrp = &adw::PreferencesGroup {
set_title: "Scale",
set_description: Some("Render resolution scale. 1.0 is 100%."),