Skip to content

Commit fceeb4a

Browse files
committed
Add button to open path in media modal
1 parent 0867e95 commit fceeb4a

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/gui/app.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ impl App {
762762
match result {
763763
Ok(_) => Message::Ignore,
764764
Err(e) => {
765-
log::error!("Unable to open directory: `{}` - {:?}", path2.resolve(), e);
765+
log::error!("Unable to open file: `{}` - {:?}", path2.resolve(), e);
766766
Message::OpenPathFailure { path: path2 }
767767
}
768768
}

src/gui/button.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,20 @@ pub fn choose_file<'a>(
232232
))
233233
}
234234

235+
pub fn open_path<'a>(path: StrictPath, modifiers: &keyboard::Modifiers) -> CustomButton<'a> {
236+
if modifiers.shift() {
237+
icon(Icon::FileOpen).on_press(Message::OpenFile { path })
238+
} else {
239+
icon(Icon::OpenInNew).on_press(Message::OpenDir { path })
240+
}
241+
.tooltip(format!(
242+
"{}\n{} {}",
243+
lang::action::open_folder(),
244+
lang::field(&lang::thing::key::shift()),
245+
lang::action::open_file()
246+
))
247+
}
248+
235249
pub fn move_up<'a>(action: fn(EditAction) -> Message, index: usize) -> CustomButton<'a> {
236250
icon(Icon::ArrowUpward).on_press_maybe((index > 0).then(|| action(EditAction::move_up(index))))
237251
}

src/gui/modal.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ impl Modal {
457457
for media in all_media {
458458
col = col.push(
459459
Row::new()
460-
.spacing(20)
460+
.spacing(10)
461461
.align_y(Alignment::Center)
462462
.push(if collection.is_error(media) {
463463
button::icon(Icon::Error)
@@ -478,7 +478,8 @@ impl Modal {
478478
}
479479
.small_control(),
480480
)
481-
.push(text(media.path().raw()).width(Length::Fill)),
481+
.push(button::open_path(media.path().clone(), modifiers))
482+
.push(text(media.path().raw())),
482483
);
483484
}
484485
}

0 commit comments

Comments
 (0)