feat: dnd to trash

This commit is contained in:
Ashley Wulber 2024-04-10 13:56:43 -04:00 committed by Jeremy Soller
parent 50ca5316f9
commit 11a2d0deef
3 changed files with 25 additions and 7 deletions

View file

@ -1366,6 +1366,9 @@ impl Application for App {
}, },
)); ));
} }
tab::Command::MoveToTrash(paths) => {
self.operation(Operation::Delete { paths });
}
} }
} }
return Command::batch(commands); return Command::batch(commands);
@ -1436,9 +1439,13 @@ impl Application for App {
paths: data.paths, paths: data.paths,
}, },
)), )),
Location::Trash => { Location::Trash if matches!(action, DndAction::Move) => {
// TODO move to trash if action is cut self.operation(Operation::Delete { paths: data.paths });
return Command::none(); Command::none()
}
_ => {
log::warn!("Copy to trash is not supported.");
Command::none()
} }
}; };
return ret; return ret;
@ -1485,9 +1492,13 @@ impl Application for App {
paths: data.paths, paths: data.paths,
}, },
)), )),
Location::Trash => { Location::Trash if matches!(action, DndAction::Move) => {
// TODO move to trash if action is cut self.operation(Operation::Delete { paths: data.paths });
return Command::none(); Command::none()
}
_ => {
log::warn!("Copy to trash is not supported.");
Command::none()
} }
}; };
return ret; return ret;

View file

@ -637,6 +637,9 @@ impl Application for App {
tab::Command::Timeout(_, _) => { tab::Command::Timeout(_, _) => {
log::warn!("Timeout not supported in dialog"); log::warn!("Timeout not supported in dialog");
} }
tab::Command::MoveToTrash(_) => {
log::warn!("MoveToTrash not supported in dialog");
}
} }
} }
return Command::batch(commands); return Command::batch(commands);

View file

@ -435,6 +435,7 @@ pub enum Command {
Scroll(widget::Id, AbsoluteOffset), Scroll(widget::Id, AbsoluteOffset),
DropFiles(PathBuf, ClipboardPaste), DropFiles(PathBuf, ClipboardPaste),
Timeout(Duration, Message), Timeout(Duration, Message),
MoveToTrash(Vec<PathBuf>),
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -1322,8 +1323,11 @@ impl Tab {
} }
commands.push(Command::DropFiles(to, from)) commands.push(Command::DropFiles(to, from))
} }
Location::Trash if matches!(from.kind, ClipboardKind::Cut) => {
commands.push(Command::MoveToTrash(from.paths))
}
Location::Trash => { Location::Trash => {
// TODO log::warn!("Copy to trash is not supported.");
} }
}; };
} }