Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LR-BEHAV-BG-TASKS: a failed filmstrip thumbnail with no file name is announced without a leading comma

Nathaniel Ledford0457d38a76cf
diff --git a/crates/ui-egui/src/panels/detail.rs b/crates/ui-egui/src/panels/detail.rs
index d5b069c41..5a206844a 100644
--- a/crates/ui-egui/src/panels/detail.rs
+++ b/crates/ui-egui/src/panels/detail.rs
@@ -2936,9 +2936,14 @@ pub(crate) fn filmstrip(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect) {
}
/// What a screen reader says for a filmstrip thumbnail: the file, and why there is no picture
-/// when the thumbnail failed (the painted `!` has no name of its own).
+/// when the thumbnail failed (the painted `!` has no name of its own). The name is empty when the
+/// catalog no longer has the photo (or its file name is blank); the reason then stands alone.
pub(crate) fn film_spoken(file_name: &str, failed: bool) -> String {
- if failed { format!("{file_name}, {}", crate::i18n::tr("This photo can't be opened")) } else { file_name.to_string() }
+ match (file_name.is_empty(), failed) {
+ (_, false) => file_name.to_string(),
+ (true, true) => crate::i18n::tr("This photo can't be opened").to_string(),
+ (false, true) => format!("{file_name}, {}", crate::i18n::tr("This photo can't be opened")),
+ }
}
/// Rating, flag and edited badges along a filmstrip thumbnail's bottom edge (Settings → Interface).
diff --git a/crates/ui-egui/src/tests_progress.rs b/crates/ui-egui/src/tests_progress.rs
index 8319278cc..7d906bc81 100644
--- a/crates/ui-egui/src/tests_progress.rs
+++ b/crates/ui-egui/src/tests_progress.rs
@@ -207,6 +207,12 @@ fn a_failed_filmstrip_thumbnail_is_announced_with_its_reason() {
assert_eq!(spoken(true).as_deref(), Some("IMG_0001.jpg, This photo can't be opened"));
}
+#[test]
+fn a_failed_filmstrip_thumbnail_without_a_file_name_has_no_leading_comma() {
+ assert_eq!(crate::panels::detail::film_spoken("", true), "This photo can't be opened");
+ assert_eq!(crate::panels::detail::film_spoken("", false), "");
+}
+
#[test]
fn the_sam_bar_keeps_its_name_and_height_while_the_size_is_unknown() {
let (nodes, _, (known, unknown)) = frames(Vec::new(), |ui| {