mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:08:12 +00:00
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
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) {
|
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())
|
if (!event.mime_data().has_urls())
|
||||||
return;
|
return;
|
||||||
auto urls = event.mime_data().urls();
|
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(),
|
target_node.full_path(directory_view.model()).characters(),
|
||||||
FileSystemPath(url_to_copy.path()).basename().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)) {
|
if (!FileUtils::copy_file_or_directory(url_to_copy.path(), new_path)) {
|
||||||
auto error_message = String::format("Could not copy %s into %s.",
|
auto error_message = String::format("Could not copy %s into %s.",
|
||||||
url_to_copy.to_string().characters(),
|
url_to_copy.to_string().characters(),
|
||||||
|
|
|
@ -350,9 +350,6 @@ void AbstractView::drop_event(DropEvent& event)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto index = index_at_event_position(event.position());
|
auto index = index_at_event_position(event.position());
|
||||||
if (!index.is_valid())
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (on_drop)
|
if (on_drop)
|
||||||
on_drop(index, event);
|
on_drop(index, event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue