diff options
Diffstat (limited to 'editor/filesystem_dock.cpp')
-rw-r--r-- | editor/filesystem_dock.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index c65c796e5e..6c8bd1901e 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1505,7 +1505,8 @@ void FileSystemDock::_move_with_overwrite() { _move_operation_confirm(to_move_path, true); } -bool FileSystemDock::_check_existing() { +Vector<String> FileSystemDock::_check_existing() { + Vector<String> conflicting_items; String &p_to_path = to_move_path; for (int i = 0; i < to_move.size(); i++) { String ol_pth = to_move[i].path.ends_with("/") ? to_move[i].path.substr(0, to_move[i].path.length() - 1) : to_move[i].path; @@ -1515,21 +1516,24 @@ bool FileSystemDock::_check_existing() { String old_path = (p_item.is_file || p_item.path.ends_with("/")) ? p_item.path : (p_item.path + "/"); String new_path = (p_item.is_file || p_new_path.ends_with("/")) ? p_new_path : (p_new_path + "/"); - if (p_item.is_file && FileAccess::exists(new_path)) { - return false; - } else if (!p_item.is_file && DirAccess::exists(new_path)) { - return false; + if ((p_item.is_file && FileAccess::exists(new_path)) || + (!p_item.is_file && DirAccess::exists(new_path))) { + conflicting_items.push_back(old_path); } } - return true; + return conflicting_items; } void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_overwrite) { if (!p_overwrite) { to_move_path = p_to_path; - bool can_move = _check_existing(); - if (!can_move) { + Vector<String> conflicting_items = _check_existing(); + if (!conflicting_items.empty()) { // Ask to do something. + overwrite_dialog->set_text(vformat( + TTR("The following files or folders conflict with items in the target location '%s':\n\n%s\n\nDo you wish to overwrite them?"), + to_move_path, + String("\n").join(conflicting_items))); overwrite_dialog->popup_centered(); return; } @@ -2368,16 +2372,16 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str } if (p_paths.size() == 1) { - p_popup->add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), TTR("Copy Path"), FILE_COPY_PATH); + p_popup->add_icon_shortcut(get_theme_icon("ActionCopy", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH); if (p_paths[0] != "res://") { - p_popup->add_icon_item(get_theme_icon("Rename", "EditorIcons"), TTR("Rename..."), FILE_RENAME); - p_popup->add_icon_item(get_theme_icon("Duplicate", "EditorIcons"), TTR("Duplicate..."), FILE_DUPLICATE); + p_popup->add_icon_shortcut(get_theme_icon("Rename", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/rename"), FILE_RENAME); + p_popup->add_icon_shortcut(get_theme_icon("Duplicate", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/duplicate"), FILE_DUPLICATE); } } if (p_paths.size() > 1 || p_paths[0] != "res://") { p_popup->add_icon_item(get_theme_icon("MoveUp", "EditorIcons"), TTR("Move To..."), FILE_MOVE); - p_popup->add_icon_item(get_theme_icon("Remove", "EditorIcons"), TTR("Move to Trash"), FILE_REMOVE); + p_popup->add_icon_shortcut(get_theme_icon("Remove", "EditorIcons"), ED_GET_SHORTCUT("filesystem_dock/delete"), FILE_REMOVE); } if (p_paths.size() == 1) { @@ -2511,7 +2515,11 @@ void FileSystemDock::_tree_gui_input(Ref<InputEvent> p_event) { _tree_rmb_option(FILE_REMOVE); } else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) { _tree_rmb_option(FILE_RENAME); + } else { + return; } + + accept_event(); } } @@ -2526,7 +2534,11 @@ void FileSystemDock::_file_list_gui_input(Ref<InputEvent> p_event) { _file_list_rmb_option(FILE_REMOVE); } else if (ED_IS_SHORTCUT("filesystem_dock/rename", p_event)) { _file_list_rmb_option(FILE_RENAME); + } else { + return; } + + accept_event(); } } @@ -2682,8 +2694,8 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { // `KEY_MASK_CMD | KEY_C` conflicts with other editor shortcuts. ED_SHORTCUT("filesystem_dock/copy_path", TTR("Copy Path"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_C); ED_SHORTCUT("filesystem_dock/duplicate", TTR("Duplicate..."), KEY_MASK_CMD | KEY_D); - ED_SHORTCUT("filesystem_dock/delete", TTR("Delete"), KEY_DELETE); - ED_SHORTCUT("filesystem_dock/rename", TTR("Rename")); + ED_SHORTCUT("filesystem_dock/delete", TTR("Move to Trash"), KEY_DELETE); + ED_SHORTCUT("filesystem_dock/rename", TTR("Rename..."), KEY_F2); VBoxContainer *top_vbc = memnew(VBoxContainer); add_child(top_vbc); @@ -2825,7 +2837,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { add_child(remove_dialog); move_dialog = memnew(EditorDirDialog); - move_dialog->get_ok()->set_text(TTR("Move")); + move_dialog->get_ok_button()->set_text(TTR("Move")); add_child(move_dialog); move_dialog->connect("dir_selected", callable_mp(this, &FileSystemDock::_move_operation_confirm), make_binds(false)); @@ -2835,14 +2847,13 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { rename_dialog_text = memnew(LineEdit); rename_dialog_vb->add_margin_child(TTR("Name:"), rename_dialog_text); - rename_dialog->get_ok()->set_text(TTR("Rename")); + rename_dialog->get_ok_button()->set_text(TTR("Rename")); add_child(rename_dialog); rename_dialog->register_text_enter(rename_dialog_text); rename_dialog->connect("confirmed", callable_mp(this, &FileSystemDock::_rename_operation_confirm)); overwrite_dialog = memnew(ConfirmationDialog); - overwrite_dialog->set_text(TTR("There is already file or folder with the same name in this location.")); - overwrite_dialog->get_ok()->set_text(TTR("Overwrite")); + overwrite_dialog->get_ok_button()->set_text(TTR("Overwrite")); add_child(overwrite_dialog); overwrite_dialog->connect("confirmed", callable_mp(this, &FileSystemDock::_move_with_overwrite)); @@ -2852,7 +2863,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { duplicate_dialog_text = memnew(LineEdit); duplicate_dialog_vb->add_margin_child(TTR("Name:"), duplicate_dialog_text); - duplicate_dialog->get_ok()->set_text(TTR("Duplicate")); + duplicate_dialog->get_ok_button()->set_text(TTR("Duplicate")); add_child(duplicate_dialog); duplicate_dialog->register_text_enter(duplicate_dialog_text); duplicate_dialog->connect("confirmed", callable_mp(this, &FileSystemDock::_duplicate_operation_confirm)); |