Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/crates/concat/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,14 @@ pub fn image_of(frame: &concat_core::frame::Frame) -> slint::Image {
slint::Image::from_rgba8(buffer)
}

/// The JPEG at `path`, if it can be read, as a Slint image.
/// The picture at `path`, if it can be read, as a Slint image. A file that
/// is not there is `None` without a word: Slint prints every load that
/// fails, and a cached picture not drawn yet is the expected case, not a
/// fault.
pub fn image_at(path: &std::path::Path) -> Option<slint::Image> {
if !path.is_file() {
return None;
}
slint::Image::load_from_path(path).ok()
}

Expand Down
7 changes: 2 additions & 5 deletions src/crates/concat/src/studio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,11 +1195,8 @@ fn package_art(
package
.folder
.as_deref()
.and_then(|folder| slint::Image::load_from_path(&folder.join("preview.png")).ok())
.or_else(|| {
let card = card_paths.get(id)?;
slint::Image::load_from_path(card).ok()
})
.and_then(|folder| image_at(&folder.join("preview.png")))
.or_else(|| image_at(card_paths.get(id)?))
.or_else(|| bundled_card(id))
.unwrap_or_default()
})
Expand Down
Loading