Compare commits

..

2 commits

Author SHA1 Message Date
9e0c2726ef feat: add empty-trash action to trash view context menu
Right-clicking inside the trash view now shows 'Empty trash' when
the trash is not empty, in addition to the existing per-item
restore/delete actions and sort options.
2026-07-25 22:54:15 +02:00
30e562c8c2 fix: nav_context_menu must produce one submenu per nav item
The segmented_button widget asserts that context_menu children
count matches model length. The yoda fork was building a single
flat menu for the clicked item instead of iterating over all
nav_model items like upstream, causing an assertion panic on
right-click in the sidebar (trash, folders, etc.).

Align with upstream: iterate self.nav_model.iter() and use
menu::nav_context() instead of menu::items().
2026-07-25 22:53:11 +02:00
2 changed files with 93 additions and 82 deletions

View file

@ -2833,7 +2833,7 @@ impl Application for App {
fn nav_context_menu( fn nav_context_menu(
&self, &self,
) -> Option<Vec<widget::menu::Tree<cosmic::Action<Self::Message>>>> { ) -> Option<Vec<widget::menu::Tree<cosmic::Action<Self::Message>>>> {
let entity = self.nav_bar_context_id; let items = self.nav_model.iter().map(|entity| {
let favorite_index_opt = self.nav_model.data::<FavoriteIndex>(entity); let favorite_index_opt = self.nav_model.data::<FavoriteIndex>(entity);
let location_opt = self.nav_model.data::<Location>(entity); let location_opt = self.nav_model.data::<Location>(entity);
@ -2919,8 +2919,13 @@ impl Application for App {
NavMenuAction::EmptyTrash, NavMenuAction::EmptyTrash,
)); ));
} }
items
});
Some(cosmic::widget::menu::items(&HashMap::new(), items)) Some(cosmic::widget::menu::nav_context(
&HashMap::new(),
items.collect(),
))
} }
fn nav_model(&self) -> Option<&segmented_button::SingleSelectModel> { fn nav_model(&self) -> Option<&segmented_button::SingleSelectModel> {

View file

@ -418,6 +418,12 @@ pub fn context_menu<'a>(
if tab.mode.multiple() { if tab.mode.multiple() {
children.push(menu_item(fl!("select-all"), Action::SelectAll).into()); children.push(menu_item(fl!("select-all"), Action::SelectAll).into());
} }
if !Trash::is_empty() {
if !children.is_empty() {
children.push(divider::horizontal::light().into());
}
children.push(menu_item(fl!("empty-trash"), Action::EmptyTrash).into());
}
if !children.is_empty() { if !children.is_empty() {
children.push(divider::horizontal::light().into()); children.push(divider::horizontal::light().into());
} }