Merge branch 'permanently-delete' of https://github.com/gwen-lg/cosmic-files
This commit is contained in:
commit
4f7d13f391
9 changed files with 177 additions and 17 deletions
59
src/app.rs
59
src/app.rs
|
|
@ -33,7 +33,7 @@ use cosmic::{
|
|||
widget::{
|
||||
self,
|
||||
dnd_destination::DragId,
|
||||
horizontal_space,
|
||||
horizontal_space, icon,
|
||||
menu::{action::MenuAction, key_bind::KeyBind},
|
||||
segmented_button::{self, Entity},
|
||||
vertical_space,
|
||||
|
|
@ -138,6 +138,7 @@ pub enum Action {
|
|||
OpenTerminal,
|
||||
OpenWith,
|
||||
Paste,
|
||||
PermanentlyDelete,
|
||||
Preview,
|
||||
Rename,
|
||||
RestoreFromTrash,
|
||||
|
|
@ -205,6 +206,7 @@ impl Action {
|
|||
Action::OpenTerminal => Message::OpenTerminal(entity_opt),
|
||||
Action::OpenWith => Message::OpenWithDialog(entity_opt),
|
||||
Action::Paste => Message::Paste(entity_opt),
|
||||
Action::PermanentlyDelete => Message::PermanentlyDelete(entity_opt),
|
||||
Action::Preview => Message::Preview(entity_opt),
|
||||
Action::Rename => Message::Rename(entity_opt),
|
||||
Action::RestoreFromTrash => Message::RestoreFromTrash(entity_opt),
|
||||
|
|
@ -313,7 +315,7 @@ pub enum Message {
|
|||
Key(Modifiers, Key, Option<SmolStr>),
|
||||
LaunchUrl(String),
|
||||
MaybeExit,
|
||||
Modifiers(Modifiers),
|
||||
ModifiersChanged(Modifiers),
|
||||
MounterItems(MounterKey, MounterItems),
|
||||
MountResult(MounterKey, MounterItem, Result<bool, String>),
|
||||
NavBarClose(Entity),
|
||||
|
|
@ -346,6 +348,7 @@ pub enum Message {
|
|||
PendingError(u64, OperationError),
|
||||
PendingPause(u64, bool),
|
||||
PendingPauseAll(bool),
|
||||
PermanentlyDelete(Option<Entity>),
|
||||
Preview(Option<Entity>),
|
||||
RescanTrash,
|
||||
Rename(Option<Entity>),
|
||||
|
|
@ -481,6 +484,9 @@ pub enum DialogPage {
|
|||
selected: usize,
|
||||
store_opt: Option<MimeApp>,
|
||||
},
|
||||
PermanentlyDelete {
|
||||
paths: Vec<PathBuf>,
|
||||
},
|
||||
RenameItem {
|
||||
from: PathBuf,
|
||||
parent: PathBuf,
|
||||
|
|
@ -2463,6 +2469,9 @@ impl Application for App {
|
|||
}
|
||||
}
|
||||
}
|
||||
DialogPage::PermanentlyDelete { paths } => {
|
||||
return self.operation(Operation::PermanentlyDelete { paths });
|
||||
}
|
||||
DialogPage::RenameItem {
|
||||
from, parent, name, ..
|
||||
} => {
|
||||
|
|
@ -2620,8 +2629,13 @@ impl Application for App {
|
|||
log::warn!("failed to open {:?}: {}", url, err);
|
||||
}
|
||||
},
|
||||
Message::Modifiers(modifiers) => {
|
||||
Message::ModifiersChanged(modifiers) => {
|
||||
self.modifiers = modifiers;
|
||||
let entity = self.tab_model.active();
|
||||
return self.update(Message::TabMessage(
|
||||
Some(entity),
|
||||
tab::Message::ModifiersChanged(modifiers),
|
||||
));
|
||||
}
|
||||
Message::MounterItems(mounter_key, mounter_items) => {
|
||||
// Check for unmounted folders
|
||||
|
|
@ -3143,6 +3157,13 @@ impl Application for App {
|
|||
}
|
||||
}
|
||||
}
|
||||
Message::PermanentlyDelete(entity_opt) => {
|
||||
let paths = self.selected_paths(entity_opt);
|
||||
if !paths.is_empty() {
|
||||
self.dialog_pages
|
||||
.push_back(DialogPage::PermanentlyDelete { paths });
|
||||
}
|
||||
}
|
||||
Message::Preview(entity_opt) => {
|
||||
match self.mode {
|
||||
Mode::App => {
|
||||
|
|
@ -4661,6 +4682,35 @@ impl Application for App {
|
|||
|
||||
dialog
|
||||
}
|
||||
DialogPage::PermanentlyDelete { paths } => {
|
||||
let target = if paths.len() == 1 {
|
||||
format!(
|
||||
"« {} »",
|
||||
paths[0]
|
||||
.file_name()
|
||||
.map(std::ffi::OsStr::to_string_lossy)
|
||||
.unwrap_or_else(|| paths[0].to_string_lossy())
|
||||
)
|
||||
} else {
|
||||
fl!("selected-items", items = paths.len())
|
||||
};
|
||||
|
||||
widget::dialog()
|
||||
.title(fl!("permanently-delete-question"))
|
||||
.icon(icon::from_name("dialog-warning").size(32))
|
||||
.primary_action(
|
||||
widget::button::destructive(fl!("delete"))
|
||||
.on_press(Message::DialogComplete),
|
||||
)
|
||||
.secondary_action(
|
||||
widget::button::standard(fl!("cancel")).on_press(Message::DialogCancel),
|
||||
)
|
||||
.control(widget::text(fl!(
|
||||
"permanently-delete-warning",
|
||||
nb_items = paths.len(),
|
||||
target = target
|
||||
)))
|
||||
}
|
||||
DialogPage::RenameItem {
|
||||
from,
|
||||
parent,
|
||||
|
|
@ -4957,6 +5007,7 @@ impl Application for App {
|
|||
&self.core,
|
||||
self.tab_model.active_data::<Tab>(),
|
||||
&self.config,
|
||||
&self.modifiers,
|
||||
&self.key_binds,
|
||||
)]
|
||||
}
|
||||
|
|
@ -5148,7 +5199,7 @@ impl Application for App {
|
|||
event::Status::Captured => None,
|
||||
},
|
||||
Event::Keyboard(KeyEvent::ModifiersChanged(modifiers)) => {
|
||||
Some(Message::Modifiers(modifiers))
|
||||
Some(Message::ModifiersChanged(modifiers))
|
||||
}
|
||||
Event::Window(WindowEvent::Unfocused) => Some(Message::WindowUnfocus),
|
||||
#[cfg(all(feature = "desktop", feature = "wayland"))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue