mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-09 09:38:54 +00:00
feat: add xr service type selector in profile editor
This commit is contained in:
parent
e2a76133d6
commit
6440a4f8b4
2 changed files with 40 additions and 7 deletions
|
@ -24,6 +24,12 @@ impl XRServiceType {
|
||||||
pub fn iter() -> Iter<'static, XRServiceType> {
|
pub fn iter() -> Iter<'static, XRServiceType> {
|
||||||
[Self::Monado, Self::Wivrn].iter()
|
[Self::Monado, Self::Wivrn].iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn as_number(&self) -> u32 {
|
||||||
|
match self {
|
||||||
|
Self::Monado => 0, Self::Wivrn => 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for XRServiceType {
|
impl Display for XRServiceType {
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
use super::factories::{entry_row_factory::{EntryModel, EntryModelInit}, switch_row_factory::{SwitchModel, SwitchModelInit}, path_row_factory::{PathModel, PathModelInit}};
|
use super::factories::{
|
||||||
use crate::{env_var_descriptions::env_var_descriptions_as_paragraph, profile::Profile};
|
entry_row_factory::{EntryModel, EntryModelInit},
|
||||||
|
path_row_factory::{PathModel, PathModelInit},
|
||||||
|
switch_row_factory::{SwitchModel, SwitchModelInit},
|
||||||
|
};
|
||||||
|
use crate::{
|
||||||
|
env_var_descriptions::env_var_descriptions_as_paragraph,
|
||||||
|
profile::{Profile, XRServiceType},
|
||||||
|
};
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use relm4::{factory::FactoryVecDeque, prelude::*};
|
use relm4::{factory::FactoryVecDeque, prelude::*};
|
||||||
|
@ -15,6 +22,8 @@ pub struct ProfileEditor {
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
name_row: adw::EntryRow,
|
name_row: adw::EntryRow,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
|
type_row: adw::ComboRow,
|
||||||
|
#[tracker::do_not_track]
|
||||||
env_rows: FactoryVecDeque<EntryModel>,
|
env_rows: FactoryVecDeque<EntryModel>,
|
||||||
#[tracker::do_not_track]
|
#[tracker::do_not_track]
|
||||||
switch_rows: FactoryVecDeque<SwitchModel>,
|
switch_rows: FactoryVecDeque<SwitchModel>,
|
||||||
|
@ -52,6 +61,7 @@ impl SimpleComponent for ProfileEditor {
|
||||||
add: maingrp = &adw::PreferencesGroup {
|
add: maingrp = &adw::PreferencesGroup {
|
||||||
set_title: "Profile Info",
|
set_title: "Profile Info",
|
||||||
model.name_row.clone(),
|
model.name_row.clone(),
|
||||||
|
model.type_row.clone(),
|
||||||
},
|
},
|
||||||
add: model.env_rows.widget(),
|
add: model.env_rows.widget(),
|
||||||
add: model.switch_rows.widget(),
|
add: model.switch_rows.widget(),
|
||||||
|
@ -69,6 +79,8 @@ impl SimpleComponent for ProfileEditor {
|
||||||
|
|
||||||
self.name_row.set_text(p.name.as_str());
|
self.name_row.set_text(p.name.as_str());
|
||||||
|
|
||||||
|
self.type_row.set_selected(prof.xrservice_type.as_number());
|
||||||
|
|
||||||
self.env_rows.guard().clear();
|
self.env_rows.guard().clear();
|
||||||
for (k, v) in p.environment.iter() {
|
for (k, v) in p.environment.iter() {
|
||||||
self.env_rows.guard().push_back(EntryModelInit {
|
self.env_rows.guard().push_back(EntryModelInit {
|
||||||
|
@ -101,27 +113,27 @@ impl SimpleComponent for ProfileEditor {
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
self.path_rows.guard().push_back(PathModelInit {
|
||||||
name: "XR Service Path".into(),
|
name: "XR Service Path".into(),
|
||||||
key: "xrservice_path".into(),
|
key: "xrservice_path".into(),
|
||||||
value: Some(p.xrservice_path)
|
value: Some(p.xrservice_path),
|
||||||
});
|
});
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
self.path_rows.guard().push_back(PathModelInit {
|
||||||
name: "OpenComposite Path".into(),
|
name: "OpenComposite Path".into(),
|
||||||
key: "opencomposite_path".into(),
|
key: "opencomposite_path".into(),
|
||||||
value: Some(p.opencomposite_path)
|
value: Some(p.opencomposite_path),
|
||||||
});
|
});
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
self.path_rows.guard().push_back(PathModelInit {
|
||||||
name: "Libsurvive Path".into(),
|
name: "Libsurvive Path".into(),
|
||||||
key: "libsurvive_path".into(),
|
key: "libsurvive_path".into(),
|
||||||
value: p.libsurvive_path
|
value: p.libsurvive_path,
|
||||||
});
|
});
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
self.path_rows.guard().push_back(PathModelInit {
|
||||||
name: "Basalt Path".into(),
|
name: "Basalt Path".into(),
|
||||||
key: "basalt_path".into(),
|
key: "basalt_path".into(),
|
||||||
value: p.basalt_path
|
value: p.basalt_path,
|
||||||
});
|
});
|
||||||
self.path_rows.guard().push_back(PathModelInit {
|
self.path_rows.guard().push_back(PathModelInit {
|
||||||
name: "Mercury Path".into(),
|
name: "Mercury Path".into(),
|
||||||
key: "mercury_path".into(),
|
key: "mercury_path".into(),
|
||||||
value: p.mercury_path
|
value: p.mercury_path,
|
||||||
});
|
});
|
||||||
|
|
||||||
self.set_profile(Some(prof.clone()));
|
self.set_profile(Some(prof.clone()));
|
||||||
|
@ -166,6 +178,21 @@ impl SimpleComponent for ProfileEditor {
|
||||||
profile: None,
|
profile: None,
|
||||||
win: None,
|
win: None,
|
||||||
name_row: adw::EntryRow::builder().title("Name").build(),
|
name_row: adw::EntryRow::builder().title("Name").build(),
|
||||||
|
type_row: adw::ComboRow::builder()
|
||||||
|
.title("XR Service Type")
|
||||||
|
.subtitle(
|
||||||
|
"Monado is for PCVR headsets, while WiVRn is for Andorid standalone headsets",
|
||||||
|
)
|
||||||
|
.model(>k::StringList::new(
|
||||||
|
XRServiceType::iter()
|
||||||
|
.map(|st| st.to_string())
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.iter()
|
||||||
|
.map(|s| s.as_str())
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.as_slice(),
|
||||||
|
))
|
||||||
|
.build(),
|
||||||
env_rows: FactoryVecDeque::new(
|
env_rows: FactoryVecDeque::new(
|
||||||
adw::PreferencesGroup::builder()
|
adw::PreferencesGroup::builder()
|
||||||
.title("Environment Variables")
|
.title("Environment Variables")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue