mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
FileManager: Show progress dialog for pasted files
For now, this is a slight step backwards, as Cut does not remove the source files. This will be rectified next.
This commit is contained in:
parent
d8fb8b9583
commit
516764ef17
Notes:
sideshowbarker
2024-07-18 08:34:40 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/516764ef178 Pull-request: https://github.com/SerenityOS/serenity/pull/8117 Reviewed-by: https://github.com/MaxWipfli ✅
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -21,5 +22,5 @@ enum class FileOperation {
|
|||
void delete_path(String const&, GUI::Window*);
|
||||
void delete_paths(Vector<String> const&, bool should_confirm, GUI::Window*);
|
||||
|
||||
void run_file_operation([[maybe_unused]] FileOperation operation, Vector<String> const& sources, String const& destination, GUI::Window* parent_window);
|
||||
void run_file_operation(FileOperation, Vector<String> const& sources, String const& destination, GUI::Window*);
|
||||
}
|
||||
|
|
|
@ -160,12 +160,13 @@ void do_paste(String const& target_directory, GUI::Window* window)
|
|||
return;
|
||||
}
|
||||
|
||||
bool should_delete_src = false;
|
||||
if (copied_lines[0] == "#cut") { // cut operation encoded as a text/uri-list commen
|
||||
should_delete_src = true;
|
||||
FileOperation file_operation = FileOperation::Copy;
|
||||
if (copied_lines[0] == "#cut") { // cut operation encoded as a text/uri-list comment
|
||||
file_operation = FileOperation::Cut;
|
||||
copied_lines.remove(0);
|
||||
}
|
||||
|
||||
Vector<String> source_paths;
|
||||
for (auto& uri_as_string : copied_lines) {
|
||||
if (uri_as_string.is_empty())
|
||||
continue;
|
||||
|
@ -176,13 +177,14 @@ void do_paste(String const& target_directory, GUI::Window* window)
|
|||
}
|
||||
|
||||
auto new_path = String::formatted("{}/{}", target_directory, url.basename());
|
||||
if (auto result = Core::File::copy_file_or_directory(new_path, url.path()); result.is_error()) {
|
||||
auto error_message = String::formatted("Could not paste '{}': {}", url.path(), result.error().error_code);
|
||||
GUI::MessageBox::show(window, error_message, "File Manager", GUI::MessageBox::Type::Error);
|
||||
} else if (should_delete_src) {
|
||||
delete_path(url.path(), window);
|
||||
}
|
||||
if (url.path() == new_path)
|
||||
continue;
|
||||
|
||||
source_paths.append(url.path());
|
||||
}
|
||||
|
||||
if (!source_paths.is_empty())
|
||||
run_file_operation(file_operation, source_paths, target_directory, window);
|
||||
}
|
||||
|
||||
void do_create_link(Vector<String> const& selected_file_paths, GUI::Window* window)
|
||||
|
|
Loading…
Reference in a new issue