mirror of
https://github.com/godotengine/godot.git
synced 2025-01-23 02:52:28 -05:00
Fix root folder logic in the filesystem
This commit is contained in:
parent
2582793d40
commit
e330b79397
1 changed files with 16 additions and 5 deletions
|
@ -3242,6 +3242,10 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect
|
||||||
p_popup->add_separator();
|
p_popup->add_separator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the root path is selected, we must check p_paths[1] because the first string in
|
||||||
|
// the list of paths obtained by _tree_get_selected(...) is not always the root path.
|
||||||
|
bool root_path_not_selected = p_paths[0] != "res://" && (p_paths.size() <= 1 || p_paths[1] != "res://");
|
||||||
|
|
||||||
if (all_folders && foldernames.size() > 0) {
|
if (all_folders && foldernames.size() > 0) {
|
||||||
p_popup->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Expand Folder"), FILE_OPEN);
|
p_popup->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Expand Folder"), FILE_OPEN);
|
||||||
|
|
||||||
|
@ -3252,7 +3256,8 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect
|
||||||
|
|
||||||
p_popup->add_separator();
|
p_popup->add_separator();
|
||||||
|
|
||||||
if (p_paths[0] != "res://") {
|
// Only add the 'Set Folder Color...' option if the root path is not selected.
|
||||||
|
if (root_path_not_selected) {
|
||||||
PopupMenu *folder_colors_menu = memnew(PopupMenu);
|
PopupMenu *folder_colors_menu = memnew(PopupMenu);
|
||||||
folder_colors_menu->connect(SceneStringName(id_pressed), callable_mp(this, &FileSystemDock::_folder_color_index_pressed).bind(folder_colors_menu));
|
folder_colors_menu->connect(SceneStringName(id_pressed), callable_mp(this, &FileSystemDock::_folder_color_index_pressed).bind(folder_colors_menu));
|
||||||
|
|
||||||
|
@ -3272,25 +3277,31 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the options that are only available when a single item is selected.
|
||||||
if (p_paths.size() == 1) {
|
if (p_paths.size() == 1) {
|
||||||
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionCopy")), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH);
|
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("ActionCopy")), ED_GET_SHORTCUT("filesystem_dock/copy_path"), FILE_COPY_PATH);
|
||||||
p_popup->add_shortcut(ED_GET_SHORTCUT("filesystem_dock/copy_absolute_path"), FILE_COPY_ABSOLUTE_PATH);
|
p_popup->add_shortcut(ED_GET_SHORTCUT("filesystem_dock/copy_absolute_path"), FILE_COPY_ABSOLUTE_PATH);
|
||||||
if (ResourceLoader::get_resource_uid(p_paths[0]) != ResourceUID::INVALID_ID) {
|
if (ResourceLoader::get_resource_uid(p_paths[0]) != ResourceUID::INVALID_ID) {
|
||||||
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Instance")), ED_GET_SHORTCUT("filesystem_dock/copy_uid"), FILE_COPY_UID);
|
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Instance")), ED_GET_SHORTCUT("filesystem_dock/copy_uid"), FILE_COPY_UID);
|
||||||
}
|
}
|
||||||
if (p_paths[0] != "res://") {
|
if (root_path_not_selected) {
|
||||||
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Rename")), ED_GET_SHORTCUT("filesystem_dock/rename"), FILE_RENAME);
|
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Rename")), ED_GET_SHORTCUT("filesystem_dock/rename"), FILE_RENAME);
|
||||||
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Duplicate")), ED_GET_SHORTCUT("filesystem_dock/duplicate"), FILE_DUPLICATE);
|
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Duplicate")), ED_GET_SHORTCUT("filesystem_dock/duplicate"), FILE_DUPLICATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_paths.size() > 1 || p_paths[0] != "res://") {
|
// Add the options that are only available when the root path is not selected.
|
||||||
|
if (root_path_not_selected) {
|
||||||
p_popup->add_icon_item(get_editor_theme_icon(SNAME("MoveUp")), TTR("Move/Duplicate To..."), FILE_MOVE);
|
p_popup->add_icon_item(get_editor_theme_icon(SNAME("MoveUp")), TTR("Move/Duplicate To..."), FILE_MOVE);
|
||||||
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Remove")), ED_GET_SHORTCUT("filesystem_dock/delete"), FILE_REMOVE);
|
p_popup->add_icon_shortcut(get_editor_theme_icon(SNAME("Remove")), ED_GET_SHORTCUT("filesystem_dock/delete"), FILE_REMOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_popup->add_separator();
|
// Only add a separator if we have actually placed any options in the menu since the last separator.
|
||||||
|
if (p_paths.size() == 1 || root_path_not_selected) {
|
||||||
|
p_popup->add_separator();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the options that are available when one or more items are selected.
|
||||||
if (p_paths.size() >= 1) {
|
if (p_paths.size() >= 1) {
|
||||||
if (!all_favorites) {
|
if (!all_favorites) {
|
||||||
p_popup->add_icon_item(get_editor_theme_icon(SNAME("Favorites")), TTR("Add to Favorites"), FILE_ADD_FAVORITE);
|
p_popup->add_icon_item(get_editor_theme_icon(SNAME("Favorites")), TTR("Add to Favorites"), FILE_ADD_FAVORITE);
|
||||||
|
@ -3299,7 +3310,7 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, const Vect
|
||||||
p_popup->add_icon_item(get_editor_theme_icon(SNAME("NonFavorite")), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE);
|
p_popup->add_icon_item(get_editor_theme_icon(SNAME("NonFavorite")), TTR("Remove from Favorites"), FILE_REMOVE_FAVORITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_paths.size() > 1 || p_paths[0] != "res://") {
|
if (root_path_not_selected) {
|
||||||
cached_valid_conversion_targets = _get_valid_conversions_for_file_paths(p_paths);
|
cached_valid_conversion_targets = _get_valid_conversions_for_file_paths(p_paths);
|
||||||
|
|
||||||
int relative_id = 0;
|
int relative_id = 0;
|
||||||
|
|
Loading…
Reference in a new issue