Add keyboard shortcuts: Ctrl+L (focus URL) and Ctrl+Return (send)
This commit is contained in:
parent
0765093ec4
commit
1da16b1db4
@ -26,6 +26,18 @@
|
|||||||
<property name="accelerator"><Control>s</property>
|
<property name="accelerator"><Control>s</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkShortcutsShortcut">
|
||||||
|
<property name="title" translatable="yes" context="shortcut window">Focus URL Field</property>
|
||||||
|
<property name="accelerator"><Control>l</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkShortcutsShortcut">
|
||||||
|
<property name="title" translatable="yes" context="shortcut window">Send Request</property>
|
||||||
|
<property name="accelerator"><Control>Return</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkShortcutsShortcut">
|
<object class="GtkShortcutsShortcut">
|
||||||
<property name="title" translatable="yes" context="shortcut window">Show Shortcuts</property>
|
<property name="title" translatable="yes" context="shortcut window">Show Shortcuts</property>
|
||||||
|
|||||||
@ -434,6 +434,23 @@ class RosterWindow(Adw.ApplicationWindow):
|
|||||||
if page:
|
if page:
|
||||||
self.tab_view.close_page(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):
|
def _on_new_request_clicked(self, button):
|
||||||
"""Handle New Request button click."""
|
"""Handle New Request button click."""
|
||||||
self._create_new_tab()
|
self._create_new_tab()
|
||||||
@ -458,6 +475,18 @@ class RosterWindow(Adw.ApplicationWindow):
|
|||||||
self.add_action(action)
|
self.add_action(action)
|
||||||
self.get_application().set_accels_for_action("win.save-request", ["<Control>s"])
|
self.get_application().set_accels_for_action("win.save-request", ["<Control>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", ["<Control>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", ["<Control>Return"])
|
||||||
|
|
||||||
def _on_send_clicked(self, widget):
|
def _on_send_clicked(self, widget):
|
||||||
"""Handle Send button click from a tab widget."""
|
"""Handle Send button click from a tab widget."""
|
||||||
# Clear previous preprocessing results
|
# Clear previous preprocessing results
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user