Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split app key from viewport title to stop spraying app.ron files everywhere #59

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2770,27 +2770,40 @@ impl UiExtra for egui::Ui {
}

#[cfg(not(target_arch = "wasm32"))]
pub fn start(data_sources: Vec<Box<dyn DeferredDataSource>>) {
env_logger::try_init().unwrap_or(()); // Log to stderr (if you run with `RUST_LOG=debug`).

fn get_locator(data_sources: &[Box<dyn DeferredDataSource>]) -> String {
let all_locators = data_sources
.iter()
.flat_map(|x| x.fetch_description().source_locator)
.collect::<Vec<_>>();

let unique_locators = all_locators.into_iter().unique().collect_vec();

let locator = match &unique_locators[..] {
match &unique_locators[..] {
[] => "No data source".to_string(),
[x] => x.to_string(),
[x, ..] => format!("{} and {} other sources", x, unique_locators.len() - 1),
};
}
}

let app_name = format!("{locator} - Legion Prof");
#[cfg(not(target_arch = "wasm32"))]
pub fn start(data_sources: Vec<Box<dyn DeferredDataSource>>) {
env_logger::try_init().unwrap_or(()); // Log to stderr (if you run with `RUST_LOG=debug`).

let native_options = eframe::NativeOptions::default();
// IMPORTANT: This will be used as the directory name for the storage
// location for the persisted app.ron configuration. eframe is not good
// about sanitizing these directory names, so it is VERY IMPORTANT that
// this be a short, predictable name without weird characters in it.
let app_name = "Legion Prof";

// This is what will be displayed as the window's actual title.
let locator = format!("{} - {}", get_locator(&data_sources), app_name);

let native_options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_title(locator),
..Default::default()
};
eframe::run_native(
&app_name,
app_name,
native_options,
Box::new(|cc| Box::new(ProfApp::new(cc, data_sources))),
)
Expand Down
Loading