Merge pull request #2818 from nledford/looping-album-empty

LRC-LIB-SMARTCOLL: a smart album on a loop of albums holds no photos, and says which album it loops through
This commit is contained in:
FredApps
2026-11-26 19:24:29 +01:00
committed by GitHub
45 changed files with 562 additions and 9 deletions
+23 -1
View File
@@ -16,7 +16,7 @@
//! about contents ([`Catalog::follows_contents`], [`Catalog::content_moved`]).
//! The two texts follow every op that changes a photo's fields, and the photo moving to another place in memory.
use std::collections::{HashMap, HashSet};
use std::collections::{BTreeSet, HashMap, HashSet};
use std::sync::OnceLock;
use crate::{AlbumId, Catalog, Photo, PhotoId, Source, StackId};
@@ -39,6 +39,10 @@ pub(crate) struct Indexes {
/// File name, lower-cased ([`file_name_index_key`]) → the photos whose file has it (same
/// states as `folders`).
names: OnceLock<HashMap<String, HashSet<PhotoId>>>,
/// The smart albums on a loop (see [`crate::Catalog::album_on_a_loop`]). Built from the albums'
/// rules, so forgotten whenever an album is added or removed or its rules change (and by no
/// other op: photos never change which album tests which).
looping: OnceLock<BTreeSet<AlbumId>>,
/// Photo → its lower-cased searchable text ([`PhotoText`]), for the free-text search.
search: OnceLock<ByPhoto<PhotoText>>,
/// Photo → the lower-cased text a smart album's Text rule looks through ([`crate::rules::rule_text`]).
@@ -73,6 +77,12 @@ impl std::fmt::Debug for Indexes {
}
impl Indexes {
/// An op is about to add or remove an album or change its rules (the undo of any of them is
/// one of those too): the albums on a loop are worked out again when asked.
pub(crate) fn forget_loops(&mut self) {
self.looping.take();
}
/// Stack `id` held `old` and holds `new` now (empty: it was added, or is gone).
pub(crate) fn stack_changed(&mut self, id: StackId, old: &[PhotoId], new: &[PhotoId]) {
let Some(Some(m)) = self.stacks.get_mut() else { return };
@@ -369,6 +379,18 @@ pub(crate) fn content_key(p: &Photo) -> Option<&str> {
}
impl Catalog {
/// The smart albums that lead back to themselves through the albums they test, worked out once
/// (by [`crate::AlbumGraph`]) and kept until an album is added, removed or has its rules changed.
pub(crate) fn looping(&self) -> &BTreeSet<AlbumId> {
self.index.looping.get_or_init(|| crate::AlbumGraph::of(self.albums.values()).on_a_loop())
}
/// Whether the albums on a loop are worked out and kept now (what the tests look at).
#[cfg(test)]
pub(crate) fn loops_known(&self) -> bool {
self.index.looping.get().is_some()
}
/// The stack photo `photo` is in, by the index (built on first use).
pub(crate) fn stack_id_of(&self, photo: PhotoId) -> Option<StackId> {
let m = self.index.stacks.get_or_init(|| {
+32 -2
View File
@@ -610,8 +610,33 @@ impl Catalog {
/// Whether smart album `id` with `rules` (as [`Filter::prepare`]d) holds `p`.
fn smart_album_has(&self, id: AlbumId, rules: &Filter, prepared: &query::Prepared, p: &Photo) -> bool {
// guarded: a smart album testing smart albums can't loop or recurse without end
!p.deleted && rules::smart_album_holds(id, p.id, || rules.matches_in(p, self, prepared))
// an album on a loop holds nothing, whoever asks (see `album_on_a_loop`); beyond that, a
// smart album testing smart albums can't recurse without end (the guard)
!p.deleted && !self.looping().contains(&id) && rules::smart_album_holds(id, p.id, || rules.matches_in(p, self, prepared))
}
/// Whether album `id` is on a loop: a smart album that includes itself, directly or through
/// the smart albums it tests. Such an album holds no photos ([`Self::album_photos`],
/// [`Self::album_count`], [`Self::album_contains`] and the grid all agree), until its rules or
/// those of an album on the loop change. An album that only tests a looping album is not on
/// the loop: it is worked out as usual, seeing the looping album as empty.
pub fn album_on_a_loop(&self, id: AlbumId) -> bool {
self.looping().contains(&id)
}
/// For an album on a loop, an album it tests that leads back to it: the one to name when
/// saying why it is empty (itself when it tests itself and nothing else on the loop). `None`
/// for an album that is not on a loop.
pub fn album_loops_through(&self, id: AlbumId) -> Option<AlbumId> {
if !self.album_on_a_loop(id) {
return None;
}
let tested = self.albums.get(&id)?.smart.as_deref()?.albums_tested();
tested
.iter()
.copied()
.find(|b| *b != id && self.album_on_a_loop(*b) && self.album_reaches(*b, id))
.or_else(|| tested.contains(&id).then_some(id))
}
/// Whether smart album `from` tests `to`, directly or through the smart albums it tests (the
@@ -1051,6 +1076,7 @@ impl Catalog {
}
Op::AddAlbum { album } => {
self.plans = PlansMemo::default();
self.index.forget_loops();
if self.albums.contains_key(&album.id) {
return Err(CatalogError::Invalid(format!("album {:?} exists", album.id)));
}
@@ -1073,6 +1099,7 @@ impl Catalog {
}
Op::RemoveAlbum { id } => {
self.plans = PlansMemo::default();
self.index.forget_loops();
if self.albums.values().any(|a| a.parent == Some(id)) {
return Err(CatalogError::Invalid("folder is not empty".into()));
}
@@ -1134,6 +1161,7 @@ impl Catalog {
}
Op::SetAlbumRules { id, rules } => {
self.plans = PlansMemo::default();
self.index.forget_loops();
self.validate_rules(&rules)?;
let a = self.album_mut(id)?;
let Some(old) = a.smart.as_mut() else {
@@ -1694,6 +1722,8 @@ mod tests_lock;
#[cfg(all(test, not(target_arch = "wasm32")))]
mod tests_log_thread;
#[cfg(test)]
mod tests_looping_albums;
#[cfg(test)]
mod tests_opened_folder;
#[cfg(test)]
mod tests_repair;
+235
View File
@@ -0,0 +1,235 @@
//! A smart album on a loop (it includes itself through the albums it tests) holds nothing,
//! whichever way it is asked: its photos, its count, whether it holds one photo, the grid's query
//! for it. The rule, stated once:
//!
//! * an album **on** a loop (a ring of albums testing one another, or one testing itself) holds no
//! photos;
//! * an album **off** every loop is worked out as always, and one that tests a looping album sees
//! it as the empty album it is (so "is in A" matches nothing and "isn't in A" matches all);
//! * mending the loop (changing rules, removing an album) gives each album its photos back.
use super::*;
/// A smart album with `any` of the rules in `rules` (a JSON array).
fn any_of(id: u64, rules: serde_json::Value) -> Album {
let filter: Filter = serde_json::from_value(serde_json::json!({"ruleSet": {"match": "any", "rules": rules}})).unwrap();
Album { smart: Some(Box::new(filter)), ..Album::new(AlbumId(id), format!("Smart {id}")) }
}
fn in_album(op: &str, id: u64) -> serde_json::Value {
serde_json::json!({"field": "album", "op": op, "value": id})
}
fn picked() -> serde_json::Value {
serde_json::json!({"field": "flag", "op": "is", "value": "pick"})
}
fn rated(n: u64) -> serde_json::Value {
serde_json::json!({"field": "rating", "op": "gte", "value": n})
}
/// Three photos: `.0` is picked, `.1` is rated 5, `.2` is neither.
fn photos(c: &mut Catalog) -> (PhotoId, PhotoId, PhotoId) {
let mut add = |name: &str| {
let id = c.alloc_photo_id();
let p = Photo::new(id, Source::Demo { scene: 1 }, name, "JPEG", 600, 400, "2026-09-30T10:00:00");
c.apply(Op::AddPhoto { photo: Box::new(p) }).unwrap();
id
};
let ids = (add("picked.jpg"), add("rated.jpg"), add("plain.jpg"));
c.apply(Op::SetFlag { id: ids.0, flag: Flag::Pick }).unwrap();
c.apply(Op::SetRating { id: ids.1, rating: 5 }).unwrap();
ids
}
fn add(c: &mut Catalog, album: Album) {
c.apply(Op::AddAlbum { album }).unwrap();
}
/// What the grid shows for `album`: the query the sidebar click makes.
fn grid(c: &Catalog, album: u64) -> Vec<PhotoId> {
c.query(&Filter { album: Some(AlbumId(album)), ..Default::default() }, &Sort::default())
}
/// Every way of asking what an album holds agrees it holds `want`.
#[track_caller]
fn assert_holds(c: &Catalog, album: u64, want: &[PhotoId]) {
let mut want = want.to_vec();
want.sort();
let mut got = c.album_photos(AlbumId(album));
got.sort();
assert_eq!(got, want, "album_photos of {album}");
assert_eq!(c.album_count(AlbumId(album)), want.len(), "album_count of {album}");
let mut shown = grid(c, album);
shown.sort();
assert_eq!(shown, want, "the grid's source for {album}");
for p in c.photos() {
assert_eq!(c.album_contains(AlbumId(album), p), want.contains(&p.id), "album_contains of {album} for {:?}", p.id);
}
}
/// 1 ⇄ 2: each holds the photos of its own rule, or those of the other. Without the loop, 1 holds
/// the picked and the rated photo, and so does 2.
fn two_albums_in_a_loop() -> (Catalog, (PhotoId, PhotoId, PhotoId)) {
let mut c = Catalog::new();
let p = photos(&mut c);
add(&mut c, any_of(1, serde_json::json!([picked(), in_album("is", 2)])));
add(&mut c, any_of(2, serde_json::json!([rated(4), in_album("is", 1)])));
(c, p)
}
#[test]
fn two_albums_that_test_each_other_hold_nothing() {
let (c, _) = two_albums_in_a_loop();
assert_holds(&c, 1, &[]);
assert_holds(&c, 2, &[]);
}
#[test]
fn an_album_that_tests_itself_holds_nothing() {
let mut c = Catalog::new();
photos(&mut c);
add(&mut c, any_of(1, serde_json::json!([picked(), in_album("is", 1)])));
assert_holds(&c, 1, &[]);
}
#[test]
fn every_album_on_a_longer_ring_holds_nothing_and_the_ones_leading_into_it_do_not_count_as_on_it() {
let mut c = Catalog::new();
let (picked_photo, rated_photo, plain) = photos(&mut c);
// 1 → 2 → 3 → 1
add(&mut c, any_of(1, serde_json::json!([picked(), in_album("is", 2)])));
add(&mut c, any_of(2, serde_json::json!([rated(4), in_album("is", 3)])));
add(&mut c, any_of(3, serde_json::json!([rated(1), in_album("is", 1)])));
// 4 tests the ring (a tail into it), 5 tests 4: neither is on it
add(&mut c, any_of(4, serde_json::json!([rated(4), in_album("is", 1)])));
add(&mut c, any_of(5, serde_json::json!([in_album("is", 4)])));
for ring in [1, 2, 3] {
assert_holds(&c, ring, &[]);
}
assert_holds(&c, 4, &[rated_photo]);
assert_holds(&c, 5, &[rated_photo]);
let _ = (picked_photo, plain);
}
#[test]
fn a_smart_album_off_every_loop_is_as_it_was() {
let mut c = Catalog::new();
let (picked_photo, rated_photo, _) = photos(&mut c);
let (a, b) = (any_of(1, serde_json::json!([picked(), in_album("is", 2)])), any_of(2, serde_json::json!([rated(4), in_album("is", 1)])));
add(&mut c, a);
add(&mut c, b);
// 3 and 4 form a chain, no loop: 4 holds what 3 holds
add(&mut c, any_of(3, serde_json::json!([picked(), rated(4)])));
add(&mut c, any_of(4, serde_json::json!([in_album("is", 3)])));
assert_holds(&c, 3, &[picked_photo, rated_photo]);
assert_holds(&c, 4, &[picked_photo, rated_photo]);
}
#[test]
fn an_album_that_tests_a_looping_album_sees_it_as_empty() {
let (mut c, (a, b, d)) = two_albums_in_a_loop();
// 3 isn't on the loop; it asks about album 1
add(&mut c, any_of(3, serde_json::json!([in_album("is", 1)])));
let mut not_in_one = any_of(4, serde_json::json!([in_album("isNot", 1)]));
not_in_one.name = "Not in one".into();
add(&mut c, not_in_one);
assert_holds(&c, 3, &[]);
assert_holds(&c, 4, &[a, b, d]);
}
#[test]
fn a_regular_album_is_not_a_loop() {
let (mut c, (a, ..)) = two_albums_in_a_loop();
add(&mut c, Album { photos: vec![a], ..Album::new(AlbumId(9), "Plain") });
assert_holds(&c, 9, &[a]);
}
#[test]
fn mending_the_loop_gives_the_photos_back() {
let (mut c, (picked_photo, rated_photo, _)) = two_albums_in_a_loop();
assert_holds(&c, 1, &[]);
// 2 stops testing 1
let before = any_of(2, serde_json::json!([rated(4), in_album("is", 1)])).smart.unwrap();
let inv = c.apply(Op::SetAlbumRules { id: AlbumId(2), rules: any_of(2, serde_json::json!([rated(4)])).smart.unwrap() }).unwrap();
assert_holds(&c, 2, &[rated_photo]);
assert_holds(&c, 1, &[picked_photo, rated_photo]);
// undoing that brings the loop, and the emptiness, back
c.apply(inv).unwrap();
assert_eq!(c.album(AlbumId(2)).and_then(|a| a.smart.as_deref()), Some(&*before));
assert_holds(&c, 1, &[]);
assert_holds(&c, 2, &[]);
// removing 2 leaves 1 testing an album that is gone
c.apply(Op::RemoveAlbum { id: AlbumId(2) }).unwrap();
assert_holds(&c, 1, &[picked_photo]);
// adding it back closes the loop again
add(&mut c, any_of(2, serde_json::json!([rated(4), in_album("is", 1)])));
assert_holds(&c, 1, &[]);
}
#[test]
fn the_loop_can_say_which_album_it_goes_through() {
let (mut c, _) = two_albums_in_a_loop();
assert!(c.album_on_a_loop(AlbumId(1)) && c.album_on_a_loop(AlbumId(2)));
assert_eq!(c.album_loops_through(AlbumId(1)), Some(AlbumId(2)));
assert_eq!(c.album_loops_through(AlbumId(2)), Some(AlbumId(1)));
// 3 tests an album on the loop, and 4 tests itself as well as 3
add(&mut c, any_of(3, serde_json::json!([in_album("is", 1)])));
add(&mut c, any_of(4, serde_json::json!([in_album("is", 4)])));
assert!(!c.album_on_a_loop(AlbumId(3)), "a tail into a loop is not on it");
assert_eq!(c.album_loops_through(AlbumId(3)), None);
assert_eq!(c.album_loops_through(AlbumId(4)), Some(AlbumId(4)), "an album that tests itself loops through itself");
// a plain album and an album that does not exist
add(&mut c, Album::new(AlbumId(5), "Plain"));
assert!(!c.album_on_a_loop(AlbumId(5)) && !c.album_on_a_loop(AlbumId(99)));
assert_eq!(c.album_loops_through(AlbumId(5)), None);
}
#[test]
fn on_a_longer_ring_the_album_named_is_one_that_leads_back() {
let mut c = Catalog::new();
// 1 → 2 → 3 → 1, and 1 also tests 7, which tests itself (a loop of its own, not 1's)
add(&mut c, any_of(1, serde_json::json!([in_album("is", 7), in_album("is", 2)])));
add(&mut c, any_of(2, serde_json::json!([in_album("is", 3)])));
add(&mut c, any_of(3, serde_json::json!([in_album("is", 1)])));
add(&mut c, any_of(7, serde_json::json!([in_album("is", 7)])));
assert_eq!(c.album_loops_through(AlbumId(1)), Some(AlbumId(2)), "7 is on a loop, but not the one 1 is on");
assert_eq!(c.album_loops_through(AlbumId(2)), Some(AlbumId(3)));
assert_eq!(c.album_loops_through(AlbumId(3)), Some(AlbumId(1)));
}
/// Asking is cheap: the albums on a loop are worked out once, and again only after an op that adds
/// or removes an album or changes rules, not after the edits to photos the library sees all day.
#[test]
fn the_loops_are_remembered_until_an_album_changes() {
let (mut c, (a, ..)) = two_albums_in_a_loop();
assert!(!c.loops_known());
assert_holds(&c, 1, &[]);
assert!(c.loops_known());
c.apply(Op::SetRating { id: a, rating: 3 }).unwrap();
c.apply(Op::SetFlag { id: a, flag: Flag::Reject }).unwrap();
assert!(c.loops_known(), "photo edits don't change which album tests which");
c.apply(Op::SetAlbumRules { id: AlbumId(2), rules: any_of(2, serde_json::json!([rated(4)])).smart.unwrap() }).unwrap();
assert!(!c.loops_known(), "new rules");
assert!(!c.album_on_a_loop(AlbumId(1)));
assert!(c.loops_known());
add(&mut c, Album::new(AlbumId(9), "New"));
assert!(!c.loops_known(), "a new album");
assert!(!c.album_on_a_loop(AlbumId(1)));
c.apply(Op::RemoveAlbum { id: AlbumId(9) }).unwrap();
assert!(!c.loops_known(), "a removed album");
// a copy builds its own when asked
assert!(!c.album_on_a_loop(AlbumId(1)));
assert!(!c.clone().loops_known());
}
/// A refused op leaves no half-forgotten state behind: the answer after it is still right.
#[test]
fn a_refused_edit_leaves_the_answers_as_they_were() {
let (mut c, _) = two_albums_in_a_loop();
assert_holds(&c, 1, &[]);
assert!(c.apply(Op::SetAlbumRules { id: AlbumId(404), rules: any_of(1, serde_json::json!([rated(4)])).smart.unwrap() }).is_err());
assert!(c.apply(Op::AddAlbum { album: any_of(1, serde_json::json!([rated(4)])) }).is_err(), "the id is taken");
assert_holds(&c, 1, &[]);
assert_holds(&c, 2, &[]);
}
+1
View File
@@ -328,6 +328,7 @@
"File › Export… · File › Print… ({keys}).": "Soubor › Exportovat… · Soubor › Tisk… ({keys}).",
"{n} folder{} could not be read": "Složky, které se nepodařilo přečíst: {n}{:.0}",
"{n} file{} skipped (not a supported photo type)": "Přeskočené soubory (nejde o podporovaný typ fotografie): {n}{:.0}",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Vede zpět samo na sebe přes album „{}“: změňte pravidla jednoho alba ve smyčce (Upravit inteligentní album…)",
"Add {n} photo{} to “{}”": "Přidat do „{1}“ fotografie: {n}{0:.0}",
"{n} already there": "již tam je: {n}",
"Add “{keyword}” to {n} photo{}": "Přidat „{keyword}“ k fotografiím: {n}{:.0}",
+2
View File
@@ -2526,6 +2526,8 @@
"Next": "Další",
"Get Started": "Začít",
"Stopped at the scan limit: there may be more photos": "Zastaveno na limitu skenování: je možné, že existují další fotografie",
"This album is in a loop, so it shows nothing": "Toto album je ve smyčce, a proto nic nezobrazuje",
"It tests itself: change its rules (Edit Smart Album…)": "Testuje samo sebe: změňte jeho pravidla (Upravit inteligentní album…)",
"Can't add to an album folder": "Nelze přidat do složky alb",
"An album folder holds albums, not photos: drop on an album inside it": "Složka alb obsahuje alba, ne fotografie: pusťte je na album uvnitř",
"Can't add to a smart album": "Nelze přidat do inteligentního alba",
+1
View File
@@ -329,6 +329,7 @@
"Bring photos in with File › Import Photos… ({keys}).": "Fotos holen Sie mit Datei › Fotos importieren… ({keys}) in die Bibliothek.",
"View › Detail View ({keys}).": "Ansicht › Detailansicht ({keys}).",
"File › Export… · File › Print… ({keys}).": "Datei › Exportieren… · Datei › Drucken… ({keys}).",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Es führt über das Album „{}“ zu sich selbst zurück: Ändere die Regeln eines Albums im Kreis (Smart-Album bearbeiten…)",
"Add {n} photo{} to “{}”": "{n} Foto{0} zu „{1}“ hinzufügen",
"{n} already there": "{n} bereits enthalten",
"Add “{keyword}” to {n} photo{}": "„{keyword}“ zu {n} Foto{} hinzufügen",
+2
View File
@@ -3583,6 +3583,8 @@
"Welcome": "Willkommen",
"Next": "Weiter",
"Get Started": "Loslegen",
"This album is in a loop, so it shows nothing": "Dieses Album ist in einem Kreis und zeigt deshalb nichts",
"It tests itself: change its rules (Edit Smart Album…)": "Es prüft sich selbst: Ändere seine Regeln (Smart-Album bearbeiten…)",
"Can't add to an album folder": "Nicht zu einem Albenordner hinzufügbar",
"An album folder holds albums, not photos: drop on an album inside it": "Ein Albenordner enthält Alben, keine Fotos: auf ein Album darin ablegen",
"Can't add to a smart album": "Nicht zu einem Smart-Album hinzufügbar",
+1
View File
@@ -329,6 +329,7 @@
"Bring photos in with File › Import Photos… ({keys}).": "Importa fotos con Archivo › Importar fotos… ({keys}).",
"View › Detail View ({keys}).": "Vista › Vista de detalle ({keys}).",
"File › Export… · File › Print… ({keys}).": "Archivo › Exportar… · Archivo › Imprimir… ({keys}).",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Vuelve a sí mismo a través del álbum “{}”: cambia las reglas de uno de los álbumes del bucle (Editar álbum inteligente…)",
"Add {n} photo{} to “{}”": "Añadir {n} foto{0} a “{1}”",
"{n} already there": "ya en el álbum: {n}",
"Add “{keyword}” to {n} photo{}": "Añadir “{keyword}” a {n} foto{}",
+2
View File
@@ -2480,6 +2480,8 @@
"Welcome": "Bienvenido",
"Next": "Siguiente",
"Get Started": "Empezar",
"This album is in a loop, so it shows nothing": "Este álbum está en un bucle, así que no muestra nada",
"It tests itself: change its rules (Edit Smart Album…)": "Se comprueba a sí mismo: cambia sus reglas (Editar álbum inteligente…)",
"Can't add to an album folder": "No se puede añadir a una carpeta de álbumes",
"An album folder holds albums, not photos: drop on an album inside it": "Una carpeta de álbumes contiene álbumes, no fotos: suéltalas en un álbum de dentro",
"Can't add to a smart album": "No se puede añadir a un álbum inteligente",
+1
View File
@@ -325,6 +325,7 @@
"File › Export… · File › Print… ({keys}).": "Tiedosto › Vie… · Tiedosto › Tulosta… ({keys}).",
"{n} folder{} could not be read": "Kansiot, joita ei voitu lukea: {n}{:.0}",
"{n} file{} skipped (not a supported photo type)": "Ohitetut tiedostot (ei tuettu valokuvatyyppi): {n}{:.0}",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Se johtaa takaisin itseensä albumin ”{}” kautta: muuta jonkin silmukan albumin sääntöjä (Muokkaa älyalbumia…)",
"Add {n} photo{} to “{}”": "Lisää kuvia albumiin ”{1}”: {n}{0:.0}",
"Add “{keyword}” to {n} photo{}": "Lisää ”{keyword}” kuviin: {n}{:.0}",
"{n} already there": "jo albumissa: {n}",
+2
View File
@@ -2432,6 +2432,8 @@
"Folder name": "Kansion nimi",
"Its templates move to User Templates.": "Sen mallipohjat siirretään kansioon Käyttäjän mallipohjat.",
"Stopped at the scan limit: there may be more photos": "Skannauksen raja saavutettiin: valokuvia voi olla lisää",
"This album is in a loop, so it shows nothing": "Tämä albumi on silmukassa, joten se ei näytä mitään",
"It tests itself: change its rules (Edit Smart Album…)": "Se testaa itseään: muuta sen sääntöjä (Muokkaa älyalbumia…)",
"Filter settings": "Suodata asetuksia",
"No setting matches what is typed.": "Mikään asetus ei vastaa kirjoitettua.",
"Try one word, or part of one: the names of tabs and sections, labels and explanations are all looked through.": "Kokeile yhtä sanaa tai sen osaa: haku kattaa välilehtien ja osioiden nimet, otsikot ja selitykset.",
+1
View File
@@ -329,6 +329,7 @@
"Bring photos in with File › Import Photos… ({keys}).": "Importez des photos avec Fichier › Importer des photos… ({keys}).",
"View › Detail View ({keys}).": "Affichage › Vue de détail ({keys}).",
"File › Export… · File › Print… ({keys}).": "Fichier › Exporter… · Fichier › Imprimer… ({keys}).",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Il revient sur lui-même via l'album « {} » : modifiez les règles d'un album de la boucle (Modifier l'album intelligent…)",
"Add {n} photo{} to “{}”": "Ajouter {n} photo{} à « {} »",
"{n} already there": "{n} déjà présent(s)",
"Add “{keyword}” to {n} photo{}": "Ajouter « {keyword} » à {n} photo{}",
+2
View File
@@ -3661,6 +3661,8 @@
"Welcome": "Bienvenue",
"Next": "Suivant",
"Get Started": "Commencer",
"This album is in a loop, so it shows nothing": "Cet album est pris dans une boucle : il n'affiche rien",
"It tests itself: change its rules (Edit Smart Album…)": "Il se teste lui-même : modifiez ses règles (Modifier l'album intelligent…)",
"Can't add to an album folder": "Impossible d’ajouter à un dossier d’albums",
"An album folder holds albums, not photos: drop on an album inside it": "Un dossier d’albums contient des albums, pas des photos : déposez-les sur un album à l’intérieur",
"Can't add to a smart album": "Impossible d’ajouter à un album intelligent",
+1
View File
@@ -328,6 +328,7 @@
"File › Export… · File › Print… ({keys}).": "File › Ekspor… · File › Cetak… ({keys}).",
"{n} folder{} could not be read": "Folder yang tidak bisa dibaca: {n}{:.0}",
"{n} file{} skipped (not a supported photo type)": "File yang dilewati (bukan jenis foto yang didukung): {n}{:.0}",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Album ini kembali ke dirinya sendiri melalui album “{}”: ubah aturan salah satu album dalam perulangan (Edit album pintar…)",
"Add {n} photo{} to “{}”": "Tambahkan {n} foto{0:.0} ke “{1}”",
"Add “{keyword}” to {n} photo{}": "Tambahkan “{keyword}” ke {n} foto{:.0}",
"{n} already there": "{n} sudah ada",
+2
View File
@@ -2446,6 +2446,8 @@
"Folder name": "Nama folder",
"Its templates move to User Templates.": "Templatnya dipindahkan ke Templat pengguna.",
"Stopped at the scan limit: there may be more photos": "Berhenti pada batas pemindaian: mungkin masih ada foto",
"This album is in a loop, so it shows nothing": "Album ini berada dalam perulangan, jadi tidak menampilkan apa pun",
"It tests itself: change its rules (Edit Smart Album…)": "Album ini menjadikan dirinya sendiri syarat: ubah aturannya (Edit album pintar…)",
"Filter settings": "Filter pengaturan",
"No setting matches what is typed.": "Tidak ada pengaturan yang cocok dengan yang diketik.",
"Try one word, or part of one: the names of tabs and sections, labels and explanations are all looked through.": "Coba satu kata atau sebagiannya: yang dicari adalah nama tab dan bagian, label, serta penjelasan.",
+1
View File
@@ -328,6 +328,7 @@
"File › Export… · File › Print… ({keys}).": "File › Esporta… · File › Stampa… ({keys}).",
"{n} folder{} could not be read": "Cartelle non leggibili: {n}{:.0}",
"{n} file{} skipped (not a supported photo type)": "File saltati (non è un tipo di foto supportato): {n}{:.0}",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Ritorna su se stesso attraverso l'album “{}”: modifica le regole di un album del ciclo (Modifica album smart…)",
"Add {n} photo{} to “{}”": "Aggiungi {n} foto{0:.0} a “{1}”",
"{n} already there": "{n} già presenti",
"Add “{keyword}” to {n} photo{}": "Aggiungi “{keyword}” a {n} foto{:.0}",
+2
View File
@@ -2641,6 +2641,8 @@
"Next": "Avanti",
"Get Started": "Inizia",
"Stopped at the scan limit: there may be more photos": "Fermati al limite di scansione: potrebbero esserci altre foto",
"This album is in a loop, so it shows nothing": "Questo album è in un ciclo, quindi non mostra nulla",
"It tests itself: change its rules (Edit Smart Album…)": "Verifica se stesso: modifica le sue regole (Modifica album smart…)",
"Can't add to an album folder": "Impossibile aggiungere a una cartella di album",
"An album folder holds albums, not photos: drop on an album inside it": "Una cartella di album contiene album, non foto: rilascia su un album al suo interno",
"Can't add to a smart album": "Impossibile aggiungere a un album smart",
+1
View File
@@ -329,6 +329,7 @@
"Bring photos in with File › Import Photos… ({keys}).": "ファイル › 写真を読み込む… ({keys}) で写真を読み込みます。",
"View › Detail View ({keys}).": "表示 › 詳細表示 ({keys})。",
"File › Export… · File › Print… ({keys}).": "ファイル › 書き出す… · ファイル › 印刷… ({keys})。",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "アルバム「{}」を通じて自分自身に戻っています。循環しているアルバムのどれかの条件を変更してください(スマートアルバムを編集…)",
"Add {n} photo{} to “{}”": "{n}枚を「{1}」に追加{0:.0}",
"{n} already there": "{n}枚は追加済み",
"Add “{keyword}” to {n} photo{}": "写真{n}枚に「{keyword}」を追加{:.0}",
+2
View File
@@ -2479,6 +2479,8 @@
"Welcome": "ようこそ",
"Next": "次へ",
"Get Started": "始める",
"This album is in a loop, so it shows nothing": "このアルバムは循環しているため、何も表示されません",
"It tests itself: change its rules (Edit Smart Album…)": "自分自身を条件にしています。条件を変更してください(スマートアルバムを編集…)",
"Can't add to an album folder": "アルバムフォルダには追加できません",
"An album folder holds albums, not photos: drop on an album inside it": "アルバムフォルダに入れられるのはアルバムだけです:中のアルバムにドロップしてください",
"Can't add to a smart album": "スマートアルバムには追加できません",
+1
View File
@@ -331,6 +331,7 @@
"File › Export… · File › Print… ({keys}).": "ფაილი › ექსპორტი… · ფაილი › დაბეჭდვა… ({keys}).",
"{n} folder{} could not be read": "საქაღალდეები, რომლებიც ვერ წაიკითხა: {n}{:.0}",
"{n} file{} skipped (not a supported photo type)": "გამოტოვებული ფაილები (მხარდაუჭერელი ფოტოს ტიპია): {n}{:.0}",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "ის საკუთარ თავს უბრუნდება ალბომის „{}“ გავლით: შეცვალეთ ციკლში მყოფი ერთ-ერთი ალბომის წესები (სმარტ-ალბომის რედაქტირება…)",
"Add {n} photo{} to “{}”": "დაამატეთ ფოტო „{1}“-ში: {n}{0:.0}",
"{n} already there": "{n} უკვე არის",
"Add “{keyword}” to {n} photo{}": "დაამატეთ „{keyword}“ ფოტოებს: {n}{:.0}",
+2
View File
@@ -3742,6 +3742,8 @@
"Folder name": "საქაღალდის სახელი",
"Its templates move to User Templates.": "მისი შაბლონები გადავა „მომხმარებლის შაბლონებში“.",
"Stopped at the scan limit: there may be more photos": "სკანირების ლიმიტზე გაჩერდა: შესაძლოა სხვა ფოტოებიც არის",
"This album is in a loop, so it shows nothing": "ეს ალბომი ციკლშია, ამიტომ არაფერს აჩვენებს",
"It tests itself: change its rules (Edit Smart Album…)": "ის საკუთარ თავს ამოწმებს: შეცვალეთ მისი წესები (სმარტ-ალბომის რედაქტირება…)",
"Filter settings": "პარამეტრების გაფილტვრა",
"No setting matches what is typed.": "აკრეფილს არც ერთი პარამეტრი არ ემთხვევა.",
"Try one word, or part of one: the names of tabs and sections, labels and explanations are all looked through.": "სცადეთ ერთი სიტყვა ან მისი ნაწილი: იძებნება ჩანართებისა და სექციების სახელებში, წარწერებსა და განმარტებებში.",
+1
View File
@@ -328,6 +328,7 @@
"File › Export… · File › Print… ({keys}).": "Plik › Eksportuj… · Plik › Drukuj… ({keys}).",
"{n} folder{} could not be read": "Nie udało się odczytać folderów: {n}{:.0}",
"{n} file{} skipped (not a supported photo type)": "Pominięte pliki (nieobsługiwany typ zdjęcia): {n}{:.0}",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Wraca do siebie przez album „{}”: zmień reguły jednego z albumów w pętli (Edytuj album inteligentny…)",
"Add {n} photo{} to “{}”": "Dodaj do „{1}” — zdjęcia: {n}{0:.0}",
"{n} already there": "{n} już tam jest",
"Add “{keyword}” to {n} photo{}": "Dodaj „{keyword}” do zdjęć: {n}{:.0}",
+2
View File
@@ -2404,6 +2404,8 @@
"Next": "Dalej",
"Get Started": "Zaczynamy",
"Stopped at the scan limit: there may be more photos": "Zatrzymano na limicie skanowania: możliwe, że jest więcej zdjęć",
"This album is in a loop, so it shows nothing": "Ten album jest w pętli, więc niczego nie pokazuje",
"It tests itself: change its rules (Edit Smart Album…)": "Sprawdza samego siebie: zmień jego reguły (Edytuj album inteligentny…)",
"Can't add to an album folder": "Nie można dodać do folderu albumów",
"An album folder holds albums, not photos: drop on an album inside it": "Folder albumów zawiera albumy, nie zdjęcia: upuść na album w jego wnętrzu",
"Can't add to a smart album": "Nie można dodać do albumu inteligentnego",
@@ -329,6 +329,7 @@
"Bring photos in with File › Import Photos… ({keys}).": "Traga fotos com Arquivo › Importar fotos… ({keys}).",
"View › Detail View ({keys}).": "Exibir › Exibição de detalhe ({keys}).",
"File › Export… · File › Print… ({keys}).": "Arquivo › Exportar… · Arquivo › Imprimir… ({keys}).",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Ele volta para si mesmo pelo álbum “{}”: mude as regras de um álbum do ciclo (Editar álbum inteligente…)",
"Add {n} photo{} to “{}”": "Adicionar {n} foto{0} a “{1}”",
"{n} already there": "já no álbum: {n}",
"Add “{keyword}” to {n} photo{}": "Adicionar “{keyword}” a {n} foto{}",
+2
View File
@@ -2324,6 +2324,8 @@
"Welcome": "Bem-vindo",
"Next": "Próximo",
"Get Started": "Começar",
"This album is in a loop, so it shows nothing": "Este álbum está em um ciclo, então não mostra nada",
"It tests itself: change its rules (Edit Smart Album…)": "Ele testa a si mesmo: mude as regras dele (Editar álbum inteligente…)",
"Can't add to an album folder": "Não é possível adicionar a uma pasta de álbuns",
"An album folder holds albums, not photos: drop on an album inside it": "Uma pasta de álbuns contém álbuns, não fotos: solte em um álbum dentro dela",
"Can't add to a smart album": "Não é possível adicionar a um álbum inteligente",
+1
View File
@@ -329,6 +329,7 @@
"Bring photos in with File › Import Photos… ({keys}).": "Фотографии добавляются через Файл › Импорт фото… ({keys}).",
"View › Detail View ({keys}).": "Вид › Режим детализации ({keys}).",
"File › Export… · File › Print… ({keys}).": "Файл › Экспорт… · Файл › Печать… ({keys}).",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Он возвращается к себе через альбом «{}»: измените условия одного из альбомов в цикле (Изменить смарт-альбом…)",
"Add {n} photo{} to “{}”": "Добавить в «{1}» фото: {n}{0:.0}",
"{n} already there": "{n} уже там",
"Add “{keyword}” to {n} photo{}": "Добавить «{keyword}» к фото: {n}{:.0}",
+2
View File
@@ -2686,6 +2686,8 @@
"Welcome": "Добро пожаловать",
"Next": "Далее",
"Get Started": "Начать",
"This album is in a loop, so it shows nothing": "Этот альбом попал в цикл, поэтому ничего не показывает",
"It tests itself: change its rules (Edit Smart Album…)": "Он проверяет сам себя: измените его условия (Изменить смарт-альбом…)",
"Can't add to an album folder": "Нельзя добавить в папку альбомов",
"An album folder holds albums, not photos: drop on an album inside it": "В папке альбомов лежат альбомы, а не фото: бросьте на альбом внутри неё",
"Can't add to a smart album": "Нельзя добавить в смарт-альбом",
+1
View File
@@ -336,6 +336,7 @@
"File › Export… · File › Print… ({keys}).": "Fil › Exportera… · Fil › Skriv ut… ({keys}).",
"{n} folder{} could not be read": "Mappar som inte gick att läsa: {n}{:.0}",
"{n} file{} skipped (not a supported photo type)": "Hoppade över filer (fotoformat som inte stöds): {n}{:.0}",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Det leder tillbaka till sig självt via albumet ”{}”: ändra reglerna för ett av albumen i loopen (Redigera smart album…)",
"Adjustments: {n}": "Justeringar: {n}",
"Add {n} photo{} to “{}”": "Lägg till foton i ”{1}”: {n}{0:.0}",
"Add “{keyword}” to {n} photo{}": "Lägg till ”{keyword}” på foton: {n}{:.0}",
+2
View File
@@ -3859,6 +3859,8 @@
"Folder name": "Mappnamn",
"Its templates move to User Templates.": "Dess mallar flyttas till Användarmallar.",
"Stopped at the scan limit: there may be more photos": "Stoppade vid skanningsgränsen: det kan finnas fler foton",
"This album is in a loop, so it shows nothing": "Det här albumet ingår i en loop och visar därför ingenting",
"It tests itself: change its rules (Edit Smart Album…)": "Det testar sig självt: ändra dess regler (Redigera smart album…)",
"Filter settings": "Filtrera inställningar",
"No setting matches what is typed.": "Ingen inställning matchar det som skrivits.",
"Try one word, or part of one: the names of tabs and sections, labels and explanations are all looked through.": "Prova ett ord eller en del av ett: namnen på flikar och avsnitt, etiketter och förklaringar genomsöks.",
+1
View File
@@ -329,6 +329,7 @@
"Bring photos in with File › Import Photos… ({keys}).": "Фотографії імпортуйте через Файл › Імпортувати фото… ({keys}).",
"View › Detail View ({keys}).": "Вигляд › Детальне подання ({keys}).",
"File › Export… · File › Print… ({keys}).": "Файл › Експортувати… · Файл › Друк… ({keys}).",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Він повертається до себе через альбом «{}»: змініть правила одного з альбомів у циклі (Редагувати смарт-альбом…)",
"Add {n} photo{} to “{}”": "Додати до «{1}» фото: {n}{0:.0}",
"{n} already there": "{n} уже там",
"Add “{keyword}” to {n} photo{}": "Додати «{keyword}» до фото: {n}{:.0}",
+2
View File
@@ -2476,6 +2476,8 @@
"Welcome": "Ласкаво просимо",
"Next": "Далі",
"Get Started": "Почати",
"This album is in a loop, so it shows nothing": "Цей альбом потрапив у цикл, тому нічого не показує",
"It tests itself: change its rules (Edit Smart Album…)": "Він перевіряє сам себе: змініть його правила (Редагувати смарт-альбом…)",
"Can't add to an album folder": "Не можна додати до теки альбомів",
"An album folder holds albums, not photos: drop on an album inside it": "У теці альбомів лежать альбоми, а не фото: киньте на альбом усередині неї",
"Can't add to a smart album": "Не можна додати до смарт-альбому",
+1
View File
@@ -325,6 +325,7 @@
"File › Export… · File › Print… ({keys}).": "Tệp › Xuất… · Tệp › In… ({keys}).",
"{n} folder{} could not be read": "Thư mục không đọc được: {n}{:.0}",
"{n} file{} skipped (not a supported photo type)": "Đã bỏ qua tệp (không phải loại ảnh được hỗ trợ): {n}{:.0}",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "Album này quay lại chính nó qua album «{}»: hãy đổi quy tắc của một album trong vòng lặp (Chỉnh sửa album thông minh…)",
"Add {n} photo{} to “{}”": "Thêm {n} ảnh{0:.0} vào “{1}”",
"Add “{keyword}” to {n} photo{}": "Thêm “{keyword}” vào {n} ảnh{:.0}",
"{n} already there": "{n} đã có sẵn",
+2
View File
@@ -2758,6 +2758,8 @@
"Folder name": "Tên thư mục",
"Its templates move to User Templates.": "Các mẫu trong đó sẽ được chuyển vào Mẫu người dùng.",
"Stopped at the scan limit: there may be more photos": "Đã dừng ở giới hạn quét: có thể còn ảnh khác",
"This album is in a loop, so it shows nothing": "Album này nằm trong một vòng lặp nên không hiển thị gì",
"It tests itself: change its rules (Edit Smart Album…)": "Album này tự kiểm tra chính nó: hãy đổi quy tắc của nó (Chỉnh sửa album thông minh…)",
"Filter settings": "Lọc cài đặt",
"No setting matches what is typed.": "Không có cài đặt nào khớp với nội dung đã nhập.",
"Try one word, or part of one: the names of tabs and sections, labels and explanations are all looked through.": "Hãy thử một từ hoặc một phần của từ: tên các tab và mục, nhãn và phần giải thích đều được tìm.",
@@ -329,6 +329,7 @@
"Bring photos in with File › Import Photos… ({keys}).": "通过 文件 › 导入照片… ({keys}) 导入照片。",
"View › Detail View ({keys}).": "视图 › 详细视图 ({keys})。",
"File › Export… · File › Print… ({keys}).": "文件 › 导出… · 文件 › 打印… ({keys})。",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "它通过相册“{0}”回到自身:请更改循环中某个相册的规则(编辑智能相册…)",
"Add {n} photo{} to “{}”": "将 {n} 张照片添加到“{1}”{0:.0}",
"{n} already there": "{n} 张已在其中",
"Add “{keyword}” to {n} photo{}": "将“{keyword}”添加到 {n} 张照片{:.0}",
+2
View File
@@ -2479,6 +2479,8 @@
"Welcome": "欢迎",
"Next": "下一步",
"Get Started": "开始使用",
"This album is in a loop, so it shows nothing": "此相册处于循环中,因此不显示任何内容",
"It tests itself: change its rules (Edit Smart Album…)": "它引用了自身:请更改其规则(编辑智能相册…)",
"Can't add to an album folder": "无法添加到相册文件夹",
"An album folder holds albums, not photos: drop on an album inside it": "相册文件夹里放的是相册,不是照片:请拖到其中的某个相册上",
"Can't add to a smart album": "无法添加到智能相册",
@@ -329,6 +329,7 @@
"Bring photos in with File › Import Photos… ({keys}).": "透過 檔案 › 匯入照片… ({keys}) 匯入照片。",
"View › Detail View ({keys}).": "檢視 › 詳細檢視 ({keys})。",
"File › Export… · File › Print… ({keys}).": "檔案 › 匯出… · 檔案 › 列印… ({keys})。",
"It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)": "它透過相簿「{}」回到自身:請變更循環中某個相簿的規則(編輯智慧型相簿…)",
"Add {n} photo{} to “{}”": "將 {n} 張照片加入「{1}」{0:.0}",
"{n} already there": "{n} 張已在其中",
"Add “{keyword}” to {n} photo{}": "將「{keyword}」加入 {n} 張照片{:.0}",
+2
View File
@@ -2480,6 +2480,8 @@
"Welcome": "歡迎",
"Next": "下一步",
"Get Started": "開始使用",
"This album is in a loop, so it shows nothing": "此相簿處於循環中,因此不顯示任何內容",
"It tests itself: change its rules (Edit Smart Album…)": "它引用了自身:請變更其規則(編輯智慧型相簿…)",
"Can't add to an album folder": "無法加入相簿資料夾",
"An album folder holds albums, not photos: drop on an album inside it": "相簿資料夾裡放的是相簿,不是照片:請拖到其中的某個相簿上",
"Can't add to a smart album": "無法加入智慧型相簿",
+14
View File
@@ -397,6 +397,20 @@ pub fn source_title(session: &lightcraft_engine::Session) -> String {
}
}
/// For a smart album on a loop (it includes itself through the albums it tests, so it holds no
/// photos): what the album's empty view says, as its title and what to do about it, naming the
/// album the loop goes through. `None` for an album that is not on a loop.
pub fn album_loop_note(catalog: &lightcraft_catalog::Catalog, id: lightcraft_catalog::AlbumId) -> Option<(String, String)> {
let through = catalog.album_loops_through(id)?;
let body = if through == id {
tr("It tests itself: change its rules (Edit Smart Album…)").to_string()
} else {
let name = catalog.album(through).map(|a| a.name.clone()).unwrap_or_default();
tr_format!("It leads back to itself through “{}”: change the rules of one album on the loop (Edit Smart Album…)", name)
};
Some((tr("This album is in a loop, so it shows nothing").to_string(), body))
}
/// A date group heading (`2026-09-20`, `2026-09`, `2026`) in the UI language: the grid's full
/// form, or the date sidebar's `short` one ("Sunday, 20" / "September" / "2026"). English keeps the
/// catalog's own wording; every other language formats it with its `*-formats.json` date
+15 -4
View File
@@ -33,7 +33,7 @@ pub mod strip;
pub mod topbar;
pub mod unnamed;
use egui::{Align2, Rect, pos2, vec2};
use egui::{Rect, pos2, vec2};
use crate::LightcraftApp;
pub use crate::dialogs;
@@ -115,12 +115,23 @@ pub fn toast(app: &mut LightcraftApp, ctx: &egui::Context) {
ctx.request_repaint_after(std::time::Duration::from_millis(30));
}
/// Paint a centred, dimmed message (empty states).
/// Paint a centred, dimmed message (empty states). Each line wraps to the area, so a long one (a
/// translation, an album named in it) is not cut off at its edges.
pub fn empty_message(ui: &egui::Ui, rect: Rect, title: &str, body: &str) {
let t = Tokens::get(ui.ctx());
let p = ui.painter();
p.text(rect.center() - vec2(0.0, 12.0), Align2::CENTER_CENTER, crate::i18n::tr(title), t.semibold(18.0), t.text_label);
p.text(rect.center() + vec2(0.0, 14.0), Align2::CENTER_CENTER, crate::i18n::tr(body), t.font(13.0), t.text_dim);
let wrap = (rect.width() - 32.0).max(120.0);
let lay = |text: &str, font: egui::FontId, color: egui::Color32| {
let mut job = egui::text::LayoutJob::simple(text.to_owned(), font, color, wrap);
job.halign = egui::Align::Center;
p.layout_job(job)
};
let title = lay(crate::i18n::tr(title), t.semibold(18.0), t.text_label);
let body = lay(crate::i18n::tr(body), t.font(13.0), t.text_dim);
// as one block, centred: one line each sits where the two lines always sat
let top = rect.center().y - (title.size().y + 8.0 + body.size().y) / 2.0;
p.galley(pos2(rect.center().x, top), title.clone(), t.text_label);
p.galley(pos2(rect.center().x, top + title.size().y + 8.0), body, t.text_dim);
}
/// A button under an empty state's message: the command it runs, its label, and the id it is
+8 -1
View File
@@ -317,7 +317,14 @@ fn show_inner(app: &mut LightcraftApp, ui: &mut egui::Ui) {
}
app.canvas_rect = Some(ui.max_rect());
if ids.is_empty() {
if !chips.is_empty() {
// an album on a loop is empty because of the loop, whatever filters are on
let loop_note = match app.session.source {
lightcraft_engine::LibrarySource::Album(id) => crate::i18n::album_loop_note(&app.session.catalog, id),
_ => None,
};
if let Some((title, body)) = loop_note {
super::empty_message(ui, ui.max_rect(), &title, &body);
} else if !chips.is_empty() {
let body = match total {
Some(n) if n > 0 => {
crate::i18n::tr_format!("{n} photos in {} are hidden by the filters above", crate::i18n::source_title(&app.session), n = n)
+6
View File
@@ -88,6 +88,9 @@ fn albums_tree(
let label = if target == Some(a.id) { format!("{} +", a.name) } else { a.name.clone() };
// a smart album whose rules no longer check (an album they test was deleted) says so
let problems = app.caches.smart_album_problems(&app.session.catalog).get(&a.id).cloned().unwrap_or_default();
// an album on a loop holds nothing: its tooltip says so, and through which album (the ⚠ is
// there already: a loop is one of the problems it reports)
let loop_note = crate::i18n::album_loop_note(&app.session.catalog, a.id);
let label = if problems.is_empty() { label } else { format!("⚠ {label}") };
let mut resp = Row::new(&format!("album:{}", a.id.0), icon, &label)
.count(n)
@@ -124,6 +127,9 @@ fn albums_tree(
tip.push_str(&crate::i18n::problem_line(p));
}
}
if let Some((title, body)) = &loop_note {
tip.push_str(&format!("\n\n{title}\n{body}"));
}
resp = resp.on_hover_text(tip);
}
if resp.clicked() {
+1
View File
@@ -77,6 +77,7 @@ mod library_problem;
mod lifecycle_037;
mod lightroom_destination;
mod lights_out;
mod looping_albums;
mod mask_effects;
mod masking;
mod masking_layout;
+163
View File
@@ -0,0 +1,163 @@
//! A smart album on a loop holds nothing, and says why: its empty view and its sidebar row name
//! the album the loop goes through. An empty album that is not on a loop says nothing of loops,
//! and neither does one that only tests a looping album.
use std::time::Duration;
use lightcraft_catalog::{Album, AlbumId, Filter, Op};
use serde_json::json;
use crate::headless::Headless;
use crate::{LightcraftApp, Services};
const T: Duration = Duration::from_secs(20);
const SETTLE: Duration = Duration::from_secs(120);
const TITLE: &str = "This album is in a loop, so it shows nothing";
fn demo() -> Headless {
let services = Services { png: None, ..Default::default() };
let app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), services);
let mut h = Headless::new(app, [1400.0, 900.0], 1.0);
let r = h.request("ui.set", json!({"view": "photoGrid", "leftPanel": true}), T);
assert_eq!(r["ok"], true, "{r}");
h.settle(SETTLE);
h
}
/// A smart album with `any` of the rules.
fn smart(id: u64, name: &str, rules: serde_json::Value) -> Album {
let filter: Filter = serde_json::from_value(json!({"ruleSet": {"match": "any", "rules": rules}})).unwrap();
Album { smart: Some(Box::new(filter)), ..Album::new(AlbumId(id), name) }
}
fn is_in(id: u64) -> serde_json::Value {
json!({"field": "album", "op": "is", "value": id})
}
fn show(h: &mut Headless, album: u64) {
let r = h.request("engine.execute", json!({"command": "library.source", "params": {"kind": "album", "id": album}}), T);
assert_eq!(r["ok"], true, "{r}");
h.settle(SETTLE);
}
fn painted(h: &Headless) -> Vec<String> {
h.painted_text()
}
/// Alpha (10) and Beta (11) test each other; Gamma (12) tests Alpha without being on the loop;
/// Delta (13) tests itself; Quiet (14) is an ordinary smart album that happens to match nothing.
fn with_a_loop() -> Headless {
let mut h = demo();
let rating = json!({"field": "rating", "op": "gte", "value": 1});
let none = json!({"field": "keywords", "op": "contains", "value": "no-such-keyword"});
for album in [
smart(10, "Alpha", json!([rating, is_in(11)])),
smart(11, "Beta", json!([rating, is_in(10)])),
smart(12, "Gamma", json!([is_in(10)])),
smart(13, "Delta", json!([rating, is_in(13)])),
smart(14, "Quiet", json!([none])),
] {
// An edit can no longer make a loop (the catalog refuses it), but a library from before that
// rule still opens with one: the journal replays its ops the way `apply` does here, so the
// album the loop leaves on screen is the one the user still sees.
h.app.session.catalog.apply(Op::AddAlbum { album }).unwrap();
}
h.settle(SETTLE);
h
}
// Scenario: an album on a loop is empty, and its empty view names the album it loops through
#[test]
fn an_album_on_a_loop_says_it_is_empty_because_of_the_loop() {
let mut h = with_a_loop();
show(&mut h, 10);
assert_eq!(h.app.session.visible_cloned().len(), 0);
let text = painted(&h);
assert!(text.iter().any(|t| t == TITLE), "{text:?}");
assert!(text.iter().any(|t| t.contains("“Beta”") && t.contains("Edit Smart Album…")), "the body names the album the loop goes through: {text:?}");
assert!(text.iter().all(|t| t != "No photos"), "{text:?}");
// the other way round, and an album that tests itself
show(&mut h, 11);
assert!(painted(&h).iter().any(|t| t.contains("“Alpha”")));
show(&mut h, 13);
let text = painted(&h);
assert!(text.iter().any(|t| t == TITLE), "{text:?}");
assert!(text.iter().any(|t| t.starts_with("It tests itself")), "{text:?}");
}
// Scenario: a filter on top doesn't hide the reason
#[test]
fn the_loop_is_the_reason_even_with_a_filter_on() {
let mut h = with_a_loop();
show(&mut h, 10);
let r = h.request("engine.execute", json!({"command": "library.filter", "params": {"rating": 3}}), T);
assert_eq!(r["ok"], true, "{r}");
h.settle(SETTLE);
assert!(painted(&h).iter().any(|t| t == TITLE));
}
// Scenario: an album that is not on a loop says nothing of loops
#[test]
fn an_empty_album_off_every_loop_does_not_blame_a_loop() {
let mut h = with_a_loop();
// empty by its own rule
show(&mut h, 14);
let text = painted(&h);
assert!(text.iter().all(|t| t != TITLE && !t.starts_with("It leads back")), "{text:?}");
assert!(text.iter().any(|t| t == "No photos"), "{text:?}");
// empty because the album it tests holds nothing, but not on the loop itself
show(&mut h, 12);
assert_eq!(h.app.session.visible_cloned().len(), 0);
let text = painted(&h);
assert!(text.iter().all(|t| t != TITLE), "{text:?}");
}
// Scenario: the sidebar marks the looping albums, and only those (the mark predates the loop rule:
// a loop is among the problems a smart album reports)
#[test]
fn the_sidebar_marks_the_albums_on_a_loop() {
let h = with_a_loop();
assert!(h.app.widgets.iter().any(|(w, _)| w == "source:album:10"), "the rows are on screen");
let has = |id: u64| h.app.widgets.iter().any(|(w, _)| *w == format!("albumProblem:{id}"));
assert!(has(10) && has(11) && has(13), "the albums on a loop carry the mark");
assert!(!has(12) && !has(14), "an album off every loop does not");
let text = painted(&h);
assert!(text.iter().any(|t| t.starts_with('⚠') && t.contains("Alpha")), "{text:?}");
}
#[test]
fn the_note_names_the_album_the_loop_goes_through() {
use lightcraft_catalog::Catalog;
let mut c = Catalog::new();
for album in [smart(1, "Alpha", json!([is_in(2)])), smart(2, "Beta", json!([is_in(1)])), smart(3, "Plain", json!([]))] {
c.apply(Op::AddAlbum { album }).unwrap();
}
let (title, body) = crate::i18n::album_loop_note(&c, AlbumId(1)).expect("on a loop");
assert_eq!(title, TITLE);
assert!(body.contains("Beta"));
assert!(crate::i18n::album_loop_note(&c, AlbumId(3)).is_none());
}
// Scenario: in a narrow grid the message wraps instead of running off its edges
#[test]
fn the_message_wraps_in_a_narrow_grid() {
let mut h = with_a_loop();
let r = h.request("ui.resize", json!({"width": 900, "height": 700}), T);
assert_eq!(r["ok"], true, "{r}");
show(&mut h, 10);
let canvas = h.app.canvas_rect.expect("the grid is drawn");
let lines: Vec<(f32, usize, egui::Rect)> = h
.view
.painted_shapes()
.into_iter()
.filter_map(|s| match s {
egui::epaint::Shape::Text(t) if t.galley.job.text.starts_with("It leads back") => {
Some((t.galley.size().x, t.galley.rows.len(), t.visual_bounding_rect()))
}
_ => None,
})
.collect();
let (_, rows, bounds) = lines.first().copied().expect("the body is painted");
assert!(rows > 1, "the body is wider than the grid, so it takes more than one row");
assert!(bounds.left() >= canvas.left() && bounds.right() <= canvas.right(), "{bounds:?} stays inside {canvas:?}");
}
File diff suppressed because one or more lines are too long
+12
View File
@@ -682,6 +682,18 @@
white balance.) On a test library of 100,000 photos, 90 % unedited JPEGs, 8 % raws with one as-shot white balance
and 2 % edited, a photo takes about 2.8 kB where it took 4.4 kB (285 MB instead of 441 MB). Nothing changes on
screen, and the library's files are byte for byte what they were, so earlier versions open them as before.
### An album caught in a loop is empty, and says so
- A smart album that tests another album, which tests it back (or that tests itself), used to show a share of
its photos, and which photos depended on the album you asked about. Now every album on such a loop shows no
photos, however you look at it: in the grid, in the count beside it in the sidebar, and in an Album rule of
another smart album.
- The empty album says why instead of "No photos": "This album is in a loop, so it shows nothing", then the album it
loops through and where to fix it (Edit Smart Album…). The row in the sidebar keeps its ⚠, and hovering it says the
same.
- An album that only tests a looping album is not on the loop: it keeps working, and sees the looping album as empty
(so an Album rule set to "isn't" that album matches every photo). Change the rules of one album on the loop and its albums hold
their photos again.
- A library that already holds such a loop opens as before; only what the albums on it show changes.
## 2026-10-23
### AI Denoise works out of the box