Add properties to bread crumbs context menu

This commit is contained in:
Jason Rodney Hansen 2024-06-30 13:33:44 -06:00 committed by Jeremy Soller
parent 26423beaac
commit 419a4dcdc7
4 changed files with 46 additions and 0 deletions

View file

@ -177,6 +177,7 @@ impl MenuAction for Action {
pub enum ContextItem {
NavBar(segmented_button::Entity),
TabBar(segmented_button::Entity),
BreadCrumbs(usize),
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
@ -695,6 +696,31 @@ impl App {
widget::settings::view_column(children).into()
}
Some(ContextItem::BreadCrumbs(index)) => {
let mut children = Vec::new();
if let Some(tab) = self.tab_model.active_data::<Tab>() {
let path = match tab.location {
Location::Path(ref path) => Some(path),
Location::Search(ref path, _) => Some(path),
_ => None,
}
.and_then(|path| path.ancestors().nth(index))
.map(|path| path.to_path_buf());
if let Some(ref path) = path {
let parent = path.parent().unwrap_or(path);
for item in Location::Path(parent.to_owned()).scan(IconSizes::default()) {
if item.path_opt.as_deref() == Some(path) {
children.push(item.property_view(IconSizes::default()));
}
}
};
}
widget::settings::view_column(children).into()
}
}
}
@ -1751,6 +1777,12 @@ impl Application for App {
log::error!("failed to get current executable path: {}", err);
}
},
tab::Command::LocationProperties(index) => {
self.context_page =
ContextPage::Properties(Some(ContextItem::BreadCrumbs(index)));
self.core.window.show_context = true;
self.set_context_title(self.context_page.title());
}
tab::Command::Scroll(id, offset) => {
commands.push(scrollable::scroll_to(id, offset));
}