FileManager+LibGUI: Allow drop on entire DirectoryView

Previously, drag and drop would only work when dragging between node
items on a DirectoryView. This commit makes it possible to drag files to
the empty area of the DirectoryView and copy files more easily between
windows.
This commit is contained in:
angel 2020-04-19 18:36:00 +02:00 committed by Andreas Kling
parent 27091d05ee
commit e0a16f8752
Notes: sideshowbarker 2024-07-19 17:35:45 +09:00
2 changed files with 3 additions and 5 deletions

View file

@ -669,8 +669,6 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
};
directory_view.on_drop = [&](const GUI::AbstractView&, const GUI::ModelIndex& index, const GUI::DropEvent& event) {
if (!index.is_valid())
return;
if (!event.mime_data().has_urls())
return;
auto urls = event.mime_data().urls();
@ -690,6 +688,9 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
target_node.full_path(directory_view.model()).characters(),
FileSystemPath(url_to_copy.path()).basename().characters());
if (url_to_copy.path() == new_path)
continue;
if (!FileUtils::copy_file_or_directory(url_to_copy.path(), new_path)) {
auto error_message = String::format("Could not copy %s into %s.",
url_to_copy.to_string().characters(),

View file

@ -350,9 +350,6 @@ void AbstractView::drop_event(DropEvent& event)
return;
auto index = index_at_event_position(event.position());
if (!index.is_valid())
return;
if (on_drop)
on_drop(index, event);
}