Better editor settings for the FileSystem dock
* Save the current display mode when changing it from the dock
This commit is contained in:
parent
91ba00b416
commit
f6b39827b1
@ -6180,7 +6180,7 @@ EditorNode::EditorNode() {
|
|||||||
|
|
||||||
scenes_dock = memnew( FileSystemDock(this) );
|
scenes_dock = memnew( FileSystemDock(this) );
|
||||||
scenes_dock->set_name(TTR("FileSystem"));
|
scenes_dock->set_name(TTR("FileSystem"));
|
||||||
scenes_dock->set_use_thumbnails(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_THUMBNAILS);
|
scenes_dock->set_display_mode(int(EditorSettings::get_singleton()->get("filesystem_dock/display_mode")));
|
||||||
dock_slot[DOCK_SLOT_LEFT_UR]->add_child(scenes_dock);
|
dock_slot[DOCK_SLOT_LEFT_UR]->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");
|
||||||
|
@ -622,6 +622,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||||||
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");
|
||||||
|
|
||||||
|
set("filesystem_dock/display_mode", 0);
|
||||||
|
hints["filesystem_dock/display_mode"]=PropertyInfo(Variant::INT,"filesystem_dock/display_mode",PROPERTY_HINT_ENUM,"Thumbnails,List");
|
||||||
|
set("filesystem_dock/thumbnail_size", 64);
|
||||||
|
hints["filesystem_dock/thumbnail_size"]=PropertyInfo(Variant::INT,"filesystem_dock/thumbnail_size",PROPERTY_HINT_RANGE,"32,128,16");
|
||||||
|
|
||||||
set("animation/autorename_animation_tracks",true);
|
set("animation/autorename_animation_tracks",true);
|
||||||
set("animation/confirm_insert_track",true);
|
set("animation/confirm_insert_track",true);
|
||||||
|
|
||||||
|
@ -146,8 +146,12 @@ void FileSystemDock::_notification(int p_what) {
|
|||||||
//button_instance->set_icon( get_icon("Add","EditorIcons"));
|
//button_instance->set_icon( get_icon("Add","EditorIcons"));
|
||||||
//button_open->set_icon( get_icon("Folder","EditorIcons"));
|
//button_open->set_icon( get_icon("Folder","EditorIcons"));
|
||||||
button_back->set_icon( get_icon("Filesystem","EditorIcons"));
|
button_back->set_icon( get_icon("Filesystem","EditorIcons"));
|
||||||
display_mode->set_icon( get_icon("FileList","EditorIcons"));
|
if (display_mode == DISPLAY_THUMBNAILS) {
|
||||||
display_mode->connect("pressed",this,"_change_file_display");
|
button_display_mode->set_icon(get_icon("FileList","EditorIcons"));
|
||||||
|
} else {
|
||||||
|
button_display_mode->set_icon(get_icon("FileThumbnail","EditorIcons"));
|
||||||
|
}
|
||||||
|
button_display_mode->connect("pressed",this,"_change_file_display");
|
||||||
//file_options->set_icon( get_icon("Tools","EditorIcons"));
|
//file_options->set_icon( get_icon("Tools","EditorIcons"));
|
||||||
files->connect("item_activated",this,"_select_file");
|
files->connect("item_activated",this,"_select_file");
|
||||||
button_hist_next->connect("pressed",this,"_fw_history");
|
button_hist_next->connect("pressed",this,"_fw_history");
|
||||||
@ -197,9 +201,13 @@ void FileSystemDock::_notification(int p_what) {
|
|||||||
} break;
|
} break;
|
||||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||||
|
|
||||||
display_mode->set_pressed(int(EditorSettings::get_singleton()->get("file_dialog/display_mode"))==EditorFileDialog::DISPLAY_LIST);
|
int new_mode = int(EditorSettings::get_singleton()->get("filesystem_dock/display_mode"));
|
||||||
|
|
||||||
_change_file_display();
|
if (new_mode != display_mode) {
|
||||||
|
set_display_mode(new_mode);
|
||||||
|
} else {
|
||||||
|
_update_files(true);
|
||||||
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,13 +322,16 @@ void FileSystemDock::_thumbnail_done(const String& p_path,const Ref<Texture>& p_
|
|||||||
|
|
||||||
void FileSystemDock::_change_file_display() {
|
void FileSystemDock::_change_file_display() {
|
||||||
|
|
||||||
if (display_mode->is_pressed()) {
|
if (button_display_mode->is_pressed()) {
|
||||||
display_mode->set_icon( get_icon("FileThumbnail","EditorIcons"));
|
display_mode = DISPLAY_LIST;
|
||||||
|
button_display_mode->set_icon( get_icon("FileThumbnail","EditorIcons"));
|
||||||
} else {
|
} else {
|
||||||
display_mode->set_icon( get_icon("FileList","EditorIcons"));
|
display_mode = DISPLAY_THUMBNAILS;
|
||||||
|
button_display_mode->set_icon( get_icon("FileList","EditorIcons"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditorSettings::get_singleton()->set("filesystem_dock/display_mode", display_mode);
|
||||||
|
|
||||||
_update_files(true);
|
_update_files(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,12 +404,12 @@ void FileSystemDock::_update_files(bool p_keep_selection) {
|
|||||||
if (!efd)
|
if (!efd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int thumbnail_size = EditorSettings::get_singleton()->get("file_dialog/thumbnail_size");
|
int thumbnail_size = EditorSettings::get_singleton()->get("filesystem_dock/thumbnail_size");
|
||||||
thumbnail_size*=EDSCALE;
|
thumbnail_size*=EDSCALE;
|
||||||
Ref<Texture> folder_thumbnail;
|
Ref<Texture> folder_thumbnail;
|
||||||
Ref<Texture> file_thumbnail;
|
Ref<Texture> file_thumbnail;
|
||||||
|
|
||||||
bool use_thumbnails=!display_mode->is_pressed();
|
bool use_thumbnails = (display_mode == DISPLAY_THUMBNAILS);
|
||||||
bool use_folders = search_box->get_text().length()==0 && split_mode;
|
bool use_folders = search_box->get_text().length()==0 && split_mode;
|
||||||
|
|
||||||
if (use_thumbnails) { //thumbnails
|
if (use_thumbnails) { //thumbnails
|
||||||
@ -1147,9 +1158,13 @@ void FileSystemDock::focus_on_filter() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSystemDock::set_use_thumbnails(bool p_use) {
|
void FileSystemDock::set_display_mode(int p_mode) {
|
||||||
|
|
||||||
display_mode->set_pressed(!p_use);
|
if (p_mode == display_mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
button_display_mode->set_pressed(p_mode == DISPLAY_LIST);
|
||||||
|
_change_file_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1721,9 +1736,9 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
|
|||||||
search_icon->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED);
|
search_icon->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED);
|
||||||
path_hb->add_child(search_icon);
|
path_hb->add_child(search_icon);
|
||||||
|
|
||||||
display_mode = memnew( ToolButton );
|
button_display_mode = memnew( ToolButton );
|
||||||
path_hb->add_child(display_mode);
|
path_hb->add_child(button_display_mode);
|
||||||
display_mode->set_toggle_mode(true);
|
button_display_mode->set_toggle_mode(true);
|
||||||
|
|
||||||
file_list_vb->add_child(files);
|
file_list_vb->add_child(files);
|
||||||
|
|
||||||
@ -1766,6 +1781,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
|
|||||||
history_pos=0;
|
history_pos=0;
|
||||||
|
|
||||||
split_mode=false;
|
split_mode=false;
|
||||||
|
display_mode = DISPLAY_THUMBNAILS;
|
||||||
|
|
||||||
path="res://";
|
path="res://";
|
||||||
|
|
||||||
|
@ -54,6 +54,12 @@ class EditorNode;
|
|||||||
class FileSystemDock : public VBoxContainer {
|
class FileSystemDock : public VBoxContainer {
|
||||||
OBJ_TYPE( FileSystemDock, VBoxContainer );
|
OBJ_TYPE( FileSystemDock, VBoxContainer );
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum DisplayMode {
|
||||||
|
DISPLAY_THUMBNAILS,
|
||||||
|
DISPLAY_LIST
|
||||||
|
};
|
||||||
|
private:
|
||||||
enum FileMenu {
|
enum FileMenu {
|
||||||
FILE_OPEN,
|
FILE_OPEN,
|
||||||
FILE_INSTANCE,
|
FILE_INSTANCE,
|
||||||
@ -79,7 +85,7 @@ class FileSystemDock : public VBoxContainer {
|
|||||||
Button *button_reload;
|
Button *button_reload;
|
||||||
Button *button_favorite;
|
Button *button_favorite;
|
||||||
Button *button_back;
|
Button *button_back;
|
||||||
Button *display_mode;
|
Button *button_display_mode;
|
||||||
Button *button_hist_next;
|
Button *button_hist_next;
|
||||||
Button *button_hist_prev;
|
Button *button_hist_prev;
|
||||||
LineEdit *current_path;
|
LineEdit *current_path;
|
||||||
@ -88,6 +94,7 @@ class FileSystemDock : public VBoxContainer {
|
|||||||
HBoxContainer *path_hb;
|
HBoxContainer *path_hb;
|
||||||
|
|
||||||
bool split_mode;
|
bool split_mode;
|
||||||
|
DisplayMode display_mode;
|
||||||
|
|
||||||
PopupMenu *file_options;
|
PopupMenu *file_options;
|
||||||
|
|
||||||
@ -182,7 +189,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);
|
void set_display_mode(int p_mode);
|
||||||
|
|
||||||
FileSystemDock(EditorNode *p_editor);
|
FileSystemDock(EditorNode *p_editor);
|
||||||
~FileSystemDock();
|
~FileSystemDock();
|
||||||
|
Loading…
Reference in New Issue
Block a user