mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-09 17:48:49 +00:00
feat: add restart xr service button
This commit is contained in:
parent
d686fb53ac
commit
6068263d9d
2 changed files with 66 additions and 23 deletions
|
@ -18,8 +18,12 @@ use crate::dependencies::mercury_deps::get_missing_mercury_deps;
|
|||
use crate::dependencies::monado_deps::get_missing_monado_deps;
|
||||
use crate::dependencies::pkexec_dep::pkexec_dep;
|
||||
use crate::dependencies::wivrn_deps::get_missing_wivrn_deps;
|
||||
use crate::file_builders::active_runtime_json::{set_current_active_runtime_to_profile, set_current_active_runtime_to_steam};
|
||||
use crate::file_builders::openvrpaths_vrpath::{set_current_openvrpaths_to_profile, set_current_openvrpaths_to_steam};
|
||||
use crate::file_builders::active_runtime_json::{
|
||||
set_current_active_runtime_to_profile, set_current_active_runtime_to_steam,
|
||||
};
|
||||
use crate::file_builders::openvrpaths_vrpath::{
|
||||
set_current_openvrpaths_to_profile, set_current_openvrpaths_to_steam,
|
||||
};
|
||||
use crate::file_utils::setcap_cap_sys_nice_eip;
|
||||
use crate::log_parser::MonadoLog;
|
||||
use crate::profile::{Profile, XRServiceType};
|
||||
|
@ -88,6 +92,7 @@ pub enum Msg {
|
|||
BuildProfile,
|
||||
EnableDebugViewChanged(bool),
|
||||
DoStartStopXRService,
|
||||
RestartXRService,
|
||||
ProfileSelected(Profile),
|
||||
DeleteProfile,
|
||||
SaveProfile(Profile),
|
||||
|
@ -121,8 +126,7 @@ impl App {
|
|||
gtk::ApplicationInhibitFlags::all(),
|
||||
Some("XR Session running"),
|
||||
));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if self.inhibit_id.is_none() {
|
||||
return;
|
||||
}
|
||||
|
@ -344,6 +348,22 @@ impl SimpleComponent for App {
|
|||
}
|
||||
},
|
||||
},
|
||||
Msg::RestartXRService => {
|
||||
match &mut self.xrservice_runner {
|
||||
None => {}
|
||||
Some(runner) => match runner.status() {
|
||||
RunnerStatus::Stopped(_) => {}
|
||||
RunnerStatus::Running => {
|
||||
if self.xrservice_runner.is_some() {
|
||||
if self.xrservice_runner.as_mut().unwrap().status() == RunnerStatus::Running {
|
||||
self.xrservice_runner.as_mut().unwrap().terminate();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
self.start_xrservice();
|
||||
}
|
||||
Msg::BuildProfile => {
|
||||
let profile = self.get_selected_profile();
|
||||
let mut missing_deps = vec![];
|
||||
|
@ -543,6 +563,7 @@ impl SimpleComponent for App {
|
|||
.forward(sender.input_sender(), |message| match message {
|
||||
MainViewOutMsg::EnableDebugViewChanged(val) => Msg::EnableDebugViewChanged(val),
|
||||
MainViewOutMsg::DoStartStopXRService => Msg::DoStartStopXRService,
|
||||
MainViewOutMsg::RestartXRService => Msg::RestartXRService,
|
||||
MainViewOutMsg::ProfileSelected(uuid) => Msg::ProfileSelected(uuid),
|
||||
MainViewOutMsg::DeleteProfile => Msg::DeleteProfile,
|
||||
MainViewOutMsg::SaveProfile(p) => Msg::SaveProfile(p),
|
||||
|
|
|
@ -44,6 +44,7 @@ pub struct MainView {
|
|||
pub enum MainViewMsg {
|
||||
ClockTicking,
|
||||
StartStopClicked,
|
||||
RestartXRService,
|
||||
XRServiceActiveChanged(bool, Option<Profile>),
|
||||
EnableDebugViewChanged(bool),
|
||||
UpdateProfiles(Vec<Profile>, Config),
|
||||
|
@ -62,6 +63,7 @@ pub enum MainViewMsg {
|
|||
pub enum MainViewOutMsg {
|
||||
EnableDebugViewChanged(bool),
|
||||
DoStartStopXRService,
|
||||
RestartXRService,
|
||||
ProfileSelected(Profile),
|
||||
DeleteProfile,
|
||||
SaveProfile(Profile),
|
||||
|
@ -126,21 +128,38 @@ impl SimpleComponent for MainView {
|
|||
set_margin_top: 12,
|
||||
set_margin_bottom: 12,
|
||||
set_orientation: gtk::Orientation::Vertical,
|
||||
gtk::Button {
|
||||
add_css_class: "pill",
|
||||
add_css_class: "suggested-action",
|
||||
add_css_class: "destructive-action",
|
||||
set_hexpand: true,
|
||||
gtk::Box {
|
||||
set_halign: gtk::Align::Center,
|
||||
#[track = "model.changed(Self::xrservice_active())"]
|
||||
set_class_active: ("suggested-action", !model.xrservice_active),
|
||||
#[track = "model.changed(Self::xrservice_active())"]
|
||||
set_label: match model.xrservice_active {
|
||||
true => "Stop",
|
||||
false => "Start",
|
||||
set_orientation: gtk::Orientation::Horizontal,
|
||||
set_spacing: 12,
|
||||
gtk::Button {
|
||||
add_css_class: "pill",
|
||||
add_css_class: "suggested-action",
|
||||
add_css_class: "destructive-action",
|
||||
set_halign: gtk::Align::Center,
|
||||
#[track = "model.changed(Self::xrservice_active())"]
|
||||
set_class_active: ("suggested-action", !model.xrservice_active),
|
||||
#[track = "model.changed(Self::xrservice_active())"]
|
||||
set_label: match model.xrservice_active {
|
||||
true => "Stop",
|
||||
false => "Start",
|
||||
},
|
||||
connect_clicked[sender] => move |_| {
|
||||
sender.input(MainViewMsg::StartStopClicked);
|
||||
},
|
||||
},
|
||||
connect_clicked[sender] => move |_| {
|
||||
sender.input(MainViewMsg::StartStopClicked)
|
||||
gtk::Button {
|
||||
add_css_class: "circular",
|
||||
add_css_class: "flat",
|
||||
set_halign: gtk::Align::Center,
|
||||
set_valign: gtk::Align::Center,
|
||||
set_icon_name: "view-refresh-symbolic",
|
||||
set_tooltip_text: Some("Restart"),
|
||||
#[track = "model.changed(Self::xrservice_active())"]
|
||||
set_visible: model.xrservice_active,
|
||||
connect_clicked[sender] => move |_| {
|
||||
sender.input(MainViewMsg::RestartXRService)
|
||||
},
|
||||
},
|
||||
},
|
||||
model.devices_box.widget(),
|
||||
|
@ -219,7 +238,10 @@ impl SimpleComponent for MainView {
|
|||
.emit(InstallWivrnBoxMsg::ClockTicking);
|
||||
}
|
||||
Self::Input::StartStopClicked => {
|
||||
sender.output(MainViewOutMsg::DoStartStopXRService);
|
||||
sender.output(Self::Output::DoStartStopXRService);
|
||||
}
|
||||
Self::Input::RestartXRService => {
|
||||
sender.output(Self::Output::RestartXRService);
|
||||
}
|
||||
Self::Input::XRServiceActiveChanged(active, profile) => {
|
||||
self.set_xrservice_active(active);
|
||||
|
@ -301,14 +323,14 @@ impl SimpleComponent for MainView {
|
|||
self.profile_editor.sender().emit(ProfileEditorMsg::Present(
|
||||
self.selected_profile.create_duplicate(),
|
||||
));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
self.cannot_duplicate_profile_dialog.present();
|
||||
}
|
||||
}
|
||||
Self::Input::UpdateDevices(devs) => {
|
||||
self.devices_box.sender().emit(DevicesBoxMsg::UpdateDevices(devs))
|
||||
}
|
||||
Self::Input::UpdateDevices(devs) => self
|
||||
.devices_box
|
||||
.sender()
|
||||
.emit(DevicesBoxMsg::UpdateDevices(devs)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue