Satisfy rustfmt and clippy on the album and folder picker changes

rustfmt over the files the albums work touched, and the album merge's
incoming row as a named struct rather than an eight-field tuple, which
clippy's type_complexity refused.
This commit is contained in:
2026-09-26 14:13:54 -04:00
parent 1abb18d972
commit 9b580c3720
18 changed files with 487 additions and 303 deletions
+24 -7
View File
@@ -128,7 +128,12 @@ pub fn create(conn: &Connection, name: &str, place: &Place) -> Result<AlbumId, C
tx.execute( tx.execute(
"INSERT INTO albums(uuid, name, server_path, created, revision, modified) "INSERT INTO albums(uuid, name, server_path, created, revision, modified)
VALUES (?1, ?2, ?3, ?4, 1, ?4)", VALUES (?1, ?2, ?3, ?4, 1, ?4)",
rusqlite::params![crate::collections::new_uuid(), name, server_path(place), now], rusqlite::params![
crate::collections::new_uuid(),
name,
server_path(place),
now
],
)?; )?;
let id = AlbumId(tx.last_insert_rowid() as u64); let id = AlbumId(tx.last_insert_rowid() as u64);
if let Place::Local(folder) = place { if let Place::Local(folder) = place {
@@ -206,8 +211,14 @@ pub fn delete(conn: &Connection, id: AlbumId) -> Result<(), CatalogError> {
if n == 0 { if n == 0 {
return Err(CatalogError::NoSuchAlbum(id.0)); return Err(CatalogError::NoSuchAlbum(id.0));
} }
tx.execute("DELETE FROM album_exports WHERE album_id = ?1", [id.0 as i64])?; tx.execute(
tx.execute("DELETE FROM album_folders WHERE album_id = ?1", [id.0 as i64])?; "DELETE FROM album_exports WHERE album_id = ?1",
[id.0 as i64],
)?;
tx.execute(
"DELETE FROM album_folders WHERE album_id = ?1",
[id.0 as i64],
)?;
tx.commit()?; tx.commit()?;
Ok(()) Ok(())
} }
@@ -424,7 +435,11 @@ mod tests {
record_exports( record_exports(
conn, conn,
album, album,
&[(a, "a.jpg".into()), (a, "a (1).jpg".into()), (b, "b.jpg".into())], &[
(a, "a.jpg".into()),
(a, "a (1).jpg".into()),
(b, "b.jpg".into()),
],
) )
.unwrap(); .unwrap();
@@ -490,9 +505,11 @@ mod tests {
let album = create(conn, "Web", &Place::Local("/out".into())).unwrap(); let album = create(conn, "Web", &Place::Local("/out".into())).unwrap();
rename(conn, album, "Website").unwrap(); rename(conn, album, "Website").unwrap();
let rev: i64 = conn let rev: i64 = conn
.query_row("SELECT revision FROM albums WHERE id = ?1", [album.0 as i64], |r| { .query_row(
r.get(0) "SELECT revision FROM albums WHERE id = ?1",
}) [album.0 as i64],
|r| r.get(0),
)
.unwrap(); .unwrap();
assert_eq!(rev, 2); assert_eq!(rev, 2);
} }
+36 -18
View File
@@ -239,7 +239,19 @@ fn merge_albums_within(tx: &Connection, report: &mut MergeReport) -> Result<(),
} }
crate::albums::ensure_tables(tx)?; crate::albums::ensure_tables(tx)?;
let rows: Vec<(String, String, Option<String>, i64, i64, i64, bool, MergeVerdict)> = { /// One album as the remote has it, and what the verdict made of it.
struct IncomingAlbum {
uuid: String,
name: String,
server_path: Option<String>,
created: i64,
revision: i64,
modified: i64,
deleted: bool,
verdict: MergeVerdict,
}
let rows: Vec<IncomingAlbum> = {
let mut stmt = tx.prepare( let mut stmt = tx.prepare(
"SELECT r.uuid, r.name, r.server_path, r.created, r.revision, r.modified, "SELECT r.uuid, r.name, r.server_path, r.created, r.revision, r.modified,
r.deleted, l.revision, l.modified r.deleted, l.revision, l.modified
@@ -253,16 +265,16 @@ fn merge_albums_within(tx: &Connection, report: &mut MergeReport) -> Result<(),
let deleted: bool = r.get::<_, i64>(6)? != 0; let deleted: bool = r.get::<_, i64>(6)? != 0;
let local_rev: Option<i64> = r.get(7)?; let local_rev: Option<i64> = r.get(7)?;
let local_mod: Option<i64> = r.get(8)?; let local_mod: Option<i64> = r.get(8)?;
Ok(( Ok(IncomingAlbum {
r.get(0)?, uuid: r.get(0)?,
r.get(1)?, name: r.get(1)?,
r.get(2)?, server_path: r.get(2)?,
r.get(3)?, created: r.get(3)?,
revision, revision,
modified, modified,
deleted, deleted,
verdict(local_rev.zip(local_mod), (revision, modified), deleted), verdict: verdict(local_rev.zip(local_mod), (revision, modified), deleted),
)) })
})? })?
.collect::<Result<Vec<_>, _>>()?; .collect::<Result<Vec<_>, _>>()?;
rows rows
@@ -289,29 +301,35 @@ fn merge_albums_within(tx: &Connection, report: &mut MergeReport) -> Result<(),
"DELETE FROM main.album_folders "DELETE FROM main.album_folders
WHERE album_id = (SELECT id FROM main.albums WHERE uuid = ?1)", WHERE album_id = (SELECT id FROM main.albums WHERE uuid = ?1)",
)?; )?;
for (uuid, name, server_path, created, revision, modified, deleted, v) in rows { for row in rows {
if v == MergeVerdict::KeptLocal { if row.verdict == MergeVerdict::KeptLocal {
report.albums_kept_local += 1; report.albums_kept_local += 1;
continue; continue;
} }
take.execute(rusqlite::params![ take.execute(rusqlite::params![
uuid, name, server_path, created, revision, modified, deleted as i64 row.uuid,
row.name,
row.server_path,
row.created,
row.revision,
row.modified,
row.deleted as i64
])?; ])?;
if deleted { if row.deleted {
forget.execute([&uuid])?; forget.execute([&row.uuid])?;
unfold.execute([&uuid])?; unfold.execute([&row.uuid])?;
} else if server_path.is_some() { } else if row.server_path.is_some() {
// Another device moved the album to the server with the newer // Another device moved the album to the server with the newer
// revision; a local folder chosen here is no longer where it // revision; a local folder chosen here is no longer where it
// goes. // goes.
unfold.execute([&uuid])?; unfold.execute([&row.uuid])?;
} }
report.albums_taken += 1; report.albums_taken += 1;
} }
} }
report.album_exports_added = report.album_exports_added = tx.execute(ALBUM_EXPORTS_BY_FILE_ID, [])?
tx.execute(ALBUM_EXPORTS_BY_FILE_ID, [])? + tx.execute(ALBUM_EXPORTS_BY_CONTENT_HASH, [])?; + tx.execute(ALBUM_EXPORTS_BY_CONTENT_HASH, [])?;
Ok(()) Ok(())
} }
File diff suppressed because one or more lines are too long
+50 -50
View File
@@ -39,7 +39,7 @@ The list is longer than it is tall, so a way to walk it that cannot be lost to t
Anchored on the fingers' midpoint, and on the pointer, so the gesture reads as magnifying the picture rather than sliding it about. Double-tap is the way to an exact 1:1; this is the way to everything in between. Past 1:1 the pixels are shown as they are, square and unsmoothed; below it, filtered. Anchored on the fingers' midpoint, and on the pointer, so the gesture reads as magnifying the picture rather than sliding it about. Double-tap is the way to an exact 1:1; this is the way to everything in between. Past 1:1 the pixels are shown as they are, square and unsmoothed; below it, filtered.
<sub>`ui/dr-ui/ui/app.slint:1949`</sub> <sub>`ui/dr-ui/ui/app.slint:1961`</sub>
### Move a magnified photograph about ### Move a magnified photograph about
@@ -50,7 +50,7 @@ Anchored on the fingers' midpoint, and on the pointer, so the gesture reads as m
Only once there is something outside the viewport to reach, which is why the cursor becomes a hand exactly then. The view is clamped to the frame: panning past the edge would show undefined area beside the photograph, and that reads as a rendering fault rather than as the end of the picture. Only once there is something outside the viewport to reach, which is why the cursor becomes a hand exactly then. The view is clamped to the frame: panning past the edge would show undefined area beside the photograph, and that reads as a rendering fault rather than as the end of the picture.
<sub>`ui/dr-ui/ui/app.slint:2045`</sub> <sub>`ui/dr-ui/ui/app.slint:2057`</sub>
### Paint a mask by hand ### Paint a mask by hand
@@ -60,7 +60,7 @@ Only once there is something outside the viewport to reach, which is why the cur
A model's mask stops inside a shoulder and leaks into the hair, and no single edge control fixes two errors that go opposite ways. The whole stroke is one step in the history, so taking a mark back costs one press however long it took to make. A model's mask stops inside a shoulder and leaks into the hair, and no single edge control fixes two errors that go opposite ways. The whole stroke is one step in the history, so taking a mark back costs one press however long it took to make.
<sub>`ui/dr-ui/ui/app.slint:2136`</sub> <sub>`ui/dr-ui/ui/app.slint:2148`</sub>
### Open this list ### Open this list
@@ -70,7 +70,7 @@ A model's mask stops inside a shoulder and leaks into the hair, and no single ed
Most of the keys are develop's, and a reference that could only be opened from the grid had to be looked up before opening the photograph they were wanted for. Most of the keys are develop's, and a reference that could only be opened from the grid had to be looked up before opening the photograph they were wanted for.
<sub>`ui/dr-ui/ui/app.slint:2362`</sub> <sub>`ui/dr-ui/ui/app.slint:2374`</sub>
### Take back the last change ### Take back the last change
@@ -81,7 +81,7 @@ Most of the keys are develop's, and a reference that could only be opened from t
A whole drag is one step, so undo takes back a decision rather than a frame of a gesture. The list is there because arriving six steps back costs what arriving from one does. A whole drag is one step, so undo takes back a decision rather than a frame of a gesture. The list is there because arriving six steps back costs what arriving from one does.
<sub>`ui/dr-ui/ui/app.slint:2392`</sub> <sub>`ui/dr-ui/ui/app.slint:2404`</sub>
### Do it again after taking it back ### Do it again after taking it back
@@ -90,7 +90,7 @@ A whole drag is one step, so undo takes back a decision rather than a frame of a
- **Keyboard** — `Ctrl+Shift+Z`, or `Ctrl+Y` - **Keyboard** — `Ctrl+Shift+Z`, or `Ctrl+Y`
- **See it** — [in the manual](manual/README.md#history-snapshots-presets) - **See it** — [in the manual](manual/README.md#history-snapshots-presets)
<sub>`ui/dr-ui/ui/app.slint:2406`</sub> <sub>`ui/dr-ui/ui/app.slint:2418`</sub>
### Remove a repair ### Remove a repair
@@ -98,7 +98,7 @@ A whole drag is one step, so undo takes back a decision rather than a frame of a
- **Pointer** — Click it, then Delete Repair - **Pointer** — Click it, then Delete Repair
- **Keyboard** — `Delete` or `Backspace`, while repairing - **Keyboard** — `Delete` or `Backspace`, while repairing
<sub>`ui/dr-ui/ui/app.slint:2426`</sub> <sub>`ui/dr-ui/ui/app.slint:2438`</sub>
### Copy the settings from this photograph ### Copy the settings from this photograph
@@ -109,7 +109,7 @@ A whole drag is one step, so undo takes back a decision rather than a frame of a
The button is the copy that has to work: a tablet has no modifier key to hold and no menu bar to hang the action from. The shortcut is an accelerator for a control that is on screen either way. The button is the copy that has to work: a tablet has no modifier key to hold and no menu bar to hang the action from. The shortcut is an accelerator for a control that is on screen either way.
<sub>`ui/dr-ui/ui/app.slint:2445`</sub> <sub>`ui/dr-ui/ui/app.slint:2457`</sub>
### Paste the settings onto this photograph ### Paste the settings onto this photograph
@@ -120,7 +120,7 @@ The button is the copy that has to work: a tablet has no modifier key to hold an
The button names what would be pasted — "3 adjustments", and whether the crop is coming with it — which the shortcut cannot say. Both paste the same scope. The button names what would be pasted — "3 adjustments", and whether the crop is coming with it — which the shortcut cannot say. Both paste the same scope.
<sub>`ui/dr-ui/ui/app.slint:2458`</sub> <sub>`ui/dr-ui/ui/app.slint:2470`</sub>
### Choose which kinds of edit a copy carries ### Choose which kinds of edit a copy carries
@@ -131,7 +131,7 @@ The button names what would be pasted — "3 adjustments", and whether the crop
Lightroom's Copy Settings. Pasting a look across a shoot usually means leaving each frame's crop and rotation alone, and that is a choice to make at the moment of copying. Lightroom's Copy Settings. Pasting a look across a shoot usually means leaving each frame's crop and rotation alone, and that is a choice to make at the moment of copying.
<sub>`ui/dr-ui/ui/app.slint:2476`</sub> <sub>`ui/dr-ui/ui/app.slint:2488`</sub>
### Export this photograph as the last one was ### Export this photograph as the last one was
@@ -142,7 +142,7 @@ Lightroom's Copy Settings. Pasting a look across a shoot usually means leaving e
Every export runs on the defaults in Settings, so "as the last one was" is what the button already does. The chord is Lightroom's and darktable's, kept so hands that learned it there need not learn it again. Every export runs on the defaults in Settings, so "as the last one was" is what the button already does. The chord is Lightroom's and darktable's, kept so hands that learned it there need not learn it again.
<sub>`ui/dr-ui/ui/app.slint:2501`</sub> <sub>`ui/dr-ui/ui/app.slint:2513`</sub>
### Choose how to export, then export ### Choose how to export, then export
@@ -153,7 +153,7 @@ Every export runs on the defaults in Settings, so "as the last one was" is what
The export sheet is the export defaults alone with an Export button. What is chosen there is kept, so it is also what the next Ctrl+Shift+E uses. The export sheet is the export defaults alone with an Export button. What is chosen there is kept, so it is also what the next Ctrl+Shift+E uses.
<sub>`ui/dr-ui/ui/app.slint:2514`</sub> <sub>`ui/dr-ui/ui/app.slint:2526`</sub>
### Keep a crop that leaves a mask outside ### Keep a crop that leaves a mask outside
@@ -161,7 +161,7 @@ The export sheet is the export defaults alone with an Export button. What is cho
- **Pointer** — Press "Keep crop" on the notice, or "Undo crop" to take it back - **Pointer** — Press "Keep crop" on the notice, or "Undo crop" to take it back
- **Keyboard** — `Enter` keeps it; `Ctrl+Z` takes the crop back, like any other step - **Keyboard** — `Enter` keeps it; `Ctrl+Z` takes the crop back, like any other step
<sub>`ui/dr-ui/ui/app.slint:2579`</sub> <sub>`ui/dr-ui/ui/app.slint:2591`</sub>
### Go back to the grid ### Go back to the grid
@@ -171,7 +171,7 @@ The export sheet is the export defaults alone with an Export button. What is cho
Lightroom's key for the grid. Escape gets there too, but a step at a time — out of a mode, then out of a zoom — where this goes straight back. Lightroom's key for the grid. Escape gets there too, but a step at a time — out of a mode, then out of a zoom — where this goes straight back.
<sub>`ui/dr-ui/ui/app.slint:2596`</sub> <sub>`ui/dr-ui/ui/app.slint:2608`</sub>
### Nudge the control last moved ### Nudge the control last moved
@@ -181,7 +181,7 @@ Lightroom's key for the grid. Escape gets there too, but a step at a time — ou
Lightroom's keys for the selected slider. There is no focus ring on a slider here, so "selected" is the last one moved — the same control `R` puts back — which covers the framing sliders, perspective included, as well as the adjustments. Lightroom's keys for the selected slider. There is no focus ring on a slider here, so "selected" is the last one moved — the same control `R` puts back — which covers the framing sliders, perspective included, as well as the adjustments.
<sub>`ui/dr-ui/ui/app.slint:2625`</sub> <sub>`ui/dr-ui/ui/app.slint:2637`</sub>
### Change which group of adjustments is on screen ### Change which group of adjustments is on screen
@@ -192,7 +192,7 @@ Lightroom's keys for the selected slider. There is no focus ring on a slider her
The groups are whatever the operation set declares itself to be about, so there are as many as the pipeline has and no key can be assigned to one of them by name. Stepping is the binding that survives a node being added. The groups are whatever the operation set declares itself to be about, so there are as many as the pipeline has and no key can be assigned to one of them by name. Stepping is the binding that survives a node being added.
<sub>`ui/dr-ui/ui/app.slint:2653`</sub> <sub>`ui/dr-ui/ui/app.slint:2665`</sub>
### Look at the photograph at 1:1 ### Look at the photograph at 1:1
@@ -203,7 +203,7 @@ The groups are whatever the operation set declares itself to be about, so there
Noise reduction and capture sharpening are judgements about single pixels, and a fitted view averages several of the file's into each one on screen — so the frame looks softer than it is and the correction goes too far. The point and the magnification survive opening the next photograph, which is what makes checking the same eye across forty portraits forty keystrokes rather than forty pans. From 1:1 on the photograph is drawn as its own pixels, each a hard-edged square, rather than smoothed into a blur. Noise reduction and capture sharpening are judgements about single pixels, and a fitted view averages several of the file's into each one on screen — so the frame looks softer than it is and the correction goes too far. The point and the magnification survive opening the next photograph, which is what makes checking the same eye across forty portraits forty keystrokes rather than forty pans. From 1:1 on the photograph is drawn as its own pixels, each a hard-edged square, rather than smoothed into a blur.
<sub>`ui/dr-ui/ui/app.slint:2689`</sub> <sub>`ui/dr-ui/ui/app.slint:2701`</sub>
### Rate this photograph ### Rate this photograph
@@ -211,7 +211,7 @@ Noise reduction and capture sharpening are judgements about single pixels, and a
- **Pointer** — Click a star in the top bar - **Pointer** — Click a star in the top bar
- **Keyboard** — `0`–`5` - **Keyboard** — `0`–`5`
<sub>`ui/dr-ui/ui/app.slint:2746`</sub> <sub>`ui/dr-ui/ui/app.slint:2758`</sub>
### Pick or reject this photograph ### Pick or reject this photograph
@@ -221,7 +221,7 @@ Noise reduction and capture sharpening are judgements about single pixels, and a
The grid's keys, on the photograph that is open (FR-UI-5, 2026-09-19). Judging here does not move on to the next frame: that belongs to culling, and in develop the photograph in front of you is the one being worked on. The grid's keys, on the photograph that is open (FR-UI-5, 2026-09-19). Judging here does not move on to the next frame: that belongs to culling, and in develop the photograph in front of you is the one being worked on.
<sub>`ui/dr-ui/ui/app.slint:2752`</sub> <sub>`ui/dr-ui/ui/app.slint:2764`</sub>
### Give this photograph a colour label ### Give this photograph a colour label
@@ -232,7 +232,7 @@ The grid's keys, on the photograph that is open (FR-UI-5, 2026-09-19). Judging h
The grid's keys, on the photograph that is open, so labelling while stepping through a folder is one hand's work. The bar names the label in words beside its mark. The grid's keys, on the photograph that is open, so labelling while stepping through a folder is one hand's work. The bar names the label in words beside its mark.
<sub>`ui/dr-ui/ui/app.slint:2782`</sub> <sub>`ui/dr-ui/ui/app.slint:2794`</sub>
### Move to the next or previous photograph ### Move to the next or previous photograph
@@ -243,7 +243,7 @@ The grid's keys, on the photograph that is open, so labelling while stepping thr
The edit on screen is saved on the way out, so stepping through a folder is as much a departure as going back to the grid and loses nothing. A and D as well as the arrows, so the left hand steps along the roll while the right stays on the mouse. The edit on screen is saved on the way out, so stepping through a folder is as much a departure as going back to the grid and loses nothing. A and D as well as the arrows, so the left hand steps along the roll while the right stays on the mouse.
<sub>`ui/dr-ui/ui/app.slint:2807`</sub> <sub>`ui/dr-ui/ui/app.slint:2819`</sub>
### See the photograph before you edited it ### See the photograph before you edited it
@@ -254,7 +254,7 @@ The edit on screen is saved on the way out, so stepping through a folder is as m
Held rather than toggled, and no split screen: a split halves the working image on the tablet the column was sized for, and the comparison photographers describe making is a flick back and forth. It takes no history step, so checking whether a frame is overcooked costs nothing to undo afterwards. Held rather than toggled, and no split screen: a split halves the working image on the tablet the column was sized for, and the comparison photographers describe making is a flick back and forth. It takes no history step, so checking whether a frame is overcooked costs nothing to undo afterwards.
<sub>`ui/dr-ui/ui/app.slint:2937`</sub> <sub>`ui/dr-ui/ui/app.slint:2949`</sub>
### Put one control back to its default ### Put one control back to its default
@@ -338,7 +338,7 @@ The question a correction raises is whether it did what it was for — whether t
One key for "up one", innermost first: a question before the sheet under it, a sheet before the view, a view before the library. Nothing is left behind a dialogue that the key walked straight past. One key for "up one", innermost first: a question before the sheet under it, a sheet before the view, a view before the library. Nothing is left behind a dialogue that the key walked straight past.
<sub>`ui/dr-ui/ui/app.slint:1013`</sub> <sub>`ui/dr-ui/ui/app.slint:1021`</sub>
### Do what a sheet offers ### Do what a sheet offers
@@ -346,7 +346,7 @@ One key for "up one", innermost first: a question before the sheet under it, a s
- **Pointer** — Press its button — Export, or Copy - **Pointer** — Press its button — Export, or Copy
- **Keyboard** — `Enter`, on the export and copy sheets - **Keyboard** — `Enter`, on the export and copy sheets
<sub>`ui/dr-ui/ui/app.slint:1023`</sub> <sub>`ui/dr-ui/ui/app.slint:1031`</sub>
### Scroll by the scrollbar ### Scroll by the scrollbar
@@ -366,7 +366,7 @@ A list cut off at its edge looks, to a mouse, like a list that ends there — th
The tree is inside a Flickable, which claims any drag beginning inside it — so with a finger a drag on a row is a scroll until something says otherwise. The hold is that something, and it is what every mobile list already uses to pick a row up. The row lifts the moment it fires, so the gesture says it has been understood before anything moves. The tree is inside a Flickable, which claims any drag beginning inside it — so with a finger a drag on a row is a scroll until something says otherwise. The hold is that something, and it is what every mobile list already uses to pick a row up. The row lifts the moment it fires, so the gesture says it has been understood before anything moves.
<sub>`ui/dr-ui/ui/collections.slint:352`</sub> <sub>`ui/dr-ui/ui/collections.slint:353`</sub>
### Act on a collection — rename, nest, un-nest, delete ### Act on a collection — rename, nest, un-nest, delete
@@ -376,7 +376,7 @@ The tree is inside a Flickable, which claims any drag beginning inside it — so
The hold arms a drag and opens this menu, and which one you get is decided by whether you moved — the same fork the grid uses. One menu for everything done to a row, because there is one hold per row: while the hold opened the offline question by itself, nothing else the tree can do had a touch route. The hold arms a drag and opens this menu, and which one you get is decided by whether you moved — the same fork the grid uses. One menu for everything done to a row, because there is one hold per row: while the hold opened the offline question by itself, nothing else the tree can do had a touch route.
<sub>`ui/dr-ui/ui/collections.slint:364`</sub> <sub>`ui/dr-ui/ui/collections.slint:365`</sub>
### Take a collection back out of the one it is nested in ### Take a collection back out of the one it is nested in
@@ -386,7 +386,7 @@ The hold arms a drag and opens this menu, and which one you get is decided by wh
Nesting is a drag of one row onto another, and its inverse had no gesture at all: "All photographs" refused every drop, which is right for a photograph — it is already in the library — and wrong for a collection, which has a top level to be returned to. Without it a collection dragged into another was in there permanently. Nesting is a drag of one row onto another, and its inverse had no gesture at all: "All photographs" refused every drop, which is right for a photograph — it is already in the library — and wrong for a collection, which has a top level to be returned to. Without it a collection dragged into another was in there permanently.
<sub>`ui/dr-ui/ui/collections.slint:375`</sub> <sub>`ui/dr-ui/ui/collections.slint:376`</sub>
### Rename a collection ### Rename a collection
@@ -397,7 +397,7 @@ Nesting is a drag of one row onto another, and its inverse had no gesture at all
Double-click is what a file manager and a Lightroom panel use for the same thing, so it needs no discovering — but nothing on screen says so, which is what the menu item is for. Double-click is what a file manager and a Lightroom panel use for the same thing, so it needs no discovering — but nothing on screen says so, which is what the menu item is for.
<sub>`ui/dr-ui/ui/collections.slint:389`</sub> <sub>`ui/dr-ui/ui/collections.slint:390`</sub>
### Review duplicate originals ### Review duplicate originals
@@ -407,7 +407,7 @@ Double-click is what a file manager and a Lightroom panel use for the same thing
Under the trash because the trash is where the spare copies go, and only while the catalog holds any: a row that is always there and usually empty is noise. Under the trash because the trash is where the spare copies go, and only while the catalog holds any: a row that is always there and usually empty is noise.
<sub>`ui/dr-ui/ui/collections.slint:884`</sub> <sub>`ui/dr-ui/ui/collections.slint:898`</sub>
## Duplicate originals ## Duplicate originals
@@ -571,7 +571,7 @@ This replaced a double tap, which had no visible state and could take forty phot
Face indexing reads each face's eyes. The chip drops frames where the chosen people are caught blinking, and leaves sunglasses and eyes it could not read alone. Face indexing reads each face's eyes. The chip drops frames where the chosen people are caught blinking, and leaves sunglasses and eyes it could not read alone.
<sub>`ui/dr-ui/ui/library.slint:2534`</sub> <sub>`ui/dr-ui/ui/library.slint:2535`</sub>
### Find photographs with two people in them ### Find photographs with two people in them
@@ -581,7 +581,7 @@ Face indexing reads each face's eyes. The chip drops frames where the chosen peo
"Any of them" is a union and "all of them" is an intersection. The tray is where both terms and the choice between them live, because a filter belongs on the filter bar. "Any of them" is a union and "all of them" is an intersection. The tray is where both terms and the choice between them live, because a filter belongs on the filter bar.
<sub>`ui/dr-ui/ui/library.slint:2564`</sub> <sub>`ui/dr-ui/ui/library.slint:2565`</sub>
### Show only photographs with one colour label ### Show only photographs with one colour label
@@ -591,7 +591,7 @@ Face indexing reads each face's eyes. The chip drops frames where the chosen peo
Each chip is the label's mark and its name, so the one you want is found by reading it; tap the lit chip again to show every label. Each chip is the label's mark and its name, so the one you want is found by reading it; tap the lit chip again to show every label.
<sub>`ui/dr-ui/ui/library.slint:2688`</sub> <sub>`ui/dr-ui/ui/library.slint:2689`</sub>
### Export the selection as the last export was ### Export the selection as the last export was
@@ -602,7 +602,7 @@ Each chip is the label's mark and its name, so the one you want is found by read
Lightroom's and darktable's chords. Every export runs on the saved defaults, so the plain chord opens them beside an Export button and the shifted one skips straight to exporting. Lightroom's and darktable's chords. Every export runs on the saved defaults, so the plain chord opens them beside an Export button and the shifted one skips straight to exporting.
<sub>`ui/dr-ui/ui/library.slint:3158`</sub> <sub>`ui/dr-ui/ui/library.slint:3159`</sub>
### Paste copied settings onto the selection ### Paste copied settings onto the selection
@@ -611,7 +611,7 @@ Lightroom's and darktable's chords. Every export runs on the saved defaults, so
- **Keyboard** — `Ctrl+V` - **Keyboard** — `Ctrl+V`
- **See it** — [in the manual](manual/README.md#copying-settings) - **See it** — [in the manual](manual/README.md#copying-settings)
<sub>`ui/dr-ui/ui/library.slint:3182`</sub> <sub>`ui/dr-ui/ui/library.slint:3183`</sub>
### Keyword the selection ### Keyword the selection
@@ -621,7 +621,7 @@ Lightroom's and darktable's chords. Every export runs on the saved defaults, so
Lightroom's keywording chord. The sheet opens with its field ready for typing, so the keys that judge in the grid are out of the way until it closes. Lightroom's keywording chord. The sheet opens with its field ready for typing, so the keys that judge in the grid are out of the way until it closes.
<sub>`ui/dr-ui/ui/library.slint:3211`</sub> <sub>`ui/dr-ui/ui/library.slint:3212`</sub>
### Show only photographs with some number of stars ### Show only photographs with some number of stars
@@ -632,7 +632,7 @@ Lightroom's keywording chord. The sheet opens with its field ready for typing, s
The chips say "this many or more". A range with a ceiling — the twos and threes still to be decided — is the keyboard's alone, and the bar says so in words while it holds. The chips say "this many or more". A range with a ceiling — the twos and threes still to be decided — is the keyboard's alone, and the bar says so in words while it holds.
<sub>`ui/dr-ui/ui/library.slint:3245`</sub> <sub>`ui/dr-ui/ui/library.slint:3246`</sub>
### Give photographs a colour label ### Give photographs a colour label
@@ -643,7 +643,7 @@ The chips say "this many or more". A range with a ceiling — the twos and three
Lightroom's keys, so hands that learned them there need not learn them again. Purple has no key there either, and is on the bar. Every mark carries its label's initial, so the label is read without telling the colours apart. Lightroom's keys, so hands that learned them there need not learn them again. Purple has no key there either, and is on the bar. Every mark carries its label's initial, so the label is read without telling the colours apart.
<sub>`ui/dr-ui/ui/library.slint:3295`</sub> <sub>`ui/dr-ui/ui/library.slint:3296`</sub>
### Pick or reject a photograph ### Pick or reject a photograph
@@ -653,7 +653,7 @@ Lightroom's keys, so hands that learned them there need not learn them again. Pu
The keys every culling tool uses, so muscle memory built elsewhere works here. The keys every culling tool uses, so muscle memory built elsewhere works here.
<sub>`ui/dr-ui/ui/library.slint:3319`</sub> <sub>`ui/dr-ui/ui/library.slint:3320`</sub>
### Move photographs to the trash ### Move photographs to the trash
@@ -663,7 +663,7 @@ The keys every culling tool uses, so muscle memory built elsewhere works here.
The bin acts on one photograph, so a stray click cannot trash a selection; the key acts on the selection because that is what every file manager's Delete does. Both are undone from the trash view. The bin acts on one photograph, so a stray click cannot trash a selection; the key acts on the selection because that is what every file manager's Delete does. Both are undone from the trash view.
<sub>`ui/dr-ui/ui/library.slint:3346`</sub> <sub>`ui/dr-ui/ui/library.slint:3347`</sub>
### Open this list ### Open this list
@@ -671,7 +671,7 @@ The bin acts on one photograph, so a stray click cannot trash a selection; the k
- **Pointer** — Press Help in the header, and Done to put it away - **Pointer** — Press Help in the header, and Done to put it away
- **Keyboard** — `F1`, and `Escape` to put it away - **Keyboard** — `F1`, and `Escape` to put it away
<sub>`ui/dr-ui/ui/library.slint:3371`</sub> <sub>`ui/dr-ui/ui/library.slint:3372`</sub>
### Rename the collection the grid is showing ### Rename the collection the grid is showing
@@ -679,7 +679,7 @@ The bin acts on one photograph, so a stray click cannot trash a selection; the k
- **Pointer** — Double-click it in the sidebar - **Pointer** — Double-click it in the sidebar
- **Keyboard** — `F2` - **Keyboard** — `F2`
<sub>`ui/dr-ui/ui/library.slint:3379`</sub> <sub>`ui/dr-ui/ui/library.slint:3380`</sub>
### Move through the grid ### Move through the grid
@@ -689,7 +689,7 @@ The bin acts on one photograph, so a stray click cannot trash a selection; the k
The cursor selects what it lands on, so walking and judging are one hand's work. The cursor selects what it lands on, so walking and judging are one hand's work.
<sub>`ui/dr-ui/ui/library.slint:3399`</sub> <sub>`ui/dr-ui/ui/library.slint:3400`</sub>
### Resize the thumbnails ### Resize the thumbnails
@@ -700,7 +700,7 @@ The cursor selects what it lands on, so walking and judging are one hand's work.
There is no wheel on a tablet, so without the pinch the cell size could only be changed by a control a finger cannot reach. There is no wheel on a tablet, so without the pinch the cell size could only be changed by a control a finger cannot reach.
<sub>`ui/dr-ui/ui/library.slint:3530`</sub> <sub>`ui/dr-ui/ui/library.slint:3531`</sub>
### File photographs in a collection ### File photographs in a collection
@@ -710,7 +710,7 @@ There is no wheel on a tablet, so without the pinch the cell size could only be
The selection is what the drag carries, which is why selecting several is worth the mode: forty photographs file in one gesture. The selection is what the drag carries, which is why selecting several is worth the mode: forty photographs file in one gesture.
<sub>`ui/dr-ui/ui/library.slint:3729`</sub> <sub>`ui/dr-ui/ui/library.slint:3730`</sub>
### Open a photograph ### Open a photograph
@@ -721,7 +721,7 @@ The selection is what the drag carries, which is why selecting several is worth
A tap opens; a tap that *moved* does not. Travel is what separates a deliberate tap from a hand brushing past, and it is the only thing that does: the two are the same length. An earlier version required the finger to dwell 120 ms instead, and that rejected ordinary taps — a real tap is often quicker than a brush. A tap opens; a tap that *moved* does not. Travel is what separates a deliberate tap from a hand brushing past, and it is the only thing that does: the two are the same length. An earlier version required the finger to dwell 120 ms instead, and that rejected ordinary taps — a real tap is often quicker than a brush.
<sub>`ui/dr-ui/ui/library.slint:4034`</sub> <sub>`ui/dr-ui/ui/library.slint:4035`</sub>
### Rate a photograph without opening it ### Rate a photograph without opening it
@@ -732,7 +732,7 @@ A tap opens; a tap that *moved* does not. Travel is what separates a deliberate
A star has to take the press without it also reaching the cell, or every rating throws the user into develop. A star has to take the press without it also reaching the cell, or every rating throws the user into develop.
<sub>`ui/dr-ui/ui/library.slint:4157`</sub> <sub>`ui/dr-ui/ui/library.slint:4158`</sub>
### Choose the frame a folded burst shows ### Choose the frame a folded burst shows
@@ -742,7 +742,7 @@ A star has to take the press without it also reaching the cell, or every rating
A folded burst draws its earliest frame, which is a fact about the clock and not a judgement about the photograph — nothing in this application ranks a frame (FR-CULL-5). But the point of a burst is that one of the twelve is better than the other eleven, and the photographer is the only one who knows which. So the choice is offered on the frames themselves, while they are open and side by side, which is the one moment the alternatives are on screen to be compared. A folded burst draws its earliest frame, which is a fact about the clock and not a judgement about the photograph — nothing in this application ranks a frame (FR-CULL-5). But the point of a burst is that one of the twelve is better than the other eleven, and the photographer is the only one who knows which. So the choice is offered on the frames themselves, while they are open and side by side, which is the one moment the alternatives are on screen to be compared.
<sub>`ui/dr-ui/ui/library.slint:4290`</sub> <sub>`ui/dr-ui/ui/library.slint:4291`</sub>
### Drop the selection but keep selecting ### Drop the selection but keep selecting
@@ -753,7 +753,7 @@ A folded burst draws its earliest frame, which is a fact about the clock and not
Distinct from Done, which leaves the mode entirely. Clearing keeps it, so the next selection can start straight away. Distinct from Done, which leaves the mode entirely. Clearing keeps it, so the next selection can start straight away.
<sub>`ui/dr-ui/ui/library.slint:4981`</sub> <sub>`ui/dr-ui/ui/library.slint:4982`</sub>
### Select everything the grid is showing ### Select everything the grid is showing
@@ -764,7 +764,7 @@ Distinct from Done, which leaves the mode entirely. Clearing keeps it, so the ne
A scoped grid of two hundred frames is two hundred taps otherwise, and "all of them, except those three" is a far more common shape than the taps it took to say it. A scoped grid of two hundred frames is two hundred taps otherwise, and "all of them, except those three" is a far more common shape than the taps it took to say it.
<sub>`ui/dr-ui/ui/library.slint:5000`</sub> <sub>`ui/dr-ui/ui/library.slint:5001`</sub>
### Take photographs out of a collection ### Take photographs out of a collection
@@ -774,7 +774,7 @@ A scoped grid of two hundred frames is two hundred taps otherwise, and "all of t
The badge on a cell says a photograph is filed in three collections and never which. This is the sheet that names them, and the only way out of one the grid is not currently scoped to. The badge on a cell says a photograph is filed in three collections and never which. This is the sheet that names them, and the only way out of one the grid is not currently scoped to.
<sub>`ui/dr-ui/ui/library.slint:5181`</sub> <sub>`ui/dr-ui/ui/library.slint:5182`</sub>
## Settings ## Settings
+56 -43
View File
@@ -128,7 +128,11 @@ impl AlbumsController {
let borrow = catalog.borrow(); let borrow = catalog.borrow();
let Some(cat) = borrow.as_ref() else { return }; let Some(cat) = borrow.as_ref() else { return };
if let Err(e) = albums::record_exports(cat.connection(), album, &files) { if let Err(e) = albums::record_exports(cat.connection(), album, &files) {
log::warn!("recording {} exports in album {}: {e}", files.len(), album.0); log::warn!(
"recording {} exports in album {}: {e}",
files.len(),
album.0
);
return; return;
} }
} }
@@ -188,11 +192,12 @@ fn adopt_old_destination(ctl: &AlbumsController, cat: &dr_catalog::Catalog) {
return; return;
} }
let place = Place::Local(export.destination.trim().to_string()); let place = Place::Local(export.destination.trim().to_string());
match albums::create(conn, "Exports", &place) match albums::create(conn, "Exports", &place).and_then(|id| albums::get(conn, id)) {
.and_then(|id| albums::get(conn, id))
{
Ok(Some(album)) => { Ok(Some(album)) => {
log::info!("the export folder {} is now the album “Exports”", export.destination); log::info!(
"the export folder {} is now the album “Exports”",
export.destination
);
ctl.settings.edit(|s| s.export.album = album.uuid); ctl.settings.edit(|s| s.export.album = album.uuid);
} }
Ok(None) => {} Ok(None) => {}
@@ -252,7 +257,10 @@ fn describe(place: Option<&Place>) -> String {
fn display_folder(folder: &str) -> String { fn display_folder(folder: &str) -> String {
if folder.starts_with("content://") { if folder.starts_with("content://") {
let tail = folder.rsplit('/').next().unwrap_or(folder); let tail = folder.rsplit('/').next().unwrap_or(folder);
let decoded = tail.replace("%3A", ":").replace("%2F", "/").replace("%20", " "); let decoded = tail
.replace("%3A", ":")
.replace("%2F", "/")
.replace("%20", " ");
return decoded return decoded
.split_once(':') .split_once(':')
.map(|(_, p)| p.to_string()) .map(|(_, p)| p.to_string())
@@ -268,7 +276,10 @@ fn render_sheet(window: &AppWindow, ctl: &AlbumsController) {
albums.set_sheet_open(false); albums.set_sheet_open(false);
return; return;
}; };
let server = ctl.library.credentials().is_some_and(|c| !c.account.login.is_empty()); let server = ctl
.library
.credentials()
.is_some_and(|c| !c.account.login.is_empty());
let refusal = if s.at == Where::Server { let refusal = if s.at == Where::Server {
refusal(&s.browser.path, ctl) refusal(&s.browser.path, ctl)
} else { } else {
@@ -329,7 +340,9 @@ fn inside(path: &str, root: &str) -> bool {
/// List the sheet's server folder, and redraw when the answer comes. /// List the sheet's server folder, and redraw when the answer comes.
fn browse(weak: slint::Weak<AppWindow>, ctl: Rc<AlbumsController>, path: String) { fn browse(weak: slint::Weak<AppWindow>, ctl: Rc<AlbumsController>, path: String) {
let Some(conn) = ctl.library.credentials() else { return }; let Some(conn) = ctl.library.credentials() else {
return;
};
if let Some(s) = ctl.sheet.borrow_mut().as_mut() { if let Some(s) = ctl.sheet.borrow_mut().as_mut() {
s.browser.path = path.clone(); s.browser.path = path.clone();
s.browser.entries.clear(); s.browser.entries.clear();
@@ -375,7 +388,10 @@ fn settle(
/// Open the sheet — on a new album, or on `editing`. /// Open the sheet — on a new album, or on `editing`.
fn open_sheet(window: &AppWindow, ctl: &Rc<AlbumsController>, editing: Option<AlbumId>) { fn open_sheet(window: &AppWindow, ctl: &Rc<AlbumsController>, editing: Option<AlbumId>) {
let album = editing.and_then(|id| ctl.rows.borrow().iter().find(|a| a.id == id).cloned()); let album = editing.and_then(|id| ctl.rows.borrow().iter().find(|a| a.id == id).cloned());
let server = ctl.library.credentials().is_some_and(|c| !c.account.login.is_empty()); let server = ctl
.library
.credentials()
.is_some_and(|c| !c.account.login.is_empty());
let (at, device_folder, server_path) = match album.as_ref().and_then(|a| a.place.clone()) { let (at, device_folder, server_path) = match album.as_ref().and_then(|a| a.place.clone()) {
Some(Place::Local(f)) => (Where::Device, f, String::new()), Some(Place::Local(f)) => (Where::Device, f, String::new()),
Some(Place::Server(p)) => (Where::Server, String::new(), p), Some(Place::Server(p)) => (Where::Server, String::new(), p),
@@ -417,14 +433,13 @@ fn save(window: &AppWindow, ctl: &Rc<AlbumsController>) {
let Some(cat) = borrow.as_ref() else { return }; let Some(cat) = borrow.as_ref() else { return };
let conn = cat.connection(); let conn = cat.connection();
match editing { match editing {
Some(id) => albums::rename(conn, id, &name) Some(id) => albums::rename(conn, id, &name).and_then(|()| {
.and_then(|()| { let current = albums::get(conn, id)?.and_then(|a| a.place);
let current = albums::get(conn, id)?.and_then(|a| a.place); if current.as_ref() != Some(&place) {
if current.as_ref() != Some(&place) { albums::set_place(conn, id, &place)?;
albums::set_place(conn, id, &place)?; }
} Ok(id)
Ok(id) }),
}),
None => albums::create(conn, &name, &place), None => albums::create(conn, &name, &place),
} }
.and_then(|id| Ok((id, albums::get(conn, id)?))) .and_then(|id| Ok((id, albums::get(conn, id)?)))
@@ -686,7 +701,9 @@ pub fn wire(
let ctl = ctl.clone(); let ctl = ctl.clone();
albums.on_browse_make(move |name| { albums.on_browse_make(move |name| {
let Some(w) = weak.upgrade() else { return }; let Some(w) = weak.upgrade() else { return };
let Some(conn) = ctl.library.credentials() else { return }; let Some(conn) = ctl.library.credentials() else {
return;
};
let parent = { let parent = {
let mut sheet = ctl.sheet.borrow_mut(); let mut sheet = ctl.sheet.borrow_mut();
let Some(s) = sheet.as_mut() else { return }; let Some(s) = sheet.as_mut() else { return };
@@ -700,18 +717,16 @@ pub fn wire(
let name = name.trim().to_string(); let name = name.trim().to_string();
let (weak, ctl2) = (weak.clone(), ctl.clone()); let (weak, ctl2) = (weak.clone(), ctl.clone());
let child = name.clone(); let child = name.clone();
crate::remote_folders::make(conn, parent.clone(), name, move |result| { crate::remote_folders::make(conn, parent.clone(), name, move |result| match result {
match result { Ok(_) => {
Ok(_) => { let path = if parent.is_empty() {
let path = if parent.is_empty() { child
child } else {
} else { format!("{parent}/{child}")
format!("{parent}/{child}") };
}; browse(weak, ctl2, path);
browse(weak, ctl2, path);
}
Err(e) => settle(&weak, &ctl2, &parent, Err(e)),
} }
Err(e) => settle(&weak, &ctl2, &parent, Err(e)),
}); });
}); });
} }
@@ -720,20 +735,18 @@ pub fn wire(
{ {
let weak = window.as_weak(); let weak = window.as_weak();
let ctl = ctl.clone(); let ctl = ctl.clone();
window window.global::<ExportOptions>().on_album_picked(move |i| {
.global::<ExportOptions>() let Some(w) = weak.upgrade() else { return };
.on_album_picked(move |i| { let uuid = ctl
let Some(w) = weak.upgrade() else { return }; .rows
let uuid = ctl .borrow()
.rows .get(i.max(0) as usize)
.borrow() .map(|a| a.uuid.clone());
.get(i.max(0) as usize) if let Some(uuid) = uuid {
.map(|a| a.uuid.clone()); ctl.settings.edit(|s| s.export.album = uuid);
if let Some(uuid) = uuid { }
ctl.settings.edit(|s| s.export.album = uuid); render(&w, &ctl);
} });
render(&w, &ctl);
});
} }
{ {
let weak = window.as_weak(); let weak = window.as_weak();
+3 -1
View File
@@ -220,7 +220,9 @@ fn refuse(window: &AppWindow, to: export::Reporting, message: &str) {
window.set_export_busy(false); window.set_export_busy(false);
} }
export::Reporting::Library => { export::Reporting::Library => {
window.global::<Library>().set_library_status(message.into()); window
.global::<Library>()
.set_library_status(message.into());
window.global::<Library>().set_library_exporting(false); window.global::<Library>().set_library_exporting(false);
} }
} }
+8 -3
View File
@@ -313,8 +313,7 @@ fn stage(encoded: &Encoded, remote_dir: &str, outbox: &Path) -> Result<PathBuf,
Some(dir) => format!("{dir}\n{}\naccount\n", encoded.name), Some(dir) => format!("{dir}\n{}\naccount\n", encoded.name),
None => format!("{remote_dir}\n{}\n", encoded.name), None => format!("{remote_dir}\n{}\n", encoded.name),
}; };
std::fs::write(&record, text) std::fs::write(&record, text).map_err(|e| format!("{}: {e}", record.display()))?;
.map_err(|e| format!("{}: {e}", record.display()))?;
Ok(candidate) Ok(candidate)
} }
@@ -1503,7 +1502,13 @@ mod tests {
std::thread::current().id() std::thread::current().id()
)); ));
let _ = std::fs::remove_dir_all(&dir); let _ = std::fs::remove_dir_all(&dir);
place(&encoded("a.jpg", b"x"), ExportTarget::Remote, "/Shared/Web", &dir).unwrap(); place(
&encoded("a.jpg", b"x"),
ExportTarget::Remote,
"/Shared/Web",
&dir,
)
.unwrap();
let entry = pending(&dir).pop().expect("one staged export"); let entry = pending(&dir).pop().expect("one staged export");
assert!(entry.account); assert!(entry.account);
+2 -2
View File
@@ -33,10 +33,10 @@
use std::path::PathBuf; use std::path::PathBuf;
#[cfg(not(target_os = "android"))]
use slint::ComponentHandle;
#[cfg(not(target_os = "android"))] #[cfg(not(target_os = "android"))]
use raw_window_handle::{HasDisplayHandle as _, HasWindowHandle as _}; use raw_window_handle::{HasDisplayHandle as _, HasWindowHandle as _};
#[cfg(not(target_os = "android"))]
use slint::ComponentHandle;
use crate::AppWindow; use crate::AppWindow;
+8 -1
View File
@@ -506,7 +506,14 @@ fn wire_options(window: &AppWindow, ctl: &Rc<ImportController>) {
let ctl = ctl.clone(); let ctl = ctl.clone();
window.on_import_choose_backup(move || { window.on_import_choose_backup(move || {
let Some(w) = weak.upgrade() else { return }; let Some(w) = weak.upgrade() else { return };
let start = ctl.settings.settings.borrow().import.backup.trim().to_string(); let start = ctl
.settings
.settings
.borrow()
.import
.backup
.trim()
.to_string();
let (weak, ctl) = (weak.clone(), ctl.clone()); let (weak, ctl) = (weak.clone(), ctl.clone());
crate::folder_dialog::ask( crate::folder_dialog::ask(
&w, &w,
+3 -1
View File
@@ -350,7 +350,9 @@ fn wire_folder_picker_navigation(window: &AppWindow, controller: &Rc<LaunchContr
let (account, parent) = { let (account, parent) = {
let m = ctl.model.borrow(); let m = ctl.model.borrow();
let Some(b) = m.browser.as_ref() else { return }; let Some(b) = m.browser.as_ref() else { return };
let Some(account) = m.session().cloned() else { return }; let Some(account) = m.session().cloned() else {
return;
};
(account, b.path.clone()) (account, b.path.clone())
}; };
let conn = match ctl let conn = match ctl
+2 -2
View File
@@ -34,8 +34,8 @@ mod display_ui;
mod duplicates; mod duplicates;
mod duplicates_ui; mod duplicates_ui;
mod export; mod export;
mod folder_dialog;
pub mod faces; pub mod faces;
mod folder_dialog;
pub use library::render_native; pub use library::render_native;
// Generated from the `GESTURE:` comments beside the code that implements each // Generated from the `GESTURE:` comments beside the code that implements each
// one — see `tools/traceability`. Regenerate with // one — see `tools/traceability`. Regenerate with
@@ -68,9 +68,9 @@ mod recovery_ui;
mod refine; mod refine;
mod remote; mod remote;
mod remote_folders; mod remote_folders;
pub mod repairs;
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
mod saf; mod saf;
pub mod repairs;
mod segmentation; mod segmentation;
mod settings_store; mod settings_store;
mod settings_ui; mod settings_ui;
+18 -3
View File
@@ -661,18 +661,33 @@ mod tests {
.unwrap(); .unwrap();
let filter = RatingFilter::default(); let filter = RatingFilter::default();
let cells = read_cells_scoped(&catalog, Some(Scope::Collection(coll)), &filter, 0, 100).unwrap(); let cells =
read_cells_scoped(&catalog, Some(Scope::Collection(coll)), &filter, 0, 100).unwrap();
assert_eq!(cells.len(), 2); assert_eq!(cells.len(), 2);
for (i, cell) in cells.iter().enumerate() { for (i, cell) in cells.iter().enumerate() {
assert_eq!( assert_eq!(
ordinal_of_path(&catalog, Some(Scope::Collection(coll)), &filter, false, &cell.remote_path).unwrap(), ordinal_of_path(
&catalog,
Some(Scope::Collection(coll)),
&filter,
false,
&cell.remote_path
)
.unwrap(),
Some(i), Some(i),
"{} is drawn at row {i} of the collection", "{} is drawn at row {i} of the collection",
cell.remote_path cell.remote_path
); );
} }
assert_eq!( assert_eq!(
ordinal_of_path(&catalog, Some(Scope::Collection(coll)), &filter, false, "2019/a.CR2").unwrap(), ordinal_of_path(
&catalog,
Some(Scope::Collection(coll)),
&filter,
false,
"2019/a.CR2"
)
.unwrap(),
None, None,
"not a member" "not a member"
); );
+92 -22
View File
@@ -415,8 +415,8 @@ mod tests {
let catalog = with_images(10); let catalog = with_images(10);
let ids = image_ids(&catalog); let ids = image_ids(&catalog);
let album = albums::create(catalog.connection(), "Web", &Place::Local("/out".into())) let album =
.unwrap(); albums::create(catalog.connection(), "Web", &Place::Local("/out".into())).unwrap();
// Two files from one photograph, one from another: two cells. // Two files from one photograph, one from another: two cells.
albums::record_exports( albums::record_exports(
catalog.connection(), catalog.connection(),
@@ -460,10 +460,22 @@ mod tests {
.unwrap(); .unwrap();
coll::add_images(catalog.connection(), c, &ids[2..5]).unwrap(); coll::add_images(catalog.connection(), c, &ids[2..5]).unwrap();
let cells = read_cells_scoped(&catalog, Some(Scope::Collection(c)), &RatingFilter::default(), 0, 120).unwrap(); let cells = read_cells_scoped(
&catalog,
Some(Scope::Collection(c)),
&RatingFilter::default(),
0,
120,
)
.unwrap();
assert_eq!(cells.len(), 3); assert_eq!(cells.len(), 3);
assert_eq!( assert_eq!(
total_images_scoped(&catalog, Some(Scope::Collection(c)), &RatingFilter::default()).unwrap(), total_images_scoped(
&catalog,
Some(Scope::Collection(c)),
&RatingFilter::default()
)
.unwrap(),
3 3
); );
// Unscoped is still the whole library. // Unscoped is still the whole library.
@@ -493,11 +505,22 @@ mod tests {
coll::add_images(catalog.connection(), iceland, &ids[0..4]).unwrap(); coll::add_images(catalog.connection(), iceland, &ids[0..4]).unwrap();
// The parent itself has no direct members at all. // The parent itself has no direct members at all.
let cells = let cells = read_cells_scoped(
read_cells_scoped(&catalog, Some(Scope::Collection(trips)), &RatingFilter::default(), 0, 120).unwrap(); &catalog,
Some(Scope::Collection(trips)),
&RatingFilter::default(),
0,
120,
)
.unwrap();
assert_eq!(cells.len(), 4, "the set shows what its children hold"); assert_eq!(cells.len(), 4, "the set shows what its children hold");
assert_eq!( assert_eq!(
total_images_scoped(&catalog, Some(Scope::Collection(trips)), &RatingFilter::default()).unwrap(), total_images_scoped(
&catalog,
Some(Scope::Collection(trips)),
&RatingFilter::default()
)
.unwrap(),
4 4
); );
} }
@@ -522,11 +545,22 @@ mod tests {
coll::add_images(catalog.connection(), trips, &ids[0..2]).unwrap(); coll::add_images(catalog.connection(), trips, &ids[0..2]).unwrap();
coll::add_images(catalog.connection(), iceland, &ids[0..3]).unwrap(); coll::add_images(catalog.connection(), iceland, &ids[0..3]).unwrap();
let cells = let cells = read_cells_scoped(
read_cells_scoped(&catalog, Some(Scope::Collection(trips)), &RatingFilter::default(), 0, 120).unwrap(); &catalog,
Some(Scope::Collection(trips)),
&RatingFilter::default(),
0,
120,
)
.unwrap();
assert_eq!(cells.len(), 3, "images 0..3, each once"); assert_eq!(cells.len(), 3, "images 0..3, each once");
assert_eq!( assert_eq!(
total_images_scoped(&catalog, Some(Scope::Collection(trips)), &RatingFilter::default()).unwrap(), total_images_scoped(
&catalog,
Some(Scope::Collection(trips)),
&RatingFilter::default()
)
.unwrap(),
3 3
); );
} }
@@ -542,7 +576,14 @@ mod tests {
let c = coll::create(catalog.connection(), "Big", None, CollectionKind::Manual).unwrap(); let c = coll::create(catalog.connection(), "Big", None, CollectionKind::Manual).unwrap();
coll::add_images(catalog.connection(), c, &ids).unwrap(); coll::add_images(catalog.connection(), c, &ids).unwrap();
let page = read_cells_scoped(&catalog, Some(Scope::Collection(c)), &RatingFilter::default(), 10, 5).unwrap(); let page = read_cells_scoped(
&catalog,
Some(Scope::Collection(c)),
&RatingFilter::default(),
10,
5,
)
.unwrap();
assert_eq!(page.len(), 5); assert_eq!(page.len(), 5);
assert_eq!(page[0].name, "img010.CR2"); assert_eq!(page[0].name, "img010.CR2");
} }
@@ -556,13 +597,22 @@ mod tests {
let catalog = with_images(10); let catalog = with_images(10);
let c = coll::create(catalog.connection(), "Empty", None, CollectionKind::Manual).unwrap(); let c = coll::create(catalog.connection(), "Empty", None, CollectionKind::Manual).unwrap();
assert!( assert!(read_cells_scoped(
read_cells_scoped(&catalog, Some(Scope::Collection(c)), &RatingFilter::default(), 0, 120) &catalog,
.unwrap() Some(Scope::Collection(c)),
.is_empty() &RatingFilter::default(),
); 0,
120
)
.unwrap()
.is_empty());
assert_eq!( assert_eq!(
total_images_scoped(&catalog, Some(Scope::Collection(c)), &RatingFilter::default()).unwrap(), total_images_scoped(
&catalog,
Some(Scope::Collection(c)),
&RatingFilter::default()
)
.unwrap(),
0 0
); );
} }
@@ -671,15 +721,29 @@ mod tests {
let wanted: Vec<_> = all.iter().rev().copied().collect(); let wanted: Vec<_> = all.iter().rev().copied().collect();
dr_catalog::collections::set_order(catalog.connection(), id, &wanted).unwrap(); dr_catalog::collections::set_order(catalog.connection(), id, &wanted).unwrap();
let cells = read_cells_scoped(&catalog, Some(Scope::Collection(id)), &RatingFilter::default(), 0, 50).unwrap(); let cells = read_cells_scoped(
&catalog,
Some(Scope::Collection(id)),
&RatingFilter::default(),
0,
50,
)
.unwrap();
let drawn: Vec<_> = cells let drawn: Vec<_> = cells
.iter() .iter()
.map(|c| dr_types::ImageId(c.image_id as u64)) .map(|c| dr_types::ImageId(c.image_id as u64))
.collect(); .collect();
assert_eq!(drawn, wanted, "the grid draws the order that was written"); assert_eq!(drawn, wanted, "the grid draws the order that was written");
let spanned = let spanned = read_ids_span(
read_ids_span(&catalog, Some(Scope::Collection(id)), &RatingFilter::default(), false, 0, 4).unwrap(); &catalog,
Some(Scope::Collection(id)),
&RatingFilter::default(),
false,
0,
4,
)
.unwrap();
assert_eq!(spanned, wanted, "and a range resolves through the same one"); assert_eq!(spanned, wanted, "and a range resolves through the same one");
assert_eq!( assert_eq!(
@@ -715,8 +779,14 @@ mod tests {
let reversed: Vec<_> = all.iter().rev().copied().collect(); let reversed: Vec<_> = all.iter().rev().copied().collect();
dr_catalog::collections::set_order(catalog.connection(), parent, &reversed).unwrap(); dr_catalog::collections::set_order(catalog.connection(), parent, &reversed).unwrap();
let cells = let cells = read_cells_scoped(
read_cells_scoped(&catalog, Some(Scope::Collection(parent)), &RatingFilter::default(), 0, 50).unwrap(); &catalog,
Some(Scope::Collection(parent)),
&RatingFilter::default(),
0,
50,
)
.unwrap();
let drawn: Vec<_> = cells let drawn: Vec<_> = cells
.iter() .iter()
.map(|c| dr_types::ImageId(c.image_id as u64)) .map(|c| dr_types::ImageId(c.image_id as u64))
+1 -1
View File
@@ -342,7 +342,7 @@ pub(super) fn load_window(window: &AppWindow, ctl: &Rc<LibraryController>) {
.set_library_scope_pinned(match scope { .set_library_scope_pinned(match scope {
Some(library::Scope::Collection(id)) => { Some(library::Scope::Collection(id)) => {
dr_catalog::collections::descendants(catalog.connection(), id) dr_catalog::collections::descendants(catalog.connection(), id)
.map(|ids| collection_images(catalog, &ids)) .map(|ids| collection_images(catalog, &ids))
.map(|images| scope_is_pinned(catalog, &images)) .map(|images| scope_is_pinned(catalog, &images))
.unwrap_or(false) .unwrap_or(false)
} }
+8 -2
View File
@@ -1100,9 +1100,15 @@ pub fn wire_named(
window.on_browse_presets(move |file| { window.on_browse_presets(move |file| {
let Some(w) = weak.upgrade() else { return }; let Some(w) = weak.upgrade() else { return };
let (title, pick) = if file { let (title, pick) = if file {
("Import a Lightroom preset", crate::folder_dialog::Pick::File(&["xmp"])) (
"Import a Lightroom preset",
crate::folder_dialog::Pick::File(&["xmp"]),
)
} else { } else {
("Import a folder of Lightroom presets", crate::folder_dialog::Pick::Folder) (
"Import a folder of Lightroom presets",
crate::folder_dialog::Pick::Folder,
)
}; };
let (weak, named) = (weak.clone(), named.clone()); let (weak, named) = (weak.clone(), named.clone());
crate::folder_dialog::ask(&w, title, pick, None, move |path| { crate::folder_dialog::ask(&w, title, pick, None, move |path| {
+33 -23
View File
@@ -18,7 +18,11 @@ use dr_sync::{Connection, EntryKind, RemotePath};
/// Child folder names at `path` (empty is the account root), sorted as a /// Child folder names at `path` (empty is the account root), sorted as a
/// person reads them. /// person reads them.
pub fn list(conn: Connection, path: String, done: impl FnOnce(Result<Vec<String>, String>) + 'static) { pub fn list(
conn: Connection,
path: String,
done: impl FnOnce(Result<Vec<String>, String>) + 'static,
) {
run(conn, done, move |backend| { run(conn, done, move |backend| {
Box::pin(async move { children(backend.as_ref(), &path).await }) Box::pin(async move { children(backend.as_ref(), &path).await })
}); });
@@ -129,28 +133,34 @@ where
let mut done = Some(done); let mut done = Some(done);
let timer = slint::Timer::default(); let timer = slint::Timer::default();
let held = slot.clone(); let held = slot.clone();
timer.start(slint::TimerMode::Repeated, Duration::from_millis(100), move || { timer.start(
let outcome = match rx.try_recv() { slint::TimerMode::Repeated,
Ok(result) => result, Duration::from_millis(100),
Err(TryRecvError::Empty) => return, move || {
// A worker that panicked drops the sender without sending, and let outcome = match rx.try_recv() {
// treating that as "still loading" is how a picker sits on Ok(result) => result,
// "Loading…" for ever. Err(TryRecvError::Empty) => return,
Err(TryRecvError::Disconnected) => Err("the folder request failed unexpectedly".into()), // A worker that panicked drops the sender without sending, and
}; // treating that as "still loading" is how a picker sits on
if let Some(done) = done.take() { // "Loading…" for ever.
done(outcome); Err(TryRecvError::Disconnected) => {
} Err("the folder request failed unexpectedly".into())
// Stopped here, released a turn later: a timer dropped inside its }
// own callback is freed while Slint is still calling it. };
if let Some(t) = held.borrow().as_ref() { if let Some(done) = done.take() {
t.stop(); done(outcome);
} }
let held = held.clone(); // Stopped here, released a turn later: a timer dropped inside its
slint::Timer::single_shot(Duration::ZERO, move || { // own callback is freed while Slint is still calling it.
held.borrow_mut().take(); if let Some(t) = held.borrow().as_ref() {
}); t.stop();
}); }
let held = held.clone();
slint::Timer::single_shot(Duration::ZERO, move || {
held.borrow_mut().take();
});
},
);
*slot.borrow_mut() = Some(timer); *slot.borrow_mut() = Some(timer);
} }
+57 -39
View File
@@ -91,7 +91,11 @@ fn text(env: &mut jni::Env, value: JObject) -> jni::errors::Result<Option<String
/// activity, and this one's event loop keeps running under it. /// activity, and this one's event loop keeps running under it.
pub fn pick_tree(chosen: impl FnOnce(String) + 'static) { pub fn pick_tree(chosen: impl FnOnce(String) + 'static) {
let started = call("opening the folder picker", |env, activity| { let started = call("opening the folder picker", |env, activity| {
let cls = class(env, activity, jni::jni_str!("paris.tourolle.darkroom.FolderPicker"))?; let cls = class(
env,
activity,
jni::jni_str!("paris.tourolle.darkroom.FolderPicker"),
)?;
env.call_static_method( env.call_static_method(
&cls, &cls,
jni::jni_str!("start"), jni::jni_str!("start"),
@@ -112,44 +116,52 @@ pub fn pick_tree(chosen: impl FnOnce(String) + 'static) {
let mut chosen = Some(chosen); let mut chosen = Some(chosen);
let since = Instant::now(); let since = Instant::now();
let timer = slint::Timer::default(); let timer = slint::Timer::default();
timer.start(slint::TimerMode::Repeated, Duration::from_millis(250), move || { timer.start(
let answer = call("reading the folder picker", |env, activity| { slint::TimerMode::Repeated,
let cls = class(env, activity, jni::jni_str!("paris.tourolle.darkroom.FolderPicker"))?; Duration::from_millis(250),
let value = env move || {
.call_static_method( let answer = call("reading the folder picker", |env, activity| {
&cls, let cls = class(
jni::jni_str!("poll"), env,
jni::jni_sig!("()Ljava/lang/String;"), activity,
&[], jni::jni_str!("paris.tourolle.darkroom.FolderPicker"),
)? )?;
.l()?; let value = env
text(env, value) .call_static_method(
}); &cls,
let finished = match answer { jni::jni_str!("poll"),
Ok(None) => since.elapsed() > Duration::from_secs(600), jni::jni_sig!("()Ljava/lang/String;"),
Ok(Some(uri)) => { &[],
if !uri.is_empty() { )?
if let Some(chosen) = chosen.take() { .l()?;
chosen(uri); text(env, value)
}
}
true
}
Err(e) => {
log::warn!("{e}");
true
}
};
if finished {
if let Some(t) = held.borrow().as_ref() {
t.stop();
}
let held = held.clone();
slint::Timer::single_shot(Duration::ZERO, move || {
held.borrow_mut().take();
}); });
} let finished = match answer {
}); Ok(None) => since.elapsed() > Duration::from_secs(600),
Ok(Some(uri)) => {
if !uri.is_empty() {
if let Some(chosen) = chosen.take() {
chosen(uri);
}
}
true
}
Err(e) => {
log::warn!("{e}");
true
}
};
if finished {
if let Some(t) = held.borrow().as_ref() {
t.stop();
}
let held = held.clone();
slint::Timer::single_shot(Duration::ZERO, move || {
held.borrow_mut().take();
});
}
},
);
*slot.borrow_mut() = Some(timer); *slot.borrow_mut() = Some(timer);
} }
@@ -176,7 +188,13 @@ pub fn exists(tree: &str, name: &str) -> bool {
/// Write an export into the folder. Returns the name it has there, which the /// Write an export into the folder. Returns the name it has there, which the
/// provider may have changed on a collision. /// provider may have changed on a collision.
pub fn write(tree: &str, name: &str, mime: &str, bytes: &[u8], replace: bool) -> Result<String, String> { pub fn write(
tree: &str,
name: &str,
mime: &str,
bytes: &[u8],
replace: bool,
) -> Result<String, String> {
call("writing to the album folder", |env, activity| { call("writing to the album folder", |env, activity| {
let cls = class(env, activity, jni::jni_str!("paris.tourolle.darkroom.Saf"))?; let cls = class(env, activity, jni::jni_str!("paris.tourolle.darkroom.Saf"))?;
let jtree = env.new_string(tree)?; let jtree = env.new_string(tree)?;
+2 -2
View File
@@ -26,8 +26,8 @@ use std::rc::Rc;
use dr_types::settings::budget; use dr_types::settings::budget;
use dr_types::{ use dr_types::{
CacheSettings, CollisionPolicy, ColourSpace, ExportFormat, FaceDetector, CacheSettings, CollisionPolicy, ColourSpace, ExportFormat, FaceDetector, GroupNavigation,
GroupNavigation, LibrarySettings, OutputSharpening, ScreenSize, Settings, SizingMode, LibrarySettings, OutputSharpening, ScreenSize, Settings, SizingMode,
}; };
use slint::ComponentHandle; use slint::ComponentHandle;