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:
parent
27091d05ee
commit
e0a16f8752
Notes:
sideshowbarker
2024-07-19 17:35:45 +09:00
Author: https://github.com/anpep Commit: https://github.com/SerenityOS/serenity/commit/e0a16f8752a Pull-request: https://github.com/SerenityOS/serenity/pull/1886
2 changed files with 3 additions and 5 deletions
|
@ -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(),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue