Improvements to the filesystem dock.

This commit is contained in:
Relintai 2024-07-16 21:00:57 +02:00
parent 85945392a3
commit 247b04763f
3 changed files with 24 additions and 6 deletions

View File

@ -402,6 +402,9 @@ void FileSystemDock::_notification(int p_what) {
set_file_list_display_mode(FileSystemDock::FILE_LIST_DISPLAY_LIST);
SplitMode new_split_mode = SplitMode(int(EditorSettings::get_singleton()->get("docks/filesystem/split_mode")));
set_split_mode(new_split_mode);
_update_display_mode();
if (EditorFileSystem::get_singleton()->is_scanning()) {
@ -2107,6 +2110,17 @@ void FileSystemDock::set_bottom_panel_tool_button(ToolButton *fs_button) {
bottom_panel_tool_button = fs_button;
}
void FileSystemDock::on_editor_save_and_restart() {
SplitMode new_split_mode = SplitMode(int(EditorSettings::get_singleton()->get("docks/filesystem/split_mode")));
if (new_split_mode != split_mode) {
set_split_mode(new_split_mode);
if (split_box->get_split_offset() < 100 * EDSCALE) {
split_box->set_split_offset(100 * EDSCALE);
}
}
}
Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
bool all_favorites = true;
bool all_not_favorites = true;
@ -2904,7 +2918,12 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
#endif
ED_SHORTCUT("filesystem_dock/open_search", TTR("Focus the search box"), KEY_MASK_CMD | KEY_F);
bool wide = static_cast<SplitMode>(static_cast<int>(EDITOR_GET("docks/filesystem/dock_mode")));
dock_mode = static_cast<DockMode>(static_cast<int>(EDITOR_GET("docks/filesystem/dock_mode")));
applied_dock_mode = static_cast<DockMode>(static_cast<int>(EDITOR_GET("docks/filesystem/dock_mode")));
split_mode = static_cast<SplitMode>(static_cast<int>(EDITOR_GET("docks/filesystem/split_mode")));
bool wide = split_mode == SPLIT_MODE_VERTICAL;
VBoxContainer *top_vbc = memnew(VBoxContainer);
add_child(top_vbc);
@ -3113,11 +3132,9 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
if (wide) {
display_mode = DISPLAY_MODE_SPLIT;
old_display_mode = DISPLAY_MODE_SPLIT;
split_mode = SPLIT_MODE_VERTICAL;
} else {
display_mode = DISPLAY_MODE_TREE_ONLY;
old_display_mode = DISPLAY_MODE_TREE_ONLY;
split_mode = SPLIT_MODE_HORIZONTAL;
}
set_split_mode(split_mode);
@ -3129,9 +3146,6 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
file_list_display_mode = FILE_LIST_DISPLAY_THUMBNAILS;
always_show_folders = false;
dock_mode = DOCK_MODE_DOCK;
applied_dock_mode = DOCK_MODE_DOCK;
}
FileSystemDock::~FileSystemDock() {

View File

@ -391,6 +391,8 @@ public:
void ensure_visible();
void set_bottom_panel_tool_button(ToolButton *fs_button);
void on_editor_save_and_restart();
FileSystemDock(EditorNode *p_editor);
~FileSystemDock();
};

View File

@ -53,6 +53,7 @@
#include "editor_property_name_processor.h"
#include "editor_scale.h"
#include "editor_settings.h"
#include "filesystem_dock.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
#include "scene/gui/label.h"
@ -403,6 +404,7 @@ void EditorSettingsDialog::_focus_current_search_box() {
}
void EditorSettingsDialog::_editor_restart() {
EditorNode::get_singleton()->get_filesystem_dock()->on_editor_save_and_restart();
EditorNode::get_singleton()->save_all_scenes();
EditorNode::get_singleton()->restart_editor();
}