summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-06-16 12:54:06 +0200
committerGitHub <noreply@github.com>2020-06-16 12:54:06 +0200
commitb29a3e7e23ad915f349855170fb4470f9198b05e (patch)
tree2d07e2395614b6d6e8f64431d33752b229b4a7d3
parent9d23391072e4bb312b47df65225b8888ecabd523 (diff)
parentb426d11d8617daa79ccc5fa8c644abb8c8dfecd0 (diff)
Merge pull request #39307 from KoBeWi/move_n_dup
Allow duplicating files when holding Control
-rw-r--r--editor/filesystem_dock.cpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 4fdc3dc080..f279f402d9 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -2085,7 +2085,32 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
}
if (!to_move.empty()) {
- _move_operation_confirm(to_dir);
+ if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) {
+ for (int i = 0; i < to_move.size(); i++) {
+ String new_path;
+ String new_path_base;
+
+ if (to_move[i].is_file) {
+ new_path = to_dir.plus_file(to_move[i].path.get_file());
+ new_path_base = new_path.get_basename() + " (%d)." + new_path.get_extension();
+ } else {
+ PackedStringArray path_split = to_move[i].path.split("/");
+ new_path = to_dir.plus_file(path_split[path_split.size() - 2]);
+ new_path_base = new_path + " (%d)";
+ }
+
+ int exist_counter = 1;
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_RESOURCES);
+ while (da->file_exists(new_path) || da->dir_exists(new_path)) {
+ exist_counter++;
+ new_path = vformat(new_path_base, exist_counter);
+ }
+ _try_duplicate_item(to_move[i], new_path);
+ }
+ _rescan();
+ } else {
+ _move_operation_confirm(to_dir);
+ }
}
} else if (favorite) {
// Add the files from favorites.