Merge pull request #3083 from TheHX/pr-file-dialog

Add editor setting for display mode on file dialog and filesystem dock
This commit is contained in:
Rémi Verschelde 2015-12-15 19:15:56 +01:00
commit 9cb4798f6b
6 changed files with 29 additions and 7 deletions

View File

@ -55,11 +55,8 @@ void EditorFileDialog::_notification(int p_what) {
//get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size())); //get_stylebox("panel","PopupMenu")->draw(ci,Rect2(Point2(),get_size()));
} 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("file_dialog/show_hidden_files"); set_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
set_display_mode((DisplayMode)EditorSettings::get_singleton()->get("file_dialog/display_mode").operator int());
if (show_hidden != show_hidden_files) {
set_show_hidden_files(show_hidden);
}
} }
} }
@ -1026,6 +1023,8 @@ void EditorFileDialog::_go_forward(){
bool EditorFileDialog::default_show_hidden_files=false; bool EditorFileDialog::default_show_hidden_files=false;
EditorFileDialog::DisplayMode EditorFileDialog::default_display_mode=DISPLAY_THUMBNAILS;
void EditorFileDialog::set_display_mode(DisplayMode p_mode) { void EditorFileDialog::set_display_mode(DisplayMode p_mode) {
if (display_mode==p_mode) if (display_mode==p_mode)
@ -1125,6 +1124,10 @@ void EditorFileDialog::set_default_show_hidden_files(bool p_show) {
default_show_hidden_files=p_show; default_show_hidden_files=p_show;
} }
void EditorFileDialog::set_default_display_mode(DisplayMode p_mode) {
default_display_mode=p_mode;
}
void EditorFileDialog::_save_to_recent() { void EditorFileDialog::_save_to_recent() {
String dir = get_current_dir(); String dir = get_current_dir();
@ -1154,7 +1157,7 @@ void EditorFileDialog::_save_to_recent() {
EditorFileDialog::EditorFileDialog() { EditorFileDialog::EditorFileDialog() {
show_hidden_files=default_show_hidden_files; show_hidden_files=default_show_hidden_files;
display_mode=DISPLAY_THUMBNAILS; display_mode=default_display_mode;
local_history_pos=0; local_history_pos=0;
VBoxContainer *vbc = memnew( VBoxContainer ); VBoxContainer *vbc = memnew( VBoxContainer );
@ -1194,11 +1197,13 @@ EditorFileDialog::EditorFileDialog() {
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);
mode_thumbnails->set_pressed(true); mode_thumbnails->set_pressed(display_mode==DISPLAY_THUMBNAILS);
pathhb->add_child(mode_thumbnails); pathhb->add_child(mode_thumbnails);
mode_list = memnew( ToolButton ); mode_list = memnew( ToolButton );
mode_list->connect("pressed",this,"set_display_mode",varray(DISPLAY_LIST)); mode_list->connect("pressed",this,"set_display_mode",varray(DISPLAY_LIST));
mode_list->set_toggle_mode(true); mode_list->set_toggle_mode(true);
mode_list->set_pressed(display_mode==DISPLAY_LIST);
pathhb->add_child(mode_list); pathhb->add_child(mode_list);
drives = memnew( OptionButton ); drives = memnew( OptionButton );

View File

@ -128,6 +128,7 @@ private:
int preview_wheel_index; int preview_wheel_index;
float preview_wheel_timeout; float preview_wheel_timeout;
static bool default_show_hidden_files; static bool default_show_hidden_files;
static DisplayMode default_display_mode;
bool show_hidden_files; bool show_hidden_files;
DisplayMode display_mode; DisplayMode display_mode;
@ -211,6 +212,7 @@ public:
bool is_showing_hidden_files() const; bool is_showing_hidden_files() const;
static void set_default_show_hidden_files(bool p_show); static void set_default_show_hidden_files(bool p_show);
static void set_default_display_mode(DisplayMode p_mode);
void invalidate(); void invalidate();

View File

@ -4766,6 +4766,7 @@ EditorNode::EditorNode() {
ResourceLoader::set_abort_on_missing_resources(false); ResourceLoader::set_abort_on_missing_resources(false);
FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); FileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files")); EditorFileDialog::set_default_show_hidden_files(EditorSettings::get_singleton()->get("file_dialog/show_hidden_files"));
EditorFileDialog::set_default_display_mode((EditorFileDialog::DisplayMode)EditorSettings::get_singleton()->get("file_dialog/display_mode").operator int());
ResourceLoader::set_error_notify_func(this,_load_error_notify); ResourceLoader::set_error_notify_func(this,_load_error_notify);
ResourceLoader::set_dependency_error_notify_func(this,_dependency_error_report); ResourceLoader::set_dependency_error_notify_func(this,_dependency_error_report);
@ -5612,6 +5613,7 @@ EditorNode::EditorNode() {
scenes_dock = memnew( ScenesDock(this) ); scenes_dock = memnew( ScenesDock(this) );
scenes_dock->set_name("FileSystem"); scenes_dock->set_name("FileSystem");
scenes_dock->set_use_thumbnails(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_THUMBNAILS);
dock_slot[DOCK_SLOT_LEFT_BR]->add_child(scenes_dock); dock_slot[DOCK_SLOT_LEFT_BR]->add_child(scenes_dock);
//prop_pallete->add_child(scenes_dock); //prop_pallete->add_child(scenes_dock);
scenes_dock->connect("open",this,"open_request"); scenes_dock->connect("open",this,"open_request");

View File

@ -515,6 +515,8 @@ void EditorSettings::_load_defaults() {
set("text_editor/create_signal_callbacks",true); set("text_editor/create_signal_callbacks",true);
set("file_dialog/show_hidden_files", false); set("file_dialog/show_hidden_files", false);
set("file_dialog/display_mode", 0);
hints["file_dialog/display_mode"]=PropertyInfo(Variant::INT,"file_dialog/display_mode",PROPERTY_HINT_ENUM,"Thumbnails,List");
set("file_dialog/thumbnail_size", 64); set("file_dialog/thumbnail_size", 64);
hints["file_dialog/thumbnail_size"]=PropertyInfo(Variant::INT,"file_dialog/thumbnail_size",PROPERTY_HINT_RANGE,"32,128,16"); hints["file_dialog/thumbnail_size"]=PropertyInfo(Variant::INT,"file_dialog/thumbnail_size",PROPERTY_HINT_RANGE,"32,128,16");

View File

@ -195,7 +195,12 @@ void ScenesDock::_notification(int p_what) {
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
} break; } break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
display_mode->set_pressed(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_LIST);
_change_file_display();
} break;
} }
} }
@ -1063,6 +1068,11 @@ void ScenesDock::open(const String& p_path) {
} }
void ScenesDock::set_use_thumbnails(bool p_use) {
display_mode->set_pressed(!p_use);
}
void ScenesDock::_bind_methods() { void ScenesDock::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_update_tree"),&ScenesDock::_update_tree); ObjectTypeDB::bind_method(_MD("_update_tree"),&ScenesDock::_update_tree);

View File

@ -153,6 +153,7 @@ public:
void fix_dependencies(const String& p_for_file); void fix_dependencies(const String& p_for_file);
void set_use_thumbnails(bool p_use);
ScenesDock(EditorNode *p_editor); ScenesDock(EditorNode *p_editor);
~ScenesDock(); ~ScenesDock();