Merge pull request #29638 from YeldhamDev/editor_file_hidden_toggle

Add button for toggling hidden files in EditorFileDialog
This commit is contained in:
Rémi Verschelde 2019-06-13 10:09:19 +02:00 committed by GitHub
commit d888c50fa3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 12 deletions

View file

@ -63,6 +63,7 @@ void EditorFileDialog::_notification(int p_what) {
dir_up->set_icon(get_icon("ArrowUp", "EditorIcons")); dir_up->set_icon(get_icon("ArrowUp", "EditorIcons"));
refresh->set_icon(get_icon("Reload", "EditorIcons")); refresh->set_icon(get_icon("Reload", "EditorIcons"));
favorite->set_icon(get_icon("Favorites", "EditorIcons")); favorite->set_icon(get_icon("Favorites", "EditorIcons"));
show_hidden->set_icon(get_icon("GuiVisibilityVisible", "EditorIcons"));
fav_up->set_icon(get_icon("MoveUp", "EditorIcons")); fav_up->set_icon(get_icon("MoveUp", "EditorIcons"));
fav_down->set_icon(get_icon("MoveDown", "EditorIcons")); fav_down->set_icon(get_icon("MoveDown", "EditorIcons"));
@ -86,9 +87,9 @@ void EditorFileDialog::_notification(int p_what) {
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { } else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
bool show_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files"); bool is_showing_hidden = EditorSettings::get_singleton()->get("filesystem/file_dialog/show_hidden_files");
if (show_hidden_files != show_hidden) if (show_hidden_files != is_showing_hidden)
set_show_hidden_files(show_hidden); set_show_hidden_files(is_showing_hidden);
set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int()); set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("filesystem/file_dialog/display_mode").operator int());
// update icons // update icons
@ -717,20 +718,19 @@ void EditorFileDialog::update_file_list() {
List<String> files; List<String> files;
List<String> dirs; List<String> dirs;
bool isdir; bool is_dir;
bool ishidden; bool is_hidden;
bool show_hidden = show_hidden_files;
String item; String item;
while ((item = dir_access->get_next(&isdir)) != "") { while ((item = dir_access->get_next(&is_dir)) != "") {
if (item == "." || item == "..") if (item == "." || item == "..")
continue; continue;
ishidden = dir_access->current_is_hidden(); is_hidden = dir_access->current_is_hidden();
if (show_hidden || !ishidden) { if (show_hidden_files || !is_hidden) {
if (!isdir) if (!is_dir)
files.push_back(item); files.push_back(item);
else else
dirs.push_back(item); dirs.push_back(item);
@ -1411,6 +1411,7 @@ void EditorFileDialog::_bind_methods() {
void EditorFileDialog::set_show_hidden_files(bool p_show) { void EditorFileDialog::set_show_hidden_files(bool p_show) {
show_hidden_files = p_show; show_hidden_files = p_show;
show_hidden->set_pressed(p_show);
invalidate(); invalidate();
} }
@ -1521,11 +1522,18 @@ EditorFileDialog::EditorFileDialog() {
favorite->connect("pressed", this, "_favorite_pressed"); favorite->connect("pressed", this, "_favorite_pressed");
pathhb->add_child(favorite); pathhb->add_child(favorite);
Ref<ButtonGroup> view_mode_group; show_hidden = memnew(ToolButton);
view_mode_group.instance(); show_hidden->set_toggle_mode(true);
show_hidden->set_pressed(is_showing_hidden_files());
show_hidden->set_tooltip(TTR("Toggle visibility of hidden files."));
show_hidden->connect("toggled", this, "set_show_hidden_files");
pathhb->add_child(show_hidden);
pathhb->add_child(memnew(VSeparator)); pathhb->add_child(memnew(VSeparator));
Ref<ButtonGroup> view_mode_group;
view_mode_group.instance();
mode_thumbnails = memnew(ToolButton); mode_thumbnails = memnew(ToolButton);
mode_thumbnails->connect("pressed", this, "set_display_mode", varray(DISPLAY_THUMBNAILS)); mode_thumbnails->connect("pressed", this, "set_display_mode", varray(DISPLAY_THUMBNAILS));
mode_thumbnails->set_toggle_mode(true); mode_thumbnails->set_toggle_mode(true);

View file

@ -116,11 +116,13 @@ private:
DirAccess *dir_access; DirAccess *dir_access;
ConfirmationDialog *confirm_save; ConfirmationDialog *confirm_save;
DependencyRemoveDialog *remove_dialog; DependencyRemoveDialog *remove_dialog;
ToolButton *mode_thumbnails; ToolButton *mode_thumbnails;
ToolButton *mode_list; ToolButton *mode_list;
ToolButton *refresh; ToolButton *refresh;
ToolButton *favorite; ToolButton *favorite;
ToolButton *show_hidden;
ToolButton *fav_up; ToolButton *fav_up;
ToolButton *fav_down; ToolButton *fav_down;