From da5d8e9ed42b3a3e5e65127d8517489bbafb5e31 Mon Sep 17 00:00:00 2001 From: vesp Date: Tue, 13 Jan 2026 17:55:04 +0100 Subject: [PATCH] Add keyboard shortcuts: Ctrl+L (focus URL) and Ctrl+Return (send) --- src/shortcuts-dialog.ui | 12 ++++++++++++ src/window.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/shortcuts-dialog.ui b/src/shortcuts-dialog.ui index bef95b5..27a0723 100644 --- a/src/shortcuts-dialog.ui +++ b/src/shortcuts-dialog.ui @@ -26,6 +26,18 @@ <Control>s + + + Focus URL Field + <Control>l + + + + + Send Request + <Control>Return + + Show Shortcuts diff --git a/src/window.py b/src/window.py index 8c34013..6f2eb08 100644 --- a/src/window.py +++ b/src/window.py @@ -434,6 +434,23 @@ class RosterWindow(Adw.ApplicationWindow): if page: self.tab_view.close_page(page) + def _focus_url_field(self) -> None: + """Focus the URL field in the current tab.""" + page = self.tab_view.get_selected_page() + if page: + widget = self.page_to_widget.get(page) + if widget and hasattr(widget, 'url_entry'): + widget.url_entry.grab_focus() + + def _send_current_request(self) -> None: + """Send the request from the current tab.""" + page = self.tab_view.get_selected_page() + if page: + widget = self.page_to_widget.get(page) + if widget and hasattr(widget, 'send_button'): + # Trigger the send button click + self._on_send_clicked(widget) + def _on_new_request_clicked(self, button): """Handle New Request button click.""" self._create_new_tab() @@ -458,6 +475,18 @@ class RosterWindow(Adw.ApplicationWindow): self.add_action(action) self.get_application().set_accels_for_action("win.save-request", ["s"]) + # Focus URL field shortcut (Ctrl+L) + action = Gio.SimpleAction.new("focus-url", None) + action.connect("activate", lambda a, p: self._focus_url_field()) + self.add_action(action) + self.get_application().set_accels_for_action("win.focus-url", ["l"]) + + # Send request shortcut (Ctrl+Return) + action = Gio.SimpleAction.new("send-request", None) + action.connect("activate", lambda a, p: self._send_current_request()) + self.add_action(action) + self.get_application().set_accels_for_action("win.send-request", ["Return"]) + def _on_send_clicked(self, widget): """Handle Send button click from a tab widget.""" # Clear previous preprocessing results