Allow toggling collaboration menu from the keyboard
This commit is contained in:
parent
3bb1f0097f
commit
89f05ada0b
5 changed files with 32 additions and 10 deletions
|
@ -376,6 +376,7 @@
|
||||||
{
|
{
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"ctrl-alt-cmd-f": "workspace::FollowNextCollaborator",
|
"ctrl-alt-cmd-f": "workspace::FollowNextCollaborator",
|
||||||
|
"cmd-shift-c": "collab::ToggleCollaborationMenu",
|
||||||
"cmd-alt-i": "zed::DebugElements"
|
"cmd-alt-i": "zed::DebugElements"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,10 +17,7 @@ use std::ops::Range;
|
||||||
use theme::Theme;
|
use theme::Theme;
|
||||||
use workspace::{FollowNextCollaborator, JoinProject, ToggleFollow, Workspace};
|
use workspace::{FollowNextCollaborator, JoinProject, ToggleFollow, Workspace};
|
||||||
|
|
||||||
actions!(
|
actions!(collab, [ToggleCollaborationMenu, ShareProject]);
|
||||||
contacts_titlebar_item,
|
|
||||||
[ToggleContactsPopover, ShareProject]
|
|
||||||
);
|
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut MutableAppContext) {
|
||||||
cx.add_action(CollabTitlebarItem::toggle_contacts_popover);
|
cx.add_action(CollabTitlebarItem::toggle_contacts_popover);
|
||||||
|
@ -143,7 +140,11 @@ impl CollabTitlebarItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_contacts_popover(&mut self, _: &ToggleContactsPopover, cx: &mut ViewContext<Self>) {
|
pub fn toggle_contacts_popover(
|
||||||
|
&mut self,
|
||||||
|
_: &ToggleCollaborationMenu,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) {
|
||||||
match self.contacts_popover.take() {
|
match self.contacts_popover.take() {
|
||||||
Some(_) => {}
|
Some(_) => {}
|
||||||
None => {
|
None => {
|
||||||
|
@ -197,7 +198,7 @@ impl CollabTitlebarItem {
|
||||||
};
|
};
|
||||||
Stack::new()
|
Stack::new()
|
||||||
.with_child(
|
.with_child(
|
||||||
MouseEventHandler::<ToggleContactsPopover>::new(0, cx, |state, _| {
|
MouseEventHandler::<ToggleCollaborationMenu>::new(0, cx, |state, _| {
|
||||||
let style = titlebar
|
let style = titlebar
|
||||||
.toggle_contacts_button
|
.toggle_contacts_button
|
||||||
.style_for(state, self.contacts_popover.is_some());
|
.style_for(state, self.contacts_popover.is_some());
|
||||||
|
@ -214,8 +215,8 @@ impl CollabTitlebarItem {
|
||||||
.boxed()
|
.boxed()
|
||||||
})
|
})
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
.on_click(MouseButton::Left, |_, cx| {
|
.on_click(MouseButton::Left, move |_, cx| {
|
||||||
cx.dispatch_action(ToggleContactsPopover);
|
cx.dispatch_action(ToggleCollaborationMenu);
|
||||||
})
|
})
|
||||||
.aligned()
|
.aligned()
|
||||||
.boxed(),
|
.boxed(),
|
||||||
|
|
|
@ -8,7 +8,7 @@ mod notifications;
|
||||||
mod project_shared_notification;
|
mod project_shared_notification;
|
||||||
|
|
||||||
use call::ActiveCall;
|
use call::ActiveCall;
|
||||||
pub use collab_titlebar_item::CollabTitlebarItem;
|
pub use collab_titlebar_item::{CollabTitlebarItem, ToggleCollaborationMenu};
|
||||||
use gpui::MutableAppContext;
|
use gpui::MutableAppContext;
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
|
@ -1173,6 +1173,10 @@ impl Workspace {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn titlebar_item(&self) -> Option<AnyViewHandle> {
|
||||||
|
self.titlebar_item.clone()
|
||||||
|
}
|
||||||
|
|
||||||
/// Call the given callback with a workspace whose project is local.
|
/// Call the given callback with a workspace whose project is local.
|
||||||
///
|
///
|
||||||
/// If the given workspace has a local project, then it will be passed
|
/// If the given workspace has a local project, then it will be passed
|
||||||
|
|
|
@ -9,7 +9,7 @@ use anyhow::{anyhow, Context, Result};
|
||||||
use assets::Assets;
|
use assets::Assets;
|
||||||
use breadcrumbs::Breadcrumbs;
|
use breadcrumbs::Breadcrumbs;
|
||||||
pub use client;
|
pub use client;
|
||||||
use collab_ui::CollabTitlebarItem;
|
use collab_ui::{CollabTitlebarItem, ToggleCollaborationMenu};
|
||||||
use collections::VecDeque;
|
use collections::VecDeque;
|
||||||
pub use editor;
|
pub use editor;
|
||||||
use editor::{Editor, MultiBuffer};
|
use editor::{Editor, MultiBuffer};
|
||||||
|
@ -94,6 +94,22 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
||||||
cx.toggle_full_screen();
|
cx.toggle_full_screen();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
cx.add_action(
|
||||||
|
|workspace: &mut Workspace,
|
||||||
|
_: &ToggleCollaborationMenu,
|
||||||
|
cx: &mut ViewContext<Workspace>| {
|
||||||
|
if let Some(item) = workspace
|
||||||
|
.titlebar_item()
|
||||||
|
.and_then(|item| item.downcast::<CollabTitlebarItem>())
|
||||||
|
{
|
||||||
|
cx.as_mut().defer(move |cx| {
|
||||||
|
item.update(cx, |item, cx| {
|
||||||
|
item.toggle_contacts_popover(&Default::default(), cx);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
cx.add_global_action(quit);
|
cx.add_global_action(quit);
|
||||||
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
|
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
|
||||||
cx.add_global_action(move |_: &IncreaseBufferFontSize, cx| {
|
cx.add_global_action(move |_: &IncreaseBufferFontSize, cx| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue