Design tabs: the tooltip says when a saved design has unsaved changes (#11408) (#11590)

* Design tabs: the tooltip says when a saved design has unsaved changes (#11408)

A tab marks unsaved changes with a bullet after the design's name, and a
long name cut short by the tab hides it. The tab's tooltip, which says
where the design is saved, now adds "Unsaved changes" below for a saved
design with changes not saved yet. A design never saved already says
"Not saved yet". The new string is in a pending locale file, with ten
translations taken from the same words elsewhere in the catalogs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Design tabs: the unsaved line in every complete catalog (#11408)

Arabic, Hebrew and Vietnamese are complete catalogs, which must carry
every English message: they get the words they already use for
"Unsaved changes" elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
semmelrinde
2026-11-04 05:29:03 +00:00
committed by GitHub
parent 8a74336713
commit 4afd24d29f
2 changed files with 34 additions and 9 deletions
@@ -0,0 +1,15 @@
{
"en": { "document.tab_unsaved_changes": "Unsaved changes" },
"ar": { "document.tab_unsaved_changes": "تغييرات غير محفوظة" },
"de": { "document.tab_unsaved_changes": "Ungespeicherte Änderungen" },
"es": { "document.tab_unsaved_changes": "Cambios sin guardar" },
"fr": { "document.tab_unsaved_changes": "Modifications non enregistrées" },
"he": { "document.tab_unsaved_changes": "שינויים שלא נשמרו" },
"it": { "document.tab_unsaved_changes": "Modifiche non salvate" },
"ja": { "document.tab_unsaved_changes": "未保存の変更" },
"nl": { "document.tab_unsaved_changes": "Niet-opgeslagen wijzigingen" },
"pl": { "document.tab_unsaved_changes": "Niezapisane zmiany" },
"sv": { "document.tab_unsaved_changes": "Osparade ändringar" },
"vi": { "document.tab_unsaved_changes": "Thay đổi chưa lưu" },
"zh": { "document.tab_unsaved_changes": "未保存的更改" }
}
+19 -9
View File
@@ -741,9 +741,11 @@ fn tab_paths(app: &SolveApp) -> Vec<Option<String>> {
}
/// A tab's tooltip: where its design is saved (home shortened to `~`), or that it isn't yet; with
/// the full name above when the tab cut it short (#5868).
fn tab_tooltip(name: &str, path: Option<&str>, cut: bool) -> String {
/// the full name above when the tab cut it short (#5868), and below, that a saved design has
/// changes not saved yet (`dirty`), which the bullet after a cut name no longer shows (#11408).
fn tab_tooltip(name: &str, path: Option<&str>, cut: bool, dirty: bool) -> String {
let place = path.map_or_else(|| crate::i18n::tr_label("Not saved yet").to_string(), crate::home::friendly_path);
let place = if dirty && path.is_some() { format!("{place}\n{}", crate::i18n::tr("document.tab_unsaved_changes")) } else { place };
if cut { format!("{name}\n{place}") } else { place }
}
@@ -926,7 +928,7 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
};
let g = ui.painter().layout_no_wrap(label, font, ink);
let text_w = (tr.width() - 30.0).max(10.0);
let tip = tab_tooltip(&name_display, paths.get(i).cloned().flatten().as_deref(), g.size().x > text_w);
let tip = tab_tooltip(&name_display, paths.get(i).cloned().flatten().as_deref(), g.size().x > text_w, *dirty);
let clip = Rect::from_min_size(tr.min, vec2(text_w + 10.0, tr.height()));
ui.painter().with_clip_rect(clip).galley(pos2(tr.left() + 10.0, tr.center().y - g.size().y / 2.0), g, ink);
// ×
@@ -1351,18 +1353,26 @@ mod tests {
use egui::Color32;
/// #5868: a tab's tooltip says where its design is saved (home as `~`), or that it isn't
/// yet, with the full name above when the tab cut the name short.
/// yet, with the full name above when the tab cut the name short. #11408: a saved design with
/// changes not saved yet says so below, since a cut name hides the tab's bullet.
#[test]
fn tab_tooltip_says_where_the_design_is_saved() {
assert_eq!(tab_tooltip("plate", Some("/srv/designs/plate.solidcraft"), false), "/srv/designs/plate.solidcraft");
assert_eq!(tab_tooltip("a-long-name", Some("/srv/a-long-name.solidcraft"), true), "a-long-name\n/srv/a-long-name.solidcraft");
assert_eq!(tab_tooltip("Untitled", None, false), "Not saved yet");
assert_eq!(tab_tooltip("Untitled", None, true), "Untitled\nNot saved yet");
assert_eq!(tab_tooltip("plate", Some("/srv/designs/plate.solidcraft"), false, false), "/srv/designs/plate.solidcraft");
assert_eq!(tab_tooltip("a-long-name", Some("/srv/a-long-name.solidcraft"), true, false), "a-long-name\n/srv/a-long-name.solidcraft");
assert_eq!(tab_tooltip("Untitled", None, false, false), "Not saved yet");
assert_eq!(tab_tooltip("Untitled", None, true, false), "Untitled\nNot saved yet");
assert_eq!(tab_tooltip("plate", Some("/srv/designs/plate.solidcraft"), false, true), "/srv/designs/plate.solidcraft\nUnsaved changes");
assert_eq!(
tab_tooltip("a-long-name", Some("/srv/a-long-name.solidcraft"), true, true),
"a-long-name\n/srv/a-long-name.solidcraft\nUnsaved changes"
);
// A design never saved says so already, changed or not.
assert_eq!(tab_tooltip("Untitled", None, true, true), "Untitled\nNot saved yet");
if let Some(home) = std::env::var_os("HOME").or_else(|| std::env::var_os("USERPROFILE")).filter(|h| !h.is_empty()) {
// The abbreviation keeps the relative path's native separators after `~/`.
let relative = std::path::Path::new("Designs").join("bracket.solidcraft");
let path = std::path::Path::new(&home).join(&relative);
assert_eq!(tab_tooltip("bracket", path.to_str(), false), format!("~/{}", relative.display()));
assert_eq!(tab_tooltip("bracket", path.to_str(), false, false), format!("~/{}", relative.display()));
}
}