Open downloads from command bar

This commit is contained in:
2026-05-07 20:54:57 -04:00
parent 3ba9db7819
commit 9c5f93bcb8
6 changed files with 64 additions and 5 deletions
+5
View File
@@ -12,6 +12,7 @@ actions!(
[
CloseCurrentTab,
FocusAddressBar,
OpenDownloads,
OpenNewTab,
Quit,
RestoreClosedTab,
@@ -29,6 +30,8 @@ fn main() {
cx.bind_keys([
KeyBinding::new("cmd-t", OpenNewTab, None),
KeyBinding::new("ctrl-t", OpenNewTab, None),
KeyBinding::new("cmd-shift-j", OpenDownloads, None),
KeyBinding::new("ctrl-shift-j", OpenDownloads, None),
KeyBinding::new("cmd-l", FocusAddressBar, None),
KeyBinding::new("ctrl-l", FocusAddressBar, None),
KeyBinding::new("cmd-w", CloseCurrentTab, None),
@@ -63,6 +66,8 @@ fn main() {
MenuItem::separator(),
MenuItem::action("Restore Closed Tab", RestoreClosedTab),
MenuItem::separator(),
MenuItem::action("Open Downloads", OpenDownloads),
MenuItem::separator(),
MenuItem::action("Toggle Pin", TogglePinnedTab),
],
},
+21 -1
View File
@@ -6,7 +6,7 @@ use gpui::{App, AppContext, Context, Entity, FocusHandle, Focusable, Subscriptio
use gpui_component::input::{InputEvent, InputState, SelectAll};
use crate::{
CloseCurrentTab, FocusAddressBar, OpenNewTab, RestoreClosedTab, SelectNextTab,
CloseCurrentTab, FocusAddressBar, OpenDownloads, OpenNewTab, RestoreClosedTab, SelectNextTab,
SelectPreviousTab, ToggleFavoriteTab, TogglePinnedTab,
};
@@ -90,6 +90,17 @@ impl ElyShell {
}
}
fn open_downloads(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if let ShellState::Ready(core) = &mut self.state
&& let Ok(url) = UrlText::parse("ely://downloads")
{
core.open_tab(url);
self.sync_address_input(window, cx);
self.focus_address_bar(window, cx);
cx.notify();
}
}
fn focus_address_bar(&mut self, window: &mut Window, cx: &mut Context<Self>) {
self.command_input.update(cx, |input, cx| {
input.focus(window, cx);
@@ -203,6 +214,15 @@ impl ElyShell {
self.open_new_tab(window, cx);
}
fn on_open_downloads(
&mut self,
_: &OpenDownloads,
window: &mut Window,
cx: &mut Context<Self>,
) {
self.open_downloads(window, cx);
}
fn on_restore_closed_tab(
&mut self,
_: &RestoreClosedTab,
+1
View File
@@ -37,6 +37,7 @@ impl ElyShell {
.track_focus(&self.focus_handle)
.on_action(cx.listener(Self::on_close_current_tab))
.on_action(cx.listener(Self::on_focus_address_bar))
.on_action(cx.listener(Self::on_open_downloads))
.on_action(cx.listener(Self::on_open_new_tab))
.on_action(cx.listener(Self::on_restore_closed_tab))
.on_action(cx.listener(Self::on_select_next_tab))