diff options
-rw-r--r-- | editor/filesystem_dock.cpp | 35 | ||||
-rw-r--r-- | editor/filesystem_dock.h | 1 |
2 files changed, 25 insertions, 11 deletions
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index e4823c7745..406593800e 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1484,8 +1484,15 @@ Vector<String> FileSystemDock::_tree_get_selected(bool remove_self_inclusion) { selected = tree->get_next_selected(selected); } + if (remove_self_inclusion) { + selected_strings = _remove_self_included_paths(selected_strings); + } + return selected_strings; +} + +Vector<String> FileSystemDock::_remove_self_included_paths(Vector<String> selected_strings) { // Remove paths or files that are included into another - if (remove_self_inclusion && selected_strings.size() > 1) { + if (selected_strings.size() > 1) { selected_strings.sort_custom<NaturalNoCaseComparator>(); String last_path = ""; for (int i = 0; i < selected_strings.size(); i++) { @@ -1503,7 +1510,7 @@ Vector<String> FileSystemDock::_tree_get_selected(bool remove_self_inclusion) { void FileSystemDock::_tree_rmb_option(int p_option) { - Vector<String> selected_strings = _tree_get_selected(); + Vector<String> selected_strings = _tree_get_selected(false); // Execute the current option switch (p_option) { @@ -1642,8 +1649,9 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected case FILE_MOVE: { // Move the files to a given location to_move.clear(); - for (int i = 0; i < p_selected.size(); i++) { - String fpath = p_selected[i]; + Vector<String> collapsed_paths = _remove_self_included_paths(p_selected); + for (int i = collapsed_paths.size() - 1; i >= 0; i--) { + String fpath = collapsed_paths[i]; if (fpath != "res://") { to_move.push_back(FileOrFolder(fpath, !fpath.ends_with("/"))); } @@ -1680,9 +1688,10 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected // Remove the selected files Vector<String> remove_files; Vector<String> remove_folders; + Vector<String> collapsed_paths = _remove_self_included_paths(p_selected); - for (int i = 0; i < p_selected.size(); i++) { - String fpath = p_selected[i]; + for (int i = 0; i < collapsed_paths.size(); i++) { + String fpath = collapsed_paths[i]; if (fpath != "res://") { if (fpath.ends_with("/")) { remove_folders.push_back(fpath); @@ -2195,12 +2204,16 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str if (p_paths.size() == 1) { p_popup->add_item(TTR("Copy Path"), FILE_COPY_PATH); - p_popup->add_item(TTR("Rename..."), FILE_RENAME); - p_popup->add_item(TTR("Duplicate..."), FILE_DUPLICATE); + if (p_paths[0] != "res://") { + p_popup->add_item(TTR("Rename..."), FILE_RENAME); + p_popup->add_item(TTR("Duplicate..."), FILE_DUPLICATE); + } } - p_popup->add_item(TTR("Move To..."), FILE_MOVE); - p_popup->add_item(TTR("Delete"), FILE_REMOVE); + if (p_paths.size() > 1 || p_paths[0] != "res://") { + p_popup->add_item(TTR("Move To..."), FILE_MOVE); + p_popup->add_item(TTR("Delete"), FILE_REMOVE); + } if (p_paths.size() == 1) { p_popup->add_separator(); @@ -2219,7 +2232,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) { // Right click is pressed in the tree - Vector<String> paths = _tree_get_selected(); + Vector<String> paths = _tree_get_selected(false); if (paths.size() == 1) { if (paths[0].ends_with("/")) { diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index cc5ba94b48..561a4eba81 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -279,6 +279,7 @@ private: bool _is_file_type_disabled_by_feature_profile(const StringName &p_class); void _feature_profile_changed(); + Vector<String> _remove_self_included_paths(Vector<String> selected_strings); protected: void _notification(int p_what); |