mirror of
https://github.com/storytold/lightcraft.git
synced 2026-12-02 02:46:10 -06:00
Grid: one selected photo shows "1 selected" in the header (#3776)
The Library grid's header added the selection count only from two selected
photos up, so selecting one showed nothing, while the reference app shows
"1 selected". It now shows from one. The Spanish, Brazilian Portuguese and
Swedish strings were plural-only ("1 seleccionadas"); they now read
"Seleccionadas: 1 · ...", the noun-first form Italian and Polish already use.
This commit is contained in:
@@ -169,7 +169,7 @@
|
||||
"{n} photo{} now · updates automatically as photos change": "{n} foto{} ahora · se actualiza automáticamente cuando cambian las fotos",
|
||||
"{n} selected photo{} · {pages} page{}": "{n} foto{0} seleccionada{0} · {pages} página{1}",
|
||||
"{pid} (missing)": "{pid} (falta)",
|
||||
"{sel_n} selected · {counted}": "{sel_n} seleccionadas · {counted}",
|
||||
"{sel_n} selected · {counted}": "Seleccionadas: {sel_n} · {counted}",
|
||||
"{stage}… {:.0}%": "{stage}… {:.0}%",
|
||||
"{verb} {n} Photo{}": "{verb} {n} foto{}",
|
||||
"{weekday}, {day}": "{weekday}, {day}",
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
"{n} photo{} match · updates automatically as photos change": "{n} foto{0} correspondente{0} · atualiza automaticamente conforme as fotos mudam",
|
||||
"{n} photo{} now · updates automatically as photos change": "{n} foto{} agora · atualiza automaticamente conforme as fotos mudam",
|
||||
"{n} selected photo{} · {pages} page{}": "{n} foto{0} selecionada{0} · {pages} página{1}",
|
||||
"{sel_n} selected · {counted}": "{sel_n} selecionadas · {counted}",
|
||||
"{sel_n} selected · {counted}": "Selecionadas: {sel_n} · {counted}",
|
||||
"{stage}… {:.0}%": "{stage}… {:.0}%",
|
||||
"{verb} {n} Photo{}": "{verb} {n} foto{}",
|
||||
"{weekday}, {day}": "{weekday}, {day}",
|
||||
|
||||
@@ -253,7 +253,7 @@
|
||||
"{pct} %": "{pct} %",
|
||||
"{photos} catalog records processed; {collections} collections.": "{photos} katalogposter bearbetade; {collections} samlingar.",
|
||||
"{pid} (missing)": "{pid} (saknas)",
|
||||
"{sel_n} selected · {counted}": "{sel_n} markerade · {counted}",
|
||||
"{sel_n} selected · {counted}": "Markerade: {sel_n} · {counted}",
|
||||
"{size} GB": "{size} GB",
|
||||
"{stage}… {:.0}%": "{stage}… {:.0} %",
|
||||
"{s} s of AV1 video": "{s} s AV1-video",
|
||||
|
||||
@@ -298,7 +298,7 @@ fn show_inner(app: &mut LightcraftApp, ui: &mut egui::Ui) {
|
||||
let chips = lightcraft_engine::filter_chips(&app.session.filter, &app.session.catalog);
|
||||
let total = app.session.source_total();
|
||||
let counted = super::chips::count_text(ids.len(), total, !chips.is_empty());
|
||||
let cnt = if sel_n > 1 { crate::i18n::tr_format!("{sel_n} selected · {counted}", counted = counted, sel_n = sel_n) } else { counted };
|
||||
let cnt = if sel_n > 0 { crate::i18n::tr_format!("{sel_n} selected · {counted}", counted = counted, sel_n = sel_n) } else { counted };
|
||||
match app.session.browse.clone().filter(|_| app.session.source == lightcraft_engine::LibrarySource::Folder) {
|
||||
Some(b) => {
|
||||
let local = app.caches.grid.local(&app.session.catalog, &ids, generation);
|
||||
|
||||
@@ -17,6 +17,41 @@ fn breadcrumbs_open_their_folder_as_spelled() {
|
||||
assert!(to("").is_empty() && to("/").is_empty() && to(r"\\").is_empty());
|
||||
}
|
||||
|
||||
/// Issue #3776: one selected photo is counted in the header as two or more are ("1 selected · 3
|
||||
/// photos"); with nothing selected the header shows the photo count alone.
|
||||
#[test]
|
||||
fn the_header_counts_a_single_selected_photo() {
|
||||
use lightcraft_catalog::{Op, Photo, Source};
|
||||
for selected in [0, 1, 2] {
|
||||
let mut session = lightcraft_engine::Session::new();
|
||||
for i in 0..3 {
|
||||
let id = session.catalog.alloc_photo_id();
|
||||
let p = Photo::new(id, Source::File { path: format!("/pics/{i}.jpg") }, "x.jpg", "JPEG", 60, 40, "2026-01-01T10:00:00");
|
||||
session.catalog.apply(Op::AddPhoto { photo: Box::new(p) }).unwrap();
|
||||
}
|
||||
session.selection.ids = session.catalog.photos().take(selected).map(|p| p.id).collect();
|
||||
let mut app = LightcraftApp::new(session, Services { png: None, ..Default::default() });
|
||||
app.ui.view = crate::state::ViewMode::PhotoGrid;
|
||||
let mut h = crate::headless::Headless::new(app, [1400.0, 900.0], 1.0);
|
||||
h.step();
|
||||
h.step();
|
||||
assert_eq!(h.app.session.selection.ids.len(), selected, "the selection is kept");
|
||||
let painted = h.painted_text();
|
||||
let expected = if selected == 0 { "3 photos".to_string() } else { format!("{selected} selected · 3 photos") };
|
||||
assert!(painted.contains(&expected), "{selected} selected: the header shows {expected:?}: {painted:?}");
|
||||
if selected == 0 {
|
||||
assert!(!painted.iter().any(|s| s.contains("selected ·")), "nothing selected, no count: {painted:?}");
|
||||
}
|
||||
}
|
||||
// a language whose word for "selected" agrees with the number reads "noun: number", right for one as for many
|
||||
for (locale, expected) in [(Locale::Es, "Seleccionadas: 1 · x"), (Locale::PtBr, "Selecionadas: 1 · x"), (Locale::Sv, "Markerade: 1 · x")] {
|
||||
crate::i18n::set_language(locale);
|
||||
let one = crate::i18n::tr_format!("{sel_n} selected · {counted}", sel_n = 1, counted = "x");
|
||||
crate::i18n::set_language(Locale::En);
|
||||
assert_eq!(one, expected, "{locale:?}");
|
||||
}
|
||||
}
|
||||
|
||||
fn text_bounds(shape: &egui::Shape, out: &mut Vec<Rect>) {
|
||||
match shape {
|
||||
egui::Shape::Text(text) => out.push(text.visual_bounding_rect()),
|
||||
|
||||
Reference in New Issue
Block a user