|
@@ -29,6 +29,7 @@
|
|
#include "PropertiesDialog.h"
|
|
#include "PropertiesDialog.h"
|
|
#include <AK/FileSystemPath.h>
|
|
#include <AK/FileSystemPath.h>
|
|
#include <AK/StringBuilder.h>
|
|
#include <AK/StringBuilder.h>
|
|
|
|
+#include <AK/URL.h>
|
|
#include <LibCore/ConfigFile.h>
|
|
#include <LibCore/ConfigFile.h>
|
|
#include <LibCore/UserInfo.h>
|
|
#include <LibCore/UserInfo.h>
|
|
#include <LibGUI/AboutDialog.h>
|
|
#include <LibGUI/AboutDialog.h>
|
|
@@ -571,6 +572,40 @@ int main(int argc, char** argv)
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ directory_view->on_drop = [&](const GUI::AbstractView&, const GUI::ModelIndex& index, const GUI::DropEvent& event) {
|
|
|
|
+ if (!index.is_valid())
|
|
|
|
+ return;
|
|
|
|
+ if (event.data_type() != "url-list")
|
|
|
|
+ return;
|
|
|
|
+ auto paths_to_copy = event.data().split('\n');
|
|
|
|
+ if (paths_to_copy.is_empty()) {
|
|
|
|
+ dbg() << "No files to drop";
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ auto& target_node = directory_view->model().node(index);
|
|
|
|
+ if (!target_node.is_directory())
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ for (auto& path_to_copy : paths_to_copy) {
|
|
|
|
+ auto url_to_copy = URL(path_to_copy);
|
|
|
|
+ if (!url_to_copy.is_valid())
|
|
|
|
+ continue;
|
|
|
|
+ auto new_path = String::format("%s/%s",
|
|
|
|
+ target_node.full_path(directory_view->model()).characters(),
|
|
|
|
+ FileSystemPath(url_to_copy.path()).basename().characters());
|
|
|
|
+
|
|
|
|
+ if (!FileUtils::copy_file_or_directory(url_to_copy.path(), new_path)) {
|
|
|
|
+ auto error_message = String::format("Could not copy %s into %s.",
|
|
|
|
+ path_to_copy.characters(),
|
|
|
|
+ new_path.characters());
|
|
|
|
+ GUI::MessageBox::show(error_message, "File Manager", GUI::MessageBox::Type::Error);
|
|
|
|
+ } else {
|
|
|
|
+ refresh_tree_view();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
tree_view->on_selection_change = [&] {
|
|
tree_view->on_selection_change = [&] {
|
|
auto path = directories_model->full_path(tree_view->selection().first());
|
|
auto path = directories_model->full_path(tree_view->selection().first());
|
|
if (directory_view->path() == path)
|
|
if (directory_view->path() == path)
|