diff options
author | Andres Vieira <anvieiravazquez@gmail.com> | 2020-04-27 00:03:17 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-27 11:21:24 +0200 |
commit | 91b70d34e7ae5a489e142cd47e05cb30f679cdbf (patch) | |
tree | fa281f25e101784383cecc505d38937ca7d571d7 /Applications | |
parent | eeb5318c25ac8bce5c1d1a14847768715cb68e79 (diff) | |
download | serenity-91b70d34e7ae5a489e142cd47e05cb30f679cdbf.zip |
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.
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/FileManager/main.cpp | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index fc40e2ffb5..55f2282f90 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -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 { + auto do_delete = [&](ConfirmBeforeDelete confirm, const GUI::Action&) { + Vector<String> paths = selected_file_paths(); + + if (!paths.size()) 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()); - } + ASSERT_NOT_REACHED(); - 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; - } + 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) { |