diff --git a/news.d/47.beta/added-reload-action b/news.d/47.beta/added-reload-action new file mode 100644 index 0000000..b4102d1 --- /dev/null +++ b/news.d/47.beta/added-reload-action @@ -0,0 +1 @@ +Add reload button to errors and F5 as reload shortcut diff --git a/src/widgets/error_details.ui b/src/widgets/error_details.ui index c89bce5..c5f253b 100644 --- a/src/widgets/error_details.ui +++ b/src/widgets/error_details.ui @@ -56,13 +56,19 @@ - Report Issue… center 24 + + + external-link-symbolic + Report _Issue + true + + diff --git a/src/widgets/image/loading.rs b/src/widgets/image/loading.rs index 8b8fc4b..699a781 100644 --- a/src/widgets/image/loading.rs +++ b/src/widgets/image/loading.rs @@ -290,6 +290,15 @@ impl LpImage { self.imp().file.replace(Some(file.clone())); } + pub async fn reload(&self) { + dbg!("reloadking"); + if let Some(file) = self.file() { + self.load(&file).await; + } else { + log::error!("Trying to reload image without file"); + } + } + pub async fn load(&self, file: &gio::File) { let imp = self.imp(); log::debug!("Loading file {}", file.uri()); diff --git a/src/widgets/image_page.ui b/src/widgets/image_page.ui index 5a3f1e8..4bc52f2 100644 --- a/src/widgets/image_page.ui +++ b/src/widgets/image_page.ui @@ -47,7 +47,7 @@ true true - + @@ -56,12 +56,30 @@ image-missing-symbolic Could not Load Image - - More Information… + + vertical + 12 center - + + + More _Information + true + + + + + + _Reload + true + win.reload + + + diff --git a/src/window.rs b/src/window.rs index b1058c6..2f22733 100644 --- a/src/window.rs +++ b/src/window.rs @@ -758,6 +758,8 @@ impl LpWindow { for action in ACTIONS { self.action_set_enabled(action, enabled); } + + self.action_set_enabled(Action::Reload.as_ref(), true); } /// Handles change in image and availability of images diff --git a/src/window/actions.rs b/src/window/actions.rs index 8a67f1c..a9667ea 100644 --- a/src/window/actions.rs +++ b/src/window/actions.rs @@ -194,6 +194,8 @@ pub enum Action { ToggleProperties, #[strum(to_string = "win.about")] About, + #[strum(to_string = "win.reload")] + Reload, } impl Action { @@ -467,6 +469,17 @@ impl Action { win.show_about().await }); } + + Action::Reload => { + klass.install_action_async(&action, None, move |win, _, _| async move { + if let Some(current_page) = win.imp().image_view.current_page() { + current_page.image().reload().await; + } else { + log::error!("No current image to reload"); + } + }); + klass.add_binding_action(gdk::Key::F5, gdk::ModifierType::empty(), &action); + } } } }