Add context menu management of permanently deleting files and folders
The action replace move-to-trash when shift modifier is active, like on other desktop environement. Use modifiers value stored in Tab struct as needed to forward to context_menu creation. Started from work of Tim Dengel <tim.dengel.debian@gmail.com>
This commit is contained in:
parent
e220268954
commit
95aba7c74e
2 changed files with 12 additions and 3 deletions
11
src/menu.rs
11
src/menu.rs
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use cosmic::{
|
||||
app::Core,
|
||||
iced::{Alignment, Background, Border, Length},
|
||||
iced::{keyboard::Modifiers, Alignment, Background, Border, Length},
|
||||
theme,
|
||||
widget::{
|
||||
self, button, column, container, divider, horizontal_space,
|
||||
|
|
@ -55,6 +55,7 @@ fn menu_button_optional(
|
|||
pub fn context_menu<'a>(
|
||||
tab: &Tab,
|
||||
key_binds: &HashMap<KeyBind, Action>,
|
||||
modifiers: &Modifiers,
|
||||
) -> Element<'a, tab::Message> {
|
||||
let find_key = |action: &Action| -> String {
|
||||
for (key_bind, key_action) in key_binds.iter() {
|
||||
|
|
@ -216,7 +217,13 @@ pub fn context_menu<'a>(
|
|||
children.push(menu_item(fl!("add-to-sidebar"), Action::AddToSidebar).into());
|
||||
}
|
||||
children.push(divider::horizontal::light().into());
|
||||
children.push(menu_item(fl!("move-to-trash"), Action::Delete).into());
|
||||
if modifiers.shift() && !modifiers.control() {
|
||||
children.push(
|
||||
menu_item(fl!("delete-permanently"), Action::PermanentlyDelete).into(),
|
||||
);
|
||||
} else {
|
||||
children.push(menu_item(fl!("move-to-trash"), Action::Delete).into());
|
||||
}
|
||||
} else {
|
||||
//TODO: need better designs for menu with no selection
|
||||
//TODO: have things like properties but they apply to the folder?
|
||||
|
|
|
|||
|
|
@ -4855,10 +4855,12 @@ impl Tab {
|
|||
let mut popover = widget::popover(mouse_area);
|
||||
|
||||
if let Some(point) = self.context_menu {
|
||||
let context_menu = menu::context_menu(self, key_binds, &self.modifiers);
|
||||
popover = popover
|
||||
.popup(menu::context_menu(self, key_binds))
|
||||
.popup(context_menu)
|
||||
.position(widget::popover::Position::Point(point));
|
||||
}
|
||||
|
||||
let mut tab_column = widget::column::with_capacity(3);
|
||||
if let Some(location_view) = location_view_opt {
|
||||
tab_column = tab_column.push(location_view);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue