mirror of
https://github.com/storytold/lightcraft.git
synced 2026-12-02 20:19:40 -05:00
* LR-FILT-RATING: = or ≤ no stars shows the unrated photos instead of every photo (#3417) * Saving the view as a smart album keeps the rating's stars with its operator * LR-FILT-RATING: deleting the keyword of a filter put aside keeps = or ≤ no stars Enable Filters can put aside a filter of a keyword and "= no stars" or "≤ no stars". Deleting that keyword dropped the whole filter, as if the rating operator alone filtered nothing. Since #3417 those operators show the unrated photos, so the rule is still put aside and comes back. "≥ no stars" still filters nothing and is dropped. * style: apply CI formatting to saved rating filters * refactor: separate no-match Smart Album rendering --------- Co-authored-by: FredApps <[email protected]>
This commit is contained in:
1 parent
5f79f1f8c5
commit
56aa693e17
14 files changed
+288
-35
No files matched your search
@@ -295,6 +295,12 @@ impl Filter {
|
||||
self.describe_in(Some(cat))
|
||||
}
|
||||
|
||||
/// Whether the rating rule narrows the view. Only "at least no stars" lets every photo through:
|
||||
/// "exactly" or "at most" no stars shows the unrated photos, as in Lightroom's filter bar (#3417).
|
||||
pub fn rating_filters(&self) -> bool {
|
||||
self.rating > 0 || self.rating_op != RatingOp::AtLeast
|
||||
}
|
||||
|
||||
/// The flags that `flag` and `flags` let through together (they AND), in the filter bar's
|
||||
/// order; `None` when neither is set, empty when they exclude each other. The chip and the
|
||||
/// filter bar's buttons show this, so they match what is filtered.
|
||||
@@ -308,7 +314,7 @@ impl Filter {
|
||||
|
||||
fn describe_in(&self, cat: Option<&crate::Catalog>) -> String {
|
||||
let mut v: Vec<String> = Vec::new();
|
||||
if self.rating > 0 {
|
||||
if self.rating_filters() {
|
||||
let op = match self.rating_op {
|
||||
RatingOp::AtLeast => "≥",
|
||||
RatingOp::Exactly => "=",
|
||||
@@ -437,7 +443,7 @@ impl Filter {
|
||||
}
|
||||
}
|
||||
}
|
||||
if self.rating > 0 {
|
||||
if self.rating_filters() {
|
||||
let ok = match self.rating_op {
|
||||
RatingOp::AtLeast => p.rating >= self.rating,
|
||||
RatingOp::Exactly => p.rating == self.rating,
|
||||
|
||||
@@ -39,9 +39,11 @@ fn commit_keywords(s: &mut Session, label: &str, op: lightcraft_catalog::Op, fol
|
||||
&& let Some(k) = f.keyword.clone()
|
||||
{
|
||||
f.keyword = follow(&k);
|
||||
// the keyword was deleted: if that emptied the filter, nothing is left to bring back. The rating
|
||||
// operator filters nothing without stars, so it alone does not count as something to bring back.
|
||||
gone_from_put_aside = f.keyword.is_none() && (Filter { rating_op: Default::default(), ..f.clone() }) == Filter::default();
|
||||
// the keyword was deleted: if that emptied the filter, nothing is left to bring back. "At least
|
||||
// no stars" filters nothing, so that operator alone does not count; "exactly" or "at most" no
|
||||
// stars shows the unrated photos (#3417), so it is still something to bring back.
|
||||
gone_from_put_aside =
|
||||
f.keyword.is_none() && !f.rating_filters() && (Filter { rating_op: Default::default(), ..f.clone() }) == Filter::default();
|
||||
}
|
||||
if gone_from_put_aside {
|
||||
s.shelved_filter = None;
|
||||
|
||||
@@ -58,20 +58,35 @@ pub(super) fn view_rules(s: &Session) -> lightcraft_catalog::Filter {
|
||||
};
|
||||
match smart {
|
||||
Some(base) => {
|
||||
// Exactly or at most zero selects only zero. Keep the album's saved rating
|
||||
// and represent an impossible intersection explicitly instead of widening the view.
|
||||
let no_match =
|
||||
s.filter.rating == 0 && s.filter.rating_filters() && base.rating > 0 && base.rating_op != lightcraft_catalog::RatingOp::AtMost;
|
||||
// overlay the fields the filter bar changed
|
||||
let cur = serde_json::to_value(&s.filter).unwrap_or_default();
|
||||
let def = serde_json::to_value(Filter::default()).unwrap_or_default();
|
||||
let mut patch = serde_json::Map::new();
|
||||
if let (Some(c), Some(d)) = (cur.as_object(), def.as_object()) {
|
||||
for (k, v) in c {
|
||||
if no_match && matches!(k.as_str(), "rating" | "ratingOp") {
|
||||
continue;
|
||||
}
|
||||
if d.get(k) != Some(v) {
|
||||
patch.insert(k.clone(), v.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
// the rating rule is its stars and operator together: "= no stars" (the unrated
|
||||
// photos) has the default stars, which alone would leave the album's own with "="
|
||||
if !no_match && s.filter.rating_filters() {
|
||||
patch.insert("rating".into(), cur["rating"].clone());
|
||||
patch.insert("ratingOp".into(), cur["ratingOp"].clone());
|
||||
}
|
||||
// the view as it is: a rule that no longer checks (its album was deleted) just matches
|
||||
// nothing there, and mustn't cost the filter bar's settings
|
||||
merge_filter(&base, &Value::Object(patch), "").unwrap_or(base)
|
||||
let mut saved = merge_filter(&base, &Value::Object(patch), "").unwrap_or(base);
|
||||
saved.only_none |= no_match;
|
||||
saved
|
||||
}
|
||||
None => {
|
||||
let mut f = s.source.to_filter(&s.filter, &s.catalog);
|
||||
|
||||
@@ -188,18 +188,37 @@ fn deleting_a_keyword_put_aside_keeps_the_rest_of_the_filter() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_rating_operator_without_stars_does_not_keep_an_emptied_filter_put_aside() {
|
||||
fn at_least_no_stars_does_not_keep_an_emptied_filter_put_aside() {
|
||||
let mut s = session_with_a_cat();
|
||||
// the filter bar's operator picker can be set with no stars chosen; it filters nothing
|
||||
s.execute("library.filter", &json!({"keyword": "cat", "ratingOp": "exactly"})).unwrap();
|
||||
// "at least no stars" lets every photo through: it filters nothing
|
||||
s.execute("library.filter", &json!({"keyword": "cat", "ratingOp": "atLeast"})).unwrap();
|
||||
s.execute("library.toggleFilters", &json!({})).unwrap();
|
||||
assert!(s.filters_off());
|
||||
s.execute("keyword.delete", &json!({"keyword": "cat"})).unwrap();
|
||||
assert!(!s.filters_off(), "only an operator with no stars is left: nothing to bring back");
|
||||
assert!(!s.filters_off(), "only an operator that filters nothing is left: nothing to bring back");
|
||||
let r = s.execute("library.toggleFilters", &json!({})).unwrap();
|
||||
assert_eq!(r["enabled"], json!(true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exactly_or_at_most_no_stars_put_aside_comes_back_when_the_keyword_goes() {
|
||||
for op in ["exactly", "atMost"] {
|
||||
let mut s = session_with_a_cat();
|
||||
// "= no stars" and "≤ no stars" show the unrated photos (#3417), so the rule is worth bringing back
|
||||
s.execute("library.filter", &json!({"keyword": "cat", "ratingOp": op})).unwrap();
|
||||
s.execute("library.toggleFilters", &json!({})).unwrap();
|
||||
assert!(s.filters_off());
|
||||
s.execute("keyword.delete", &json!({"keyword": "cat"})).unwrap();
|
||||
assert!(s.filters_off(), "{op} no stars is still put aside");
|
||||
let r = s.execute("library.toggleFilters", &json!({})).unwrap();
|
||||
assert_eq!(r["enabled"], json!(true), "{op}");
|
||||
assert_eq!(s.filter.keyword, None, "{op}");
|
||||
assert_eq!(s.filter.rating, 0, "{op}");
|
||||
assert_ne!(s.filter.rating_op, lightcraft_catalog::RatingOp::AtLeast, "{op}");
|
||||
assert_eq!(s.visible().len(), 1, "{op}: only the unrated photo shows");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_rating_operator_put_aside_survives_a_keyword_change_that_does_not_touch_it() {
|
||||
let mut s = session_with_a_cat();
|
||||
|
||||
@@ -1583,6 +1583,52 @@ fn find_similar_of_a_flat_photo_shows_an_empty_view_and_counts_zero() {
|
||||
assert_eq!(s.visible_cloned().len(), s.catalog.len());
|
||||
}
|
||||
|
||||
/// Issue #3417: "exactly" or "at most" no stars in the filter bar shows the unrated photos, as in
|
||||
/// Lightroom, instead of switching the rating rule off; "at least" no stars still shows all.
|
||||
#[test]
|
||||
fn rating_exactly_or_at_most_zero_shows_the_unrated_photos() {
|
||||
let mut s = demo();
|
||||
let ids: Vec<u64> = s.catalog.photos().map(|p| p.id.0).collect();
|
||||
assert!(ids.len() >= 3);
|
||||
s.execute("photo.rate", &json!({"rating": 0, "ids": ids})).unwrap();
|
||||
s.execute("photo.rate", &json!({"rating": 2, "ids": [ids[0]]})).unwrap();
|
||||
s.execute("photo.rate", &json!({"rating": 5, "ids": [ids[1]]})).unwrap();
|
||||
let unrated = ids.len() - 2;
|
||||
for op in ["exactly", "atMost"] {
|
||||
s.execute("library.filter", &json!({"rating": 0, "ratingOp": op})).unwrap();
|
||||
let shown = s.visible_cloned();
|
||||
assert_eq!(shown.len(), unrated, "{op} 0");
|
||||
assert!(shown.iter().all(|id| s.catalog.photo(*id).unwrap().rating == 0), "{op} 0 shows only unrated photos");
|
||||
assert_eq!(s.catalog.count(&s.filter), unrated);
|
||||
let chips = crate::filter_chips(&s.filter, &s.catalog);
|
||||
assert_eq!(chips.iter().map(|c| c.label.as_str()).collect::<Vec<_>>(), ["Unrated"], "{op}");
|
||||
s.execute("library.filter", &chips[0].clear).unwrap();
|
||||
assert_eq!(s.filter, Default::default(), "the chip clears the rule and its operator");
|
||||
assert_eq!(s.visible_cloned().len(), ids.len());
|
||||
}
|
||||
s.execute("library.filter", &json!({"rating": 0, "ratingOp": "atLeast"})).unwrap();
|
||||
assert_eq!(s.visible_cloned().len(), ids.len(), "at least no stars is every photo");
|
||||
assert!(crate::filter_chips(&s.filter, &s.catalog).is_empty());
|
||||
|
||||
// A saved zero-star view must not widen an album that already excludes unrated photos.
|
||||
for (name, rating, album_op, bar_op, expected) in [
|
||||
("Rated", 1, "atLeast", "exactly", 0),
|
||||
("Existing high scalar", 7, "exactly", "atMost", 0),
|
||||
("Includes unrated", 3, "atMost", "exactly", unrated),
|
||||
] {
|
||||
let r = s.execute("album.createSmart", &json!({"name": name, "rules": {"rating": rating, "ratingOp": album_op}})).unwrap();
|
||||
s.execute("library.source", &json!({"kind": "album", "id": r["id"]})).unwrap();
|
||||
s.execute("library.filter", &json!({"rating": 0, "ratingOp": bar_op})).unwrap();
|
||||
let expected_ids = s.visible_cloned();
|
||||
assert_eq!(expected_ids.len(), expected, "{name}: active view");
|
||||
let saved = s.execute("album.createSmart", &json!({"name": format!("Saved {name}")})).unwrap();
|
||||
assert_eq!(saved["count"], json!(expected), "{name}: save from filter");
|
||||
s.execute("library.clearFilter", &json!({})).unwrap();
|
||||
s.execute("library.source", &json!({"kind": "album", "id": saved["id"]})).unwrap();
|
||||
assert_eq!(s.visible_cloned(), expected_ids, "{name}: reopen saved view");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn find_similar_values_stay_within_zero_and_one() {
|
||||
let mut s = demo();
|
||||
|
||||
@@ -150,13 +150,15 @@ pub fn filter_chips(f: &Filter, cat: &Catalog) -> Vec<FilterChip> {
|
||||
if !f.text.trim().is_empty() {
|
||||
add(format!("Search: “{}”", f.text.trim()), json!({"text": ""}));
|
||||
}
|
||||
if f.rating > 0 {
|
||||
if f.rating_filters() {
|
||||
let op = match f.rating_op {
|
||||
RatingOp::AtLeast => "≥",
|
||||
RatingOp::Exactly => "=",
|
||||
RatingOp::AtMost => "≤",
|
||||
};
|
||||
add(format!("Rating {op} {}★", f.rating), json!({"rating": 0}));
|
||||
// "= 0" and "≤ 0" are the unrated photos; clearing the chip takes the operator back too
|
||||
let label = if f.rating == 0 { "Unrated".to_string() } else { format!("Rating {op} {}★", f.rating) };
|
||||
add(label, json!({"rating": 0, "ratingOp": "atLeast"}));
|
||||
}
|
||||
if let Some(shown) = f.flags_shown() {
|
||||
let name = |fl: &lightcraft_catalog::Flag| format!("{fl:?}").to_lowercase();
|
||||
|
||||
@@ -659,8 +659,8 @@ fn can_confirm(app: &LightcraftApp, dlg: &Dialog, informational: bool) -> bool {
|
||||
dlg,
|
||||
Dialog::DenoiseModel { accepted: false, .. } | Dialog::FaceModel { accepted: false, .. } | Dialog::SynchronizeFolder { counts: None, .. }
|
||||
);
|
||||
let bad_rules =
|
||||
matches!(dlg, Dialog::SmartRules { id, rules, .. } if !rules.check_for(&app.session.catalog, id.map(lightcraft_catalog::AlbumId)).is_empty());
|
||||
let bad_rules = matches!(dlg, Dialog::SmartRules { id, rules, .. }
|
||||
if no_match_album(app, *id).is_none() && !rules.check_for(&app.session.catalog, id.map(lightcraft_catalog::AlbumId)).is_empty());
|
||||
!rename_blocked && (informational || (!waiting && !bad_rules))
|
||||
}
|
||||
|
||||
@@ -1026,15 +1026,26 @@ fn all_metadata_body(ui: &mut egui::Ui, t: &Tokens, dlg: &mut Dialog) {
|
||||
});
|
||||
}
|
||||
|
||||
/// A saved view that matches nothing regardless of its stored criteria.
|
||||
fn no_match_album(app: &LightcraftApp, id: Option<u64>) -> Option<&lightcraft_catalog::Filter> {
|
||||
id.and_then(|id| app.session.catalog.album(lightcraft_catalog::AlbumId(id)))
|
||||
.and_then(|album| album.smart.as_deref())
|
||||
.filter(|filter| filter.only_none)
|
||||
}
|
||||
|
||||
/// The body of the SmartRules dialog.
|
||||
fn smart_rules_body(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, dlg: &mut Dialog) {
|
||||
let Dialog::SmartRules { id, name, rules, instance, .. } = dlg else { return };
|
||||
let Dialog::SmartRules { id, name, rules, instance, allow_matching, .. } = dlg else { return };
|
||||
let r = crate::widgets::named(
|
||||
ui.add(egui::TextEdit::singleline(name).hint_text(crate::i18n::tr("Name")).desired_width(f32::INFINITY)),
|
||||
crate::i18n::tr("Name"),
|
||||
);
|
||||
crate::widgets::register(ui, "field:smartName", r.rect);
|
||||
ui.add_space(6.0);
|
||||
if let Some(saved) = no_match_album(app, *id).cloned() {
|
||||
smart_rules_no_match_body(app, ui, allow_matching, saved);
|
||||
return;
|
||||
}
|
||||
// the folder an album made from a folder view carries is not in the editor, but it counts
|
||||
let folder = id
|
||||
.and_then(|id| app.session.catalog.album(lightcraft_catalog::AlbumId(id)))
|
||||
@@ -1048,22 +1059,46 @@ fn smart_rules_body(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, dlg:
|
||||
egui::ScrollArea::vertical().max_height(list_height(ui, 360.0)).auto_shrink([false, true]).show(ui, |ui| {
|
||||
crate::panels::rules_editor::edit(ui, rules, "rules", 0, &[], &env);
|
||||
});
|
||||
let n = view.count;
|
||||
ui.add_space(4.0);
|
||||
if view.problems.is_empty() {
|
||||
ui.label(
|
||||
egui::RichText::new(crate::i18n::tr_format!(
|
||||
"{n} photo{} match · updates automatically as photos change",
|
||||
if n == 1 { "" } else { "s" },
|
||||
n = n
|
||||
))
|
||||
.color(t.text_dim),
|
||||
);
|
||||
ui.label(egui::RichText::new(smart_rules_match_text(view.count)).color(t.text_dim));
|
||||
} else {
|
||||
ui.label(egui::RichText::new(crate::i18n::tr("Fix the marked rules to save this album.")).color(t.caution));
|
||||
}
|
||||
}
|
||||
|
||||
/// The existing rules are read-only while editing a no-match album's matching behavior.
|
||||
fn smart_rules_no_match_body(app: &mut LightcraftApp, ui: &mut egui::Ui, allow_matching: &mut bool, mut saved: lightcraft_catalog::Filter) {
|
||||
let allow = ui.checkbox(allow_matching, crate::i18n::tr("Allow saved rules to match photos"));
|
||||
crate::widgets::register(ui, "field:smartAllowMatching", allow.rect);
|
||||
let preview = if *allow_matching {
|
||||
saved.only_none = false;
|
||||
smart_rules_match_text(smart_filter_preview_count(app, &saved))
|
||||
} else {
|
||||
crate::i18n::tr("Only 0 photos").to_string()
|
||||
};
|
||||
// Keep one live node across both states: the screen reader gets changed text without moving focus.
|
||||
let status = ui.push_id("smartRulesMatchStatus", |ui| ui.label(preview)).inner;
|
||||
ui.ctx().accesskit_node_builder(status.id, |node| node.set_live(egui::accesskit::Live::Polite));
|
||||
}
|
||||
|
||||
fn smart_rules_match_text(n: usize) -> String {
|
||||
crate::i18n::tr_format!("{n} photo{} match · updates automatically as photos change", if n == 1 { "" } else { "s" }, n = n)
|
||||
}
|
||||
|
||||
fn smart_filter_preview_count(app: &mut LightcraftApp, rules: &lightcraft_catalog::Filter) -> usize {
|
||||
if rules.only_none {
|
||||
return 0;
|
||||
}
|
||||
// counted when the library or the rules change (or, for "in the last…" rules, the minute), not every frame
|
||||
let now = (app.session.clock)();
|
||||
let minute = if rules.depends_on_now() { now.get(..16).unwrap_or(&now) } else { "" };
|
||||
app.caches.dialog_count(&app.session.catalog, ("smartAlbum", format!("{rules:?}"), minute), || {
|
||||
lightcraft_catalog::rules::set_now(Some(now.clone()));
|
||||
app.session.catalog.query(rules, &Default::default()).len()
|
||||
})
|
||||
}
|
||||
|
||||
/// The body of the NewSmartAlbum dialog.
|
||||
fn new_smart_album_body(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, confirm: &mut bool, dlg: &mut Dialog) {
|
||||
let Dialog::NewSmartAlbum { name, .. } = dlg else { return };
|
||||
@@ -1071,13 +1106,7 @@ fn new_smart_album_body(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens,
|
||||
*confirm = true;
|
||||
}
|
||||
let rules = app.session.view_rules();
|
||||
// counted when the library or the rules change (or, for "in the last…" rules, the minute), not every frame
|
||||
let now = (app.session.clock)();
|
||||
let minute = if rules.depends_on_now() { now.get(..16).unwrap_or(&now) } else { "" };
|
||||
let n = app.caches.dialog_count(&app.session.catalog, ("smartAlbum", format!("{rules:?}"), minute), || {
|
||||
lightcraft_catalog::rules::set_now(Some(now.clone()));
|
||||
app.session.catalog.query(&rules, &Default::default()).len()
|
||||
});
|
||||
let n = smart_filter_preview_count(app, &rules);
|
||||
ui.label(
|
||||
egui::RichText::new(crate::i18n::tr_format!("Matches: {}", crate::i18n::filter_label(&rules, &app.session.catalog))).color(t.text_label),
|
||||
);
|
||||
|
||||
@@ -186,12 +186,24 @@ pub fn confirm_dialog(app: &mut LightcraftApp, dlg: &Dialog) -> Result<serde_jso
|
||||
p["resetBursts"] = json!(reset_bursts);
|
||||
app.run("photo.analyze", p)
|
||||
}
|
||||
Dialog::SmartRules { id, name, rules, parent, .. } => {
|
||||
Dialog::SmartRules { id, name, rules, parent, allow_matching, .. } => {
|
||||
let name = if name.trim().is_empty() { "Smart Album".to_string() } else { name.trim().to_string() };
|
||||
if let Some(id) = *id
|
||||
&& super::no_match_album(app, Some(id)).is_some()
|
||||
{
|
||||
if *allow_matching {
|
||||
// Patch the no-match flag without replacing the album's original filters.
|
||||
return app.run("album.setRules", json!({"id": id, "name": name, "rules": {"onlyNone": false}}));
|
||||
}
|
||||
if app.session.catalog.album(lightcraft_catalog::AlbumId(id)).is_some_and(|a| a.name != name) {
|
||||
app.run("album.rename", json!({"id": id, "name": name}))?;
|
||||
}
|
||||
return Ok(json!({"count": 0}));
|
||||
}
|
||||
// refused before anything changes (not even the name)
|
||||
if let Some(problem) = rules.check_for(&app.session.catalog, id.map(lightcraft_catalog::AlbumId)).first() {
|
||||
return Err(problem.to_string());
|
||||
}
|
||||
let name = if name.trim().is_empty() { "Smart Album".to_string() } else { name.trim().to_string() };
|
||||
match id {
|
||||
// the name and the rules together: one undo step, both or neither
|
||||
Some(id) => app.run("album.setRules", json!({"id": id, "name": name, "replace": true, "rules": {"ruleSet": rules}})),
|
||||
|
||||
@@ -474,6 +474,9 @@ pub fn color_label(catalog: &lightcraft_catalog::Catalog, label: lightcraft_cata
|
||||
|
||||
/// A legacy smart-album filter summary, using the same display labels as filter chips.
|
||||
pub fn filter_label(filter: &lightcraft_catalog::Filter, catalog: &lightcraft_catalog::Catalog) -> String {
|
||||
if filter.only_none {
|
||||
return tr("Only 0 photos").to_string();
|
||||
}
|
||||
if language() == Locale::En {
|
||||
filter.describe_with(catalog)
|
||||
} else {
|
||||
|
||||
@@ -20,7 +20,7 @@ impl Dialog {
|
||||
|
||||
/// A new smart album rules dialog: a fresh one, whatever rules it holds.
|
||||
pub fn smart_rules(id: Option<u64>, name: String, rules: lightcraft_catalog::RuleSet, parent: Option<u64>) -> Dialog {
|
||||
Dialog::SmartRules { id, name, rules, parent, instance: new_smart_rules_instance() }
|
||||
Dialog::SmartRules { id, name, rules, parent, allow_matching: false, instance: new_smart_rules_instance() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +222,9 @@ pub enum Dialog {
|
||||
id: Option<u64>,
|
||||
name: String,
|
||||
rules: lightcraft_catalog::RuleSet,
|
||||
/// For an explicit no-match album, allow its original saved criteria to match again.
|
||||
#[serde(skip)]
|
||||
allow_matching: bool,
|
||||
/// The folder a new smart album is created in (ignored when editing).
|
||||
#[serde(default)]
|
||||
parent: Option<u64>,
|
||||
|
||||
@@ -107,6 +107,57 @@ fn release(h: &mut Headless, at: Pos2) {
|
||||
h.settle(SETTLE);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_saved_no_match_smart_album_keeps_its_filters_until_explicitly_enabled() {
|
||||
use lightcraft_catalog::AlbumId;
|
||||
let app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() });
|
||||
let mut h = Headless::new(app, [1200.0, 1000.0], 1.0);
|
||||
let ids: Vec<u64> = h.app.session.catalog.photos().map(|photo| photo.id.0).collect();
|
||||
h.app.session.execute("photo.rate", &json!({"rating": 0, "ids": ids})).unwrap();
|
||||
h.app.session.execute("photo.rate", &json!({"rating": 1, "ids": [ids[0]]})).unwrap();
|
||||
let group_at_limit = group(vec![group(vec![group(vec![rule(1), rule(2)])])]);
|
||||
let id = h
|
||||
.app
|
||||
.session
|
||||
.execute(
|
||||
"album.createSmart",
|
||||
&json!({"name": "Empty view", "rules": {
|
||||
"rating": 1, "onlyNone": true, "ruleSet": {"match": "any", "rules": [group_at_limit]}
|
||||
}}),
|
||||
)
|
||||
.unwrap()["id"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
let source = |h: &Headless| h.app.session.catalog.album(AlbumId(id)).unwrap().smart.as_deref().unwrap().clone();
|
||||
let original = source(&h);
|
||||
let open = |h: &mut Headless| {
|
||||
let r = h.request("engine.execute", json!({"command": "dialog.smartAlbum", "params": {"id": id}}), T);
|
||||
assert_eq!(r["ok"], true, "{r}");
|
||||
h.settle(SETTLE);
|
||||
};
|
||||
open(&mut h);
|
||||
assert!(has(&h, "field:smartAllowMatching"));
|
||||
assert!(!has(&h, "ruleGrip:rules-0"), "do not edit the stored criteria while deciding whether to allow matches");
|
||||
let dlg = h.app.ui.dialog.take().unwrap();
|
||||
assert_eq!(crate::dialogs::confirm_dialog(&mut h.app, &dlg).unwrap()["count"], 0);
|
||||
assert_eq!(source(&h), original, "unchanged save");
|
||||
open(&mut h);
|
||||
let mut dlg = h.app.ui.dialog.take().unwrap();
|
||||
let crate::state::Dialog::SmartRules { name, .. } = &mut dlg else { panic!("no smart album editor") };
|
||||
*name = "Renamed empty view".into();
|
||||
assert_eq!(crate::dialogs::confirm_dialog(&mut h.app, &dlg).unwrap()["count"], 0);
|
||||
assert_eq!(source(&h), original, "rename must not replace any criteria");
|
||||
assert_eq!(h.app.session.catalog.album(AlbumId(id)).unwrap().name, "Renamed empty view");
|
||||
open(&mut h);
|
||||
let toggle = widget(&h, "field:smartAllowMatching").center();
|
||||
pointer(&mut h, toggle, Some(true));
|
||||
h.step();
|
||||
release(&mut h, toggle);
|
||||
let dlg = h.app.ui.dialog.take().unwrap();
|
||||
assert_eq!(crate::dialogs::confirm_dialog(&mut h.app, &dlg).unwrap()["count"], 1);
|
||||
assert_eq!(source(&h), lightcraft_catalog::Filter { only_none: false, ..original });
|
||||
}
|
||||
|
||||
/// A whole drag: press the grip of `from`, move to the lower (`after`) or upper half of the row
|
||||
/// of `to`, release.
|
||||
fn drag(h: &mut Headless, from: &str, to: &str, after: bool) {
|
||||
|
||||
@@ -159,6 +159,63 @@ fn every_interactive_node_has_a_name_in_every_view_and_tool() {
|
||||
assert!(problems.is_empty(), "{} accessibility problems:\n{}", problems.len(), problems.join("\n"));
|
||||
}
|
||||
|
||||
/// Toggling a saved no-match album by keyboard keeps focus on the checkbox and updates one live result node.
|
||||
#[test]
|
||||
fn smart_rules_match_preview_is_live_after_keyboard_toggle() {
|
||||
use egui::accesskit::Live;
|
||||
use serde_json::json;
|
||||
|
||||
const TOGGLE: &str = "Allow saved rules to match photos";
|
||||
const ZERO: &str = "Only 0 photos";
|
||||
const ONE: &str = "1 photo match · updates automatically as photos change";
|
||||
|
||||
let mut h = harness(ViewMode::PhotoGrid, RightPanel::None);
|
||||
let app = h.state_mut();
|
||||
let ids: Vec<u64> = app.session.catalog.photos().map(|photo| photo.id.0).collect();
|
||||
app.session.execute("photo.rate", &json!({"ids": ids, "rating": 0})).unwrap();
|
||||
app.session.execute("photo.rate", &json!({"ids": [ids[0]], "rating": 1})).unwrap();
|
||||
let album = app.session.execute("album.createSmart", &json!({"name": "Empty view", "rules": {"onlyNone": true, "rating": 1}})).unwrap();
|
||||
app.run("dialog.smartAlbum", json!({"id": album["id"]})).unwrap();
|
||||
h.run_steps(6);
|
||||
|
||||
let focused = |h: &Harness<'_, LightcraftApp>| {
|
||||
h.root()
|
||||
.children_recursive()
|
||||
.map(|n| n.accesskit_node())
|
||||
.any(|n| n.is_focused() && n.role() == Role::CheckBox && n.label().as_deref() == Some(TOGGLE))
|
||||
};
|
||||
let status_id = |h: &Harness<'_, LightcraftApp>, text: &str| {
|
||||
let nodes: Vec<_> = h
|
||||
.root()
|
||||
.children_recursive()
|
||||
.map(|n| n.accesskit_node())
|
||||
.filter(|n| n.live() == Live::Polite && (n.label().as_deref() == Some(text) || n.value().as_deref() == Some(text)))
|
||||
.map(|n| n.id())
|
||||
.collect();
|
||||
assert_eq!(nodes.len(), 1, "one live preview matching {text:?}");
|
||||
nodes[0]
|
||||
};
|
||||
let zero = status_id(&h, ZERO);
|
||||
for _ in 0..24 {
|
||||
if focused(&h) {
|
||||
break;
|
||||
}
|
||||
h.key_press(egui::Key::Tab);
|
||||
h.run_steps(1);
|
||||
}
|
||||
assert!(focused(&h), "Tab reaches the edit-album checkbox");
|
||||
h.key_press(egui::Key::Space);
|
||||
h.run_steps(3);
|
||||
assert!(focused(&h), "updating the count does not steal focus");
|
||||
assert_eq!(status_id(&h, ONE), zero, "the live node's text changes without replacing the node");
|
||||
h.run_steps(3);
|
||||
assert_eq!(status_id(&h, ONE), zero, "idle redraws keep the same live node and text");
|
||||
h.key_press(egui::Key::Space);
|
||||
h.run_steps(3);
|
||||
assert!(focused(&h));
|
||||
assert_eq!(status_id(&h, ZERO), zero, "toggling off announces the zero result on the same node");
|
||||
}
|
||||
|
||||
fn slider_value(h: &Harness<'_, LightcraftApp>, name: &str) -> Option<f64> {
|
||||
h.root()
|
||||
.children_recursive()
|
||||
|
||||
@@ -154,7 +154,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts).
|
||||
|---|---|---|---|---|---|
|
||||
| LR-FILT-SEARCH-META | Text search | P0 | ✅ | `cmd:library.filter` (`text`), `crates/ui-egui/src/panels/topbar.rs`, `crates/catalog/src/query.rs` | fielded tokens (`rating:3`, `iso:>800`, `rating:>=3` / `iso:<=400`, `camera:…`); plain words also match the people named on faces; double quotes keep several words in one token (`person:"Jane Doe"`, `"jane doe"`, issue #1449); no suggestions dropdown |
|
||||
| LR-FILT-SEARCH-AI | Natural-language search | P2 | ⬜ | | |
|
||||
| LR-FILT-RATING | Rating filter | P0 | ✅ | `cmd:library.filter` (`rating`, `ratingOp`), `crates/ui-egui/src/panels/filterbar.rs` | ≥ / = / ≤ stars in the filter bar (`cmd:view.filterBar`) |
|
||||
| LR-FILT-RATING | Rating filter | P0 | ✅ | `cmd:library.filter` (`rating`, `ratingOp`), `crates/ui-egui/src/panels/filterbar.rs` | ≥ / = / ≤ stars in the filter bar (`cmd:view.filterBar`); = or ≤ no stars shows the unrated photos, as in Lightroom (issue #3417, `rating_exactly_or_at_most_zero_shows_the_unrated_photos`) |
|
||||
| LR-FILT-FLAG | Flag filter | P0 | ✅ | `cmd:library.filter` (`flag`, `flags`), `crates/ui-egui/src/panels/filterbar.rs` | picked / rejected / unflagged, toggled on and off like Classic's Attribute flag buttons: several at once show any of them (Picked + Unflagged hides only the rejects, issue #2588; `flags`, one chip); the single `flag` of saved filters, smart albums and agents still filters |
|
||||
| LR-FILT-LABEL | Colour-label filter | P1 | ✅ | `cmd:library.filter` (`label`), `crates/ui-egui/src/panels/filterbar.rs` | one label at a time; no “no label” choice |
|
||||
| LR-FILT-TYPE | Type / edited filter | P1 | ✅ | `cmd:library.filter` (`kind`, `merged`, `edited`), `crates/ui-egui/src/panels/filterbar.rs`, `crates/catalog/src/query.rs` (`merged_kind`) | photos / raw / videos / HDR / panoramas / HDR panoramas (merge results by name), edited / unedited; no depth kind |
|
||||
@@ -809,6 +809,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-19 | minor | LR-EDIT-OPTICS-DEFRINGE: AI Defringe (beyond Lightroom), a user-installed defringe network with a cached per-photo correction; no model ships; status unchanged |
|
||||
| 2026-10-31 | patch | LR-FILT-RATING: = or ≤ no stars in the filter bar shows the unrated photos instead of every photo (#3417); status unchanged |
|
||||
| 2026-10-29 | minor | MENU-EDIT-SELECTBY: Edit → Select by lists each rating on its own (★ only … ★★★★★ only, `library.selectBy` with `ratingOp: eq`) after the "and higher" rows, beside Unrated (#3311); status unchanged (✅) |
|
||||
| 2026-11-15 | patch | LR-PRE-AMOUNT: Amount blends tone curves, fades in the strength of a profile/LUT or switched-on group a preset changes, and takes white balance on another scale whole (#2669); the step at half amount for switches and choices stays (#2207); status unchanged (✅) |
|
||||
| 2026-11-09 | minor | LR-PREF-LOCALSTORAGE: the low-disk notice warns under 20 GB free, no longer under 10 % of the drive (76 GB free of a 926 GB drive warned, #4013); status unchanged |
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# What's new in LightCraft
|
||||
|
||||
## 2026-10-31
|
||||
|
||||
### Filter for unrated photos
|
||||
- In the filter bar, Rating "= exactly" or "≤ at most" with no stars now shows the photos without a rating, as in
|
||||
Lightroom. Before, it switched the rating rule off and showed every photo. "≥ at least" with no stars still shows
|
||||
everything, and the chip above the grid reads "Unrated" (issue #3417).
|
||||
|
||||
## 2026-10-29
|
||||
|
||||
### Select by a single star rating
|
||||
|
||||
Reference in new issue
Block a user