mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
FileManager: Copy and Delete selected file(s), not current folder
FileManager had this weird behaviour in which it would ignore the current selection and try to copy and delete the current folder.
This commit is contained in:
parent
eeb5318c25
commit
91b70d34e7
Notes:
sideshowbarker
2024-07-19 07:15:21 +09:00
Author: https://github.com/zlotny Commit: https://github.com/SerenityOS/serenity/commit/91b70d34e7a Pull-request: https://github.com/SerenityOS/serenity/pull/1980
1 changed files with 31 additions and 33 deletions
|
@ -406,15 +406,15 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
|||
});
|
||||
|
||||
auto copy_action = GUI::CommonActions::make_copy_action(
|
||||
[&](const GUI::Action& action) {
|
||||
Vector<String> paths;
|
||||
if (action.activator() == directory_context_menu || directory_view.active_widget()->is_focused()) {
|
||||
paths = selected_file_paths();
|
||||
} else {
|
||||
[&](const GUI::Action&) {
|
||||
Vector<String> paths = selected_file_paths();
|
||||
|
||||
if (!paths.size())
|
||||
paths = tree_view_selected_file_paths();
|
||||
}
|
||||
|
||||
if (paths.is_empty())
|
||||
return;
|
||||
ASSERT_NOT_REACHED();
|
||||
|
||||
StringBuilder copy_text;
|
||||
for (auto& path : paths) {
|
||||
copy_text.appendf("%s\n", path.characters());
|
||||
|
@ -489,33 +489,31 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
|||
Yes
|
||||
};
|
||||
|
||||
auto do_delete = [&](ConfirmBeforeDelete confirm, const GUI::Action& action) {
|
||||
Vector<String> paths;
|
||||
if (action.activator() == directory_context_menu || directory_view.active_widget()->is_focused()) {
|
||||
paths = selected_file_paths();
|
||||
} else {
|
||||
paths = tree_view_selected_file_paths();
|
||||
}
|
||||
if (paths.is_empty())
|
||||
return;
|
||||
{
|
||||
String message;
|
||||
if (paths.size() == 1) {
|
||||
message = String::format("Really delete %s?", FileSystemPath(paths[0]).basename().characters());
|
||||
} else {
|
||||
message = String::format("Really delete %d files?", paths.size());
|
||||
}
|
||||
auto do_delete = [&](ConfirmBeforeDelete confirm, const GUI::Action&) {
|
||||
Vector<String> paths = selected_file_paths();
|
||||
|
||||
if (confirm == ConfirmBeforeDelete::Yes) {
|
||||
auto result = GUI::MessageBox::show(
|
||||
message,
|
||||
"Confirm deletion",
|
||||
GUI::MessageBox::Type::Warning,
|
||||
GUI::MessageBox::InputType::OKCancel,
|
||||
window);
|
||||
if (result == GUI::MessageBox::ExecCancel)
|
||||
return;
|
||||
}
|
||||
if (!paths.size())
|
||||
paths = tree_view_selected_file_paths();
|
||||
|
||||
if (paths.is_empty())
|
||||
ASSERT_NOT_REACHED();
|
||||
|
||||
String message;
|
||||
if (paths.size() == 1) {
|
||||
message = String::format("Really delete %s?", FileSystemPath(paths[0]).basename().characters());
|
||||
} else {
|
||||
message = String::format("Really delete %d files?", paths.size());
|
||||
}
|
||||
|
||||
if (confirm == ConfirmBeforeDelete::Yes) {
|
||||
auto result = GUI::MessageBox::show(
|
||||
message,
|
||||
"Confirm deletion",
|
||||
GUI::MessageBox::Type::Warning,
|
||||
GUI::MessageBox::InputType::OKCancel,
|
||||
window);
|
||||
if (result == GUI::MessageBox::ExecCancel)
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& path : paths) {
|
||||
|
|
Loading…
Reference in a new issue