Remove the thumnail-only view from the filesystem dock

This commit is contained in:
groud 2018-10-16 22:08:00 +02:00
parent ebdb374d80
commit 8f3becafeb
2 changed files with 10 additions and 77 deletions

View File

@ -227,12 +227,7 @@ void FileSystemDock::_update_tree(const Vector<String> p_uncollapsed_paths, bool
void FileSystemDock::_update_display_mode() { void FileSystemDock::_update_display_mode() {
// Compute the new display mode // Compute the new display mode
DisplayMode new_display_mode; DisplayMode new_display_mode = (display_mode_setting == DISPLAY_MODE_SETTING_TREE_ONLY) ? DISPLAY_MODE_TREE_ONLY : DISPLAY_MODE_SPLIT;
if (display_mode_setting == DISPLAY_MODE_SETTING_TREE_ONLY) {
new_display_mode = file_list_view ? DISPLAY_MODE_FILE_LIST_ONLY : DISPLAY_MODE_TREE_ONLY;
} else {
new_display_mode = DISPLAY_MODE_SPLIT;
}
if (new_display_mode != display_mode || old_display_mode_setting != display_mode_setting) { if (new_display_mode != display_mode || old_display_mode_setting != display_mode_setting) {
display_mode = new_display_mode; display_mode = new_display_mode;
@ -252,19 +247,9 @@ void FileSystemDock::_update_display_mode() {
file_list_vb->hide(); file_list_vb->hide();
break; break;
case DISPLAY_MODE_FILE_LIST_ONLY:
tree->hide();
tree_search_box->hide();
button_tree->show();
file_list_vb->show();
_update_file_list(true);
break;
case DISPLAY_MODE_SPLIT: case DISPLAY_MODE_SPLIT:
tree->show(); tree->show();
tree->set_v_size_flags(SIZE_EXPAND_FILL); tree->set_v_size_flags(SIZE_EXPAND_FILL);
button_tree->hide();
tree->ensure_cursor_is_visible(); tree->ensure_cursor_is_visible();
tree_search_box->hide(); tree_search_box->hide();
_update_tree(_compute_uncollapsed_paths()); _update_tree(_compute_uncollapsed_paths());
@ -295,7 +280,6 @@ void FileSystemDock::_notification(int p_what) {
String ei = "EditorIcons"; String ei = "EditorIcons";
button_reload->set_icon(get_icon("Reload", ei)); button_reload->set_icon(get_icon("Reload", ei));
button_toggle_display_mode->set_icon(get_icon("Panels2", ei)); button_toggle_display_mode->set_icon(get_icon("Panels2", ei));
button_tree->set_icon(get_icon("Filesystem", ei));
_update_file_list_display_mode_button(); _update_file_list_display_mode_button();
button_file_list_display_mode->connect("pressed", this, "_change_file_display"); button_file_list_display_mode->connect("pressed", this, "_change_file_display");
@ -312,7 +296,6 @@ void FileSystemDock::_notification(int p_what) {
file_list_popup->connect("id_pressed", this, "_file_list_rmb_option"); file_list_popup->connect("id_pressed", this, "_file_list_rmb_option");
tree_popup->connect("id_pressed", this, "_tree_rmb_option"); tree_popup->connect("id_pressed", this, "_tree_rmb_option");
button_tree->connect("pressed", this, "_go_to_tree", varray(), CONNECT_DEFERRED);
current_path->connect("text_entered", this, "navigate_to_path"); current_path->connect("text_entered", this, "navigate_to_path");
display_mode_setting = DisplayModeSetting(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode"))); display_mode_setting = DisplayModeSetting(int(EditorSettings::get_singleton()->get("docks/filesystem/display_mode")));
@ -357,7 +340,6 @@ void FileSystemDock::_notification(int p_what) {
String ei = "EditorIcons"; String ei = "EditorIcons";
button_reload->set_icon(get_icon("Reload", ei)); button_reload->set_icon(get_icon("Reload", ei));
button_toggle_display_mode->set_icon(get_icon("Panels2", ei)); button_toggle_display_mode->set_icon(get_icon("Panels2", ei));
button_tree->set_icon(get_icon("Filesystem", ei));
button_hist_next->set_icon(get_icon("Forward", ei)); button_hist_next->set_icon(get_icon("Forward", ei));
button_hist_prev->set_icon(get_icon("Back", ei)); button_hist_prev->set_icon(get_icon("Back", ei));
@ -474,20 +456,9 @@ void FileSystemDock::navigate_to_path(const String &p_path) {
_set_current_path_text(path); _set_current_path_text(path);
_push_to_history(); _push_to_history();
_update_tree(_compute_uncollapsed_paths());
if (display_mode == DISPLAY_MODE_SPLIT) { if (display_mode == DISPLAY_MODE_SPLIT) {
if (path.ends_with("/") || path == "Favorites") {
_go_to_file_list();
}
_update_tree(_compute_uncollapsed_paths());
_update_file_list(false); _update_file_list(false);
} else if (display_mode == DISPLAY_MODE_TREE_ONLY) {
if (path.ends_with("/") || path == "Favorites") {
_go_to_file_list();
} else {
_update_tree(_compute_uncollapsed_paths());
}
} else { // DISPLAY_MODE_FILE_LIST_ONLY
_update_file_list(true);
} }
String file_name = p_path.get_file(); String file_name = p_path.get_file();
@ -701,7 +672,7 @@ void FileSystemDock::_update_file_list(bool p_keep_selection) {
_search(EditorFileSystem::get_singleton()->get_filesystem(), &filelist, 128); _search(EditorFileSystem::get_singleton()->get_filesystem(), &filelist, 128);
} else { } else {
if ((display_mode == DISPLAY_MODE_FILE_LIST_ONLY || display_mode == DISPLAY_MODE_TREE_ONLY) || always_show_folders) { if (display_mode == DISPLAY_MODE_TREE_ONLY || always_show_folders) {
// Display folders in the list // Display folders in the list
if (directory != "res://") { if (directory != "res://") {
@ -829,6 +800,11 @@ void FileSystemDock::_tree_activate_file() {
TreeItem *selected = tree->get_selected(); TreeItem *selected = tree->get_selected();
if (selected) { if (selected) {
call_deferred("_select_file", selected->get_metadata(0)); call_deferred("_select_file", selected->get_metadata(0));
if (path.ends_with("/") || path == "Favorites") {
bool collapsed = selected->is_collapsed();
selected->set_collapsed(!collapsed);
}
} }
} }
@ -836,30 +812,6 @@ void FileSystemDock::_file_list_activate_file(int p_idx) {
_select_file(files->get_item_metadata(p_idx)); _select_file(files->get_item_metadata(p_idx));
} }
void FileSystemDock::_go_to_file_list() {
if (display_mode == DISPLAY_MODE_TREE_ONLY) {
file_list_view = true;
_update_display_mode();
} else {
TreeItem *selected = tree->get_selected();
if (selected) {
bool collapsed = selected->is_collapsed();
selected->set_collapsed(!collapsed);
}
_update_file_list(false);
}
}
void FileSystemDock::_go_to_tree() {
file_list_view = false;
tree->grab_focus();
_update_display_mode();
tree->ensure_cursor_is_visible();
}
void FileSystemDock::_preview_invalidated(const String &p_path) { void FileSystemDock::_preview_invalidated(const String &p_path) {
if (file_list_display_mode == FILE_LIST_DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && searched_string.length() == 0 && file_list_vb->is_visible_in_tree()) { if (file_list_display_mode == FILE_LIST_DISPLAY_THUMBNAILS && p_path.get_base_dir() == path && searched_string.length() == 0 && file_list_vb->is_visible_in_tree()) {
@ -1676,9 +1628,6 @@ void FileSystemDock::_search_changed(const String &p_text, const Control *p_from
tree_search_box->set_text(searched_string); tree_search_box->set_text(searched_string);
switch (display_mode) { switch (display_mode) {
case DISPLAY_MODE_FILE_LIST_ONLY: {
_update_file_list(false);
} break;
case DISPLAY_MODE_TREE_ONLY: { case DISPLAY_MODE_TREE_ONLY: {
_update_tree(searched_string.length() == 0 ? uncollapsed_paths_before_search : Vector<String>()); _update_tree(searched_string.length() == 0 ? uncollapsed_paths_before_search : Vector<String>());
} break; } break;
@ -1707,12 +1656,6 @@ void FileSystemDock::fix_dependencies(const String &p_for_file) {
void FileSystemDock::focus_on_filter() { void FileSystemDock::focus_on_filter() {
if (display_mode == DISPLAY_MODE_FILE_LIST_ONLY && tree->is_visible()) {
// Tree mode, switch to files list with search box
tree->hide();
file_list_vb->show();
}
file_list_search_box->grab_focus(); file_list_search_box->grab_focus();
} }
@ -2302,7 +2245,6 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_file_list_activate_file"), &FileSystemDock::_file_list_activate_file); ClassDB::bind_method(D_METHOD("_file_list_activate_file"), &FileSystemDock::_file_list_activate_file);
ClassDB::bind_method(D_METHOD("_tree_activate_file"), &FileSystemDock::_tree_activate_file); ClassDB::bind_method(D_METHOD("_tree_activate_file"), &FileSystemDock::_tree_activate_file);
ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file); ClassDB::bind_method(D_METHOD("_select_file"), &FileSystemDock::_select_file);
ClassDB::bind_method(D_METHOD("_go_to_tree"), &FileSystemDock::_go_to_tree);
ClassDB::bind_method(D_METHOD("navigate_to_path"), &FileSystemDock::navigate_to_path); ClassDB::bind_method(D_METHOD("navigate_to_path"), &FileSystemDock::navigate_to_path);
ClassDB::bind_method(D_METHOD("_change_file_display"), &FileSystemDock::_change_file_display); ClassDB::bind_method(D_METHOD("_change_file_display"), &FileSystemDock::_change_file_display);
ClassDB::bind_method(D_METHOD("_fw_history"), &FileSystemDock::_fw_history); ClassDB::bind_method(D_METHOD("_fw_history"), &FileSystemDock::_fw_history);
@ -2398,7 +2340,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
/* /*
button_open = memnew( Button ); button_open = memnew( Button );
button_open->set_flat(true); button_open->set_flat(true);
button_open->connect("pressed",this,"_go_to_file_list"); button_open->connect("pressed",this,"_tree_toggle_collapsed");
toolbar_hbc->add_child(button_open); toolbar_hbc->add_child(button_open);
button_open->hide(); button_open->hide();
button_open->set_focus_mode(FOCUS_NONE); button_open->set_focus_mode(FOCUS_NONE);
@ -2448,11 +2390,6 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
path_hb = memnew(HBoxContainer); path_hb = memnew(HBoxContainer);
file_list_vb->add_child(path_hb); file_list_vb->add_child(path_hb);
button_tree = memnew(ToolButton);
button_tree->set_tooltip(TTR("Enter tree-view."));
button_tree->hide();
path_hb->add_child(button_tree);
file_list_search_box = memnew(LineEdit); file_list_search_box = memnew(LineEdit);
file_list_search_box->set_h_size_flags(SIZE_EXPAND_FILL); file_list_search_box->set_h_size_flags(SIZE_EXPAND_FILL);
file_list_search_box->set_placeholder(TTR("Search files")); file_list_search_box->set_placeholder(TTR("Search files"));

View File

@ -73,7 +73,6 @@ private:
enum DisplayMode { enum DisplayMode {
DISPLAY_MODE_TREE_ONLY, DISPLAY_MODE_TREE_ONLY,
DISPLAY_MODE_FILE_LIST_ONLY,
DISPLAY_MODE_SPLIT, DISPLAY_MODE_SPLIT,
}; };
@ -109,7 +108,6 @@ private:
Button *button_toggle_display_mode; Button *button_toggle_display_mode;
Button *button_reload; Button *button_reload;
Button *button_tree;
Button *button_file_list_display_mode; Button *button_file_list_display_mode;
Button *button_hist_next; Button *button_hist_next;
Button *button_hist_prev; Button *button_hist_prev;
@ -127,7 +125,6 @@ private:
DisplayMode display_mode; DisplayMode display_mode;
DisplayModeSetting display_mode_setting; DisplayModeSetting display_mode_setting;
DisplayModeSetting old_display_mode_setting; DisplayModeSetting old_display_mode_setting;
bool file_list_view;
PopupMenu *file_list_popup; PopupMenu *file_list_popup;
PopupMenu *tree_popup; PopupMenu *tree_popup;
@ -193,8 +190,7 @@ private:
void _change_file_display(); void _change_file_display();
void _fs_changed(); void _fs_changed();
void _go_to_tree(); void _tree_toggle_collapsed();
void _go_to_file_list();
void _select_file(const String p_path); void _select_file(const String p_path);
void _tree_activate_file(); void _tree_activate_file();