Add ability to open files with system default application (#17231)
This commit is contained in:
parent
06142f975b
commit
ae3880e71a
10 changed files with 63 additions and 1 deletions
|
@ -146,6 +146,7 @@ actions!(
|
|||
CopyRelativePath,
|
||||
Duplicate,
|
||||
RevealInFileManager,
|
||||
OpenWithSystem,
|
||||
Cut,
|
||||
Paste,
|
||||
Rename,
|
||||
|
@ -500,6 +501,7 @@ impl ProjectPanel {
|
|||
.when(cfg!(not(target_os = "macos")), |menu| {
|
||||
menu.action("Reveal in File Manager", Box::new(RevealInFileManager))
|
||||
})
|
||||
.action("Open in Default App", Box::new(OpenWithSystem))
|
||||
.action("Open in Terminal", Box::new(OpenInTerminal))
|
||||
.when(is_dir, |menu| {
|
||||
menu.separator()
|
||||
|
@ -1497,6 +1499,13 @@ impl ProjectPanel {
|
|||
}
|
||||
}
|
||||
|
||||
fn open_system(&mut self, _: &OpenWithSystem, cx: &mut ViewContext<Self>) {
|
||||
if let Some((worktree, entry)) = self.selected_entry(cx) {
|
||||
let abs_path = worktree.abs_path().join(&entry.path);
|
||||
cx.open_with_system(&abs_path);
|
||||
}
|
||||
}
|
||||
|
||||
fn open_in_terminal(&mut self, _: &OpenInTerminal, cx: &mut ViewContext<Self>) {
|
||||
if let Some((worktree, entry)) = self.selected_sub_entry(cx) {
|
||||
let abs_path = worktree.abs_path().join(&entry.path);
|
||||
|
@ -2711,6 +2720,7 @@ impl Render for ProjectPanel {
|
|||
})
|
||||
.when(project.is_local_or_ssh(), |el| {
|
||||
el.on_action(cx.listener(Self::reveal_in_finder))
|
||||
.on_action(cx.listener(Self::open_system))
|
||||
.on_action(cx.listener(Self::open_in_terminal))
|
||||
})
|
||||
.on_mouse_down(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue