window: Let the user select multiple files to open.
Uses code that drag and drop already uses. It's kinda ugly because the file dialog returns a ListModel. As an added bonus, since the button responds to the action "win.open", it will also allow open multiple files with the primary menu. It would be a good idea to change the "Open…" label in the primary menu though. Closes #191
This commit is contained in:
parent
8804938859
commit
c6897da62d
2 changed files with 11 additions and 3 deletions
|
|
@ -485,8 +485,16 @@ impl LpWindow {
|
|||
.modal(true)
|
||||
.build();
|
||||
|
||||
if let Ok(file) = chooser.open_future(Some(self)).await {
|
||||
self.image_view().set_image_from_file(file);
|
||||
if let Ok(selected) = chooser.open_multiple_future(Some(self)).await {
|
||||
let images: Vec<_> = selected
|
||||
.into_iter()
|
||||
.filter_map(|files| {
|
||||
files
|
||||
.ok()
|
||||
.and_then(|object| object.downcast::<gio::File>().ok())
|
||||
})
|
||||
.collect();
|
||||
self.image_view().set_images_from_files(images);
|
||||
} else {
|
||||
log::debug!("File dialog canceled or file not readable");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue