Ask for confirmation when deleting from trash
This commit is contained in:
parent
84d3659263
commit
456d4b003e
2 changed files with 36 additions and 3 deletions
|
|
@ -91,7 +91,7 @@ other-apps = Other applications
|
|||
related-apps = Related applications
|
||||
|
||||
## Permanently delete Dialog
|
||||
selected-items = the {$items} selected items
|
||||
selected-items = The {$items} selected items
|
||||
permanently-delete-question = Permanently delete?
|
||||
delete = Delete
|
||||
permanently-delete-warning = {$target} will be permanently deleted. This action can't be undone.
|
||||
|
|
|
|||
37
src/app.rs
37
src/app.rs
|
|
@ -101,6 +101,9 @@ use crate::{
|
|||
static PERMANENT_DELETE_BUTTON_ID: LazyLock<widget::Id> =
|
||||
LazyLock::new(|| widget::Id::new("permanent-delete-button"));
|
||||
|
||||
static DELETE_TRASH_BUTTON_ID: LazyLock<widget::Id> =
|
||||
LazyLock::new(|| widget::Id::new("delete-trash-button"));
|
||||
|
||||
static CONFIRM_OPEN_WITH_BUTTON_ID: LazyLock<widget::Id> =
|
||||
LazyLock::new(|| widget::Id::new("confirm-open-with-button"));
|
||||
|
||||
|
|
@ -534,6 +537,9 @@ pub enum DialogPage {
|
|||
PermanentlyDelete {
|
||||
paths: Box<[PathBuf]>,
|
||||
},
|
||||
DeleteTrash {
|
||||
items: Vec<TrashItem>,
|
||||
},
|
||||
RenameItem {
|
||||
from: PathBuf,
|
||||
parent: PathBuf,
|
||||
|
|
@ -2683,8 +2689,10 @@ impl Application for App {
|
|||
}
|
||||
}
|
||||
if !trash_items.is_empty() {
|
||||
return self
|
||||
.operation(Operation::DeleteTrash { items: trash_items });
|
||||
return self.update(Message::DialogPush(
|
||||
DialogPage::DeleteTrash { items: trash_items },
|
||||
Some(DELETE_TRASH_BUTTON_ID.clone()),
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2883,6 +2891,9 @@ impl Application for App {
|
|||
DialogPage::PermanentlyDelete { paths } => {
|
||||
tasks.push(self.operation(Operation::PermanentlyDelete { paths }));
|
||||
}
|
||||
DialogPage::DeleteTrash { items } => {
|
||||
tasks.push(self.operation(Operation::DeleteTrash { items }));
|
||||
}
|
||||
DialogPage::RenameItem {
|
||||
from, parent, name, ..
|
||||
} => {
|
||||
|
|
@ -5323,6 +5334,28 @@ impl Application for App {
|
|||
target = target
|
||||
)))
|
||||
}
|
||||
DialogPage::DeleteTrash { items } => {
|
||||
let target = if items.len() == 1 {
|
||||
format!("\"{}\"", items[0].name.to_string_lossy())
|
||||
} else {
|
||||
fl!("selected-items", items = items.len())
|
||||
};
|
||||
|
||||
widget::dialog()
|
||||
.title(fl!("permanently-delete-question"))
|
||||
.primary_action(
|
||||
widget::button::destructive(fl!("delete"))
|
||||
.on_press(Message::DialogComplete)
|
||||
.id(DELETE_TRASH_BUTTON_ID.clone()),
|
||||
)
|
||||
.secondary_action(
|
||||
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
|
||||
)
|
||||
.control(widget::text(fl!(
|
||||
"permanently-delete-warning",
|
||||
target = target
|
||||
)))
|
||||
}
|
||||
DialogPage::RenameItem {
|
||||
from,
|
||||
parent,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue