* claim: #5542 * Reopen the designs that were open at the last quit (#5542) A launch with no file to open reopens the saved designs that were open when SolidCraft was last closed, in tab order. Designs never saved and files that are gone are skipped. Preferences > General > Reopen designs turns it off; a launch driven over --control or with --sample starts fresh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Move the new messages to a pending locale file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
This commit is contained in:
@@ -933,6 +933,10 @@ fn main() -> eframe::Result {
|
||||
open_documents::set_ui(&cc.egui_ctx);
|
||||
[files, open_documents::take()].concat()
|
||||
};
|
||||
// No design given: the designs open at the last quit, when the preference asks (#5542).
|
||||
// Not when driven over the control channel, whose clients expect a fresh design.
|
||||
let files =
|
||||
if files.is_empty() && !sample && control_port.is_none() { solidcraft_ui_egui::documents::designs_to_reopen(&app) } else { files };
|
||||
for f in &files {
|
||||
app.open_path_async(f);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"en": {
|
||||
"Reopen designs": "Reopen designs",
|
||||
"Reopen the designs that were open when SolidCraft was last closed": "Reopen the designs that were open when SolidCraft was last closed"
|
||||
},
|
||||
"ja": {
|
||||
"Reopen designs": "デザインを再度開く",
|
||||
"Reopen the designs that were open when SolidCraft was last closed": "前回 SolidCraft を閉じたときに開いていたデザインを再度開く"
|
||||
},
|
||||
"zh": {
|
||||
"Reopen designs": "重新打开设计",
|
||||
"Reopen the designs that were open when SolidCraft was last closed": "重新打开上次关闭 SolidCraft 时打开的设计"
|
||||
}
|
||||
}
|
||||
@@ -477,6 +477,12 @@ fn quit_step(app: &mut SolveApp) {
|
||||
}
|
||||
app.docs.quitting = None;
|
||||
app.quit_requested = true;
|
||||
// The next launch reopens the designs saved to a file (#5542).
|
||||
let sessions: Vec<&solidcraft_engine::Session> = match app.docs.slots.is_empty() {
|
||||
true => vec![&app.session],
|
||||
false => app.docs.slots.iter().map(|s| s.as_ref().map_or(&app.session, |d| &d.session)).collect(),
|
||||
};
|
||||
app.preferences.open_designs = sessions.into_iter().filter_map(|s| s.path.clone()).collect();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -523,6 +529,15 @@ fn tab_tooltip(name: &str, path: Option<&str>, cut: bool) -> String {
|
||||
if cut { format!("{name}\n{place}") } else { place }
|
||||
}
|
||||
|
||||
/// The designs a launch with no file to open reopens: those open at the last quit that still
|
||||
/// exist, when Preferences › General asks for it (#5542).
|
||||
pub fn designs_to_reopen(app: &SolveApp) -> Vec<String> {
|
||||
if !app.preferences.reopen_designs {
|
||||
return Vec::new();
|
||||
}
|
||||
app.preferences.open_designs.iter().filter(|p| std::path::Path::new(p.as_str()).is_file()).take(MAX_OPEN).cloned().collect()
|
||||
}
|
||||
|
||||
/// The control channel's `ui.documents`: list, `new`, `switch`, `close` (by index; `force`
|
||||
/// closes without asking), `close_others` (all but `index`), `close_all`, `move` (`from`, `to`)
|
||||
/// or `quit`; `answer`: save | dont_save | cancel answers "save changes?"; `open_elsewhere`:
|
||||
@@ -1409,7 +1424,15 @@ mod tests {
|
||||
assert_eq!(a.docs.closing, None);
|
||||
assert!(a.quit_requested, "every design answered: quit");
|
||||
assert!(!any_dirty(&a), "Don't Save discards: nothing is kept for recovery");
|
||||
// The next launch reopens the saved design; the never-saved one has no file (#5542).
|
||||
let path = file.to_string_lossy().to_string();
|
||||
assert_eq!(a.preferences.open_designs, vec![path.clone()]);
|
||||
assert_eq!(designs_to_reopen(&a), vec![path]);
|
||||
a.preferences.reopen_designs = false;
|
||||
assert!(designs_to_reopen(&a).is_empty(), "turned off in Preferences");
|
||||
a.preferences.reopen_designs = true;
|
||||
let _ = std::fs::remove_file(&file);
|
||||
assert!(designs_to_reopen(&a).is_empty(), "a file that is gone is skipped");
|
||||
}
|
||||
|
||||
/// Cancel, Esc's answer, or a Save that saves nothing (a never-saved design whose Save As
|
||||
|
||||
@@ -614,6 +614,10 @@ preference_settings! {
|
||||
/// Up/Down and the wheel over a focused value field step its plain number (`value_step`,
|
||||
/// #2320). Off by default: the keys move the text cursor and the wheel scrolls, as before.
|
||||
step_values: bool = false, PAGE_DESIGN => check_id("ui.step_values");
|
||||
/// Reopen the saved designs that were open when the app was last closed (#5542).
|
||||
reopen_designs: bool = true, PAGE_GENERAL;
|
||||
/// Those designs' files, in tab order, as the last quit left them.
|
||||
open_designs: Vec<String> = Vec::new(), PAGE_GENERAL;
|
||||
/// `dark`, `light` or `system` (follow the operating system), or a theme file's id: a
|
||||
/// built-in one (`gruvbox-dark`, …) or one of `custom_themes` (#2255).
|
||||
theme: String = "dark".into(), PAGE_INTERFACE;
|
||||
|
||||
@@ -30,6 +30,13 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
ui_kit::settings_autosave_timeline(ui, app.autosave_minutes);
|
||||
});
|
||||
ui_kit::settings_block(ui, app.tr_label("Reopen designs"), labels, |ui| {
|
||||
ui_kit::checkbox(
|
||||
ui,
|
||||
crate::i18n::tr_label("Reopen the designs that were open when SolidCraft was last closed"),
|
||||
&mut app.preferences.reopen_designs,
|
||||
);
|
||||
});
|
||||
ui_kit::settings_block(ui, app.tr_label("Crash reports"), labels, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
let count = app.crashes.saved_count();
|
||||
|
||||
Reference in New Issue
Block a user