From 1aac9d1203598bbc7fb2cd7560f9bd251a85591a Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 26 Nov 2026 08:20:17 +0000 Subject: [PATCH] Profiles: the Profiles page, a game's profile and screen pickers, editing a shared profile, and the change-the-profile-or-make-individual prompt A fifth view lists Default, Built-in, My profiles and Individual games; each shared profile shows its games with Remove and what it comes to on each screen, with suggestions. The settings pane edits a shared profile too and gets a Screen section (frame rate native or pinned). Changing an engine setting on a game that uses a shared profile asks first. --- crates/summit-core/src/profiles.rs | 35 ++ crates/summit-gui/src/main.rs | 34 +- crates/summit-gui/src/pane.rs | 259 ++++++++- crates/summit-gui/src/profiles.rs | 861 ++++++++++++++++++++++++++++ crates/summit-gui/src/rows.rs | 2 +- crates/summit-gui/src/shot.rs | 7 +- crates/summit-gui/ui/app.slint | 48 +- crates/summit-gui/ui/detail.slint | 36 +- crates/summit-gui/ui/pane.slint | 7 +- crates/summit-gui/ui/profiles.slint | 293 ++++++++++ crates/summit-gui/ui/widgets.slint | 7 + docs/demo/profiles-shots.sh | 61 ++ 12 files changed, 1604 insertions(+), 46 deletions(-) create mode 100644 crates/summit-gui/src/profiles.rs create mode 100644 crates/summit-gui/ui/profiles.slint create mode 100755 docs/demo/profiles-shots.sh diff --git a/crates/summit-core/src/profiles.rs b/crates/summit-core/src/profiles.rs index bf25e57..1c8cd46 100644 --- a/crates/summit-core/src/profiles.rs +++ b/crates/summit-core/src/profiles.rs @@ -77,6 +77,29 @@ pub fn slugify(name: &str) -> String { s.trim_end_matches('-').to_string() } +/// Profile files lying in `dirs` (not below them): every `.toml` that reads as a profile and has a `name`, with that +/// name. What "Import" offers without a file dialog. +pub fn importable(dirs: &[PathBuf]) -> Vec<(PathBuf, String)> { + let mut v: Vec<(PathBuf, String)> = vec![]; + for d in dirs { + for e in std::fs::read_dir(d).into_iter().flatten().flatten().take(2000) { + let p = e.path(); + if p.extension().and_then(|x| x.to_str()) != Some("toml") || std::fs::metadata(&p).map(|m| m.len() > 1 << 20).unwrap_or(true) { continue; } + let Ok(text) = std::fs::read_to_string(&p) else { continue }; + let Ok(l) = profile::parse_layer(&text) else { continue }; + if l.version.is_some_and(|x| x > LAYER_VERSION) { continue; } + if let Some(name) = l.name.filter(|n| !n.trim().is_empty()) { if !v.iter().any(|(q, _)| *q == p) { v.push((p, name)); } } + } + } + v.sort(); + v +} + +/// Where exported profiles are looked for: Documents, Downloads and the home folder. +pub fn exchange_dirs() -> Vec { + [dirs::document_dir(), dirs::download_dir(), dirs::home_dir()].into_iter().flatten().filter(|d| d.is_dir()).collect() +} + /// A built-in profile's settings: the preset's values, as a layer. pub fn builtin_layer(p: &crate::presets::Preset) -> Layer { let mut l = Layer::default(); @@ -432,6 +455,14 @@ impl Store { self.create(&name, &l) } + /// Where an exported profile is put when no place is given: the user's Documents folder (their home without one). + pub fn export_path(&self, r: &Ref) -> Result { + let s = self.get(r)?; + let dir = dirs::document_dir().filter(|d| d.is_dir()).or_else(dirs::home_dir).context("no home folder")?; + let base = match r { Ref::User(slug) => slug.clone(), _ => slugify(&s.name) }; + Ok(dir.join(format!("summit-profile-{base}.toml"))) + } + /// Bring the files of an older Summit up to this one, once (`profiles.toml` says it was done). Before anything is /// written, `profiles/` is copied to `backups/profiles-v2-