fix: restore profile selection on startup

This commit is contained in:
Gabriele Musco 2023-06-17 22:36:22 +02:00
commit 5630091179
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE

View file

@ -26,6 +26,7 @@ pub enum MainViewMsg {
MonadoActiveChanged(bool), MonadoActiveChanged(bool),
EnableDebugViewChanged(bool), EnableDebugViewChanged(bool),
UpdateProfileNames(Vec<String>, Config), UpdateProfileNames(Vec<String>, Config),
SetSelectedProfile(u32),
ProfileSelected(u32), ProfileSelected(u32),
SteamLaunchOptionsChanged(String), SteamLaunchOptionsChanged(String),
CopySteamLaunchOptions, CopySteamLaunchOptions,
@ -245,14 +246,17 @@ impl SimpleComponent for MainView {
} }
MainViewMsg::UpdateProfileNames(names, config) => { MainViewMsg::UpdateProfileNames(names, config) => {
self.set_profile_names(names); self.set_profile_names(names);
self.profiles_dropdown.as_ref().unwrap().clone().set_selected({ sender.input(MainViewMsg::SetSelectedProfile({
let pos = self.profile_names.iter() let pos = self.profile_names.iter()
.position(|p| p.clone() == config.selected_profile_name); .position(|p| p.clone() == config.selected_profile_name);
match pos { match pos {
Some(idx) => idx as u32, Some(idx) => idx as u32,
None => 0, None => 0,
} }
}); }));
}
MainViewMsg::SetSelectedProfile(index) => {
self.profiles_dropdown.as_ref().unwrap().clone().set_selected(index);
} }
MainViewMsg::SteamLaunchOptionsChanged(lo) => self.set_steam_launch_options(lo), MainViewMsg::SteamLaunchOptionsChanged(lo) => self.set_steam_launch_options(lo),
MainViewMsg::CopySteamLaunchOptions => gtk::gdk::Display::default() MainViewMsg::CopySteamLaunchOptions => gtk::gdk::Display::default()