Allow duplicating files when holding Control
This commit is contained in:
parent
c0ff2a388d
commit
b426d11d86
|
@ -2085,8 +2085,33 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
|
|||
}
|
||||
}
|
||||
if (!to_move.empty()) {
|
||||
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.
|
||||
Vector<String> fnames = drag_data["files"];
|
||||
|
|
Loading…
Reference in New Issue