Fix favorite files handling
This commit is contained in:
@@ -1595,13 +1595,11 @@ void EditorSettings::save_project_metadata() {
|
||||
}
|
||||
|
||||
void EditorSettings::set_favorites(const Vector<String> &p_favorites, bool p_update_file_dialog) {
|
||||
if (p_update_file_dialog) {
|
||||
FileDialog::set_favorite_list(p_favorites);
|
||||
} else if (p_favorites == favorites) {
|
||||
// If the list came from EditorFileDialog, it may be the same as before.
|
||||
return;
|
||||
}
|
||||
set_favorites_bind(p_favorites);
|
||||
if (p_update_file_dialog) {
|
||||
FileDialog::set_favorite_list(get_favorite_folders());
|
||||
}
|
||||
emit_signal(SNAME("_favorites_changed"));
|
||||
}
|
||||
|
||||
void EditorSettings::set_favorites_bind(const Vector<String> &p_favorites) {
|
||||
@@ -1636,6 +1634,22 @@ Vector<String> EditorSettings::get_favorites() const {
|
||||
return favorites;
|
||||
}
|
||||
|
||||
Vector<String> EditorSettings::get_favorite_folders() const {
|
||||
Vector<String> folder_favorites;
|
||||
folder_favorites.resize(favorites.size());
|
||||
String *folder_write = folder_favorites.ptrw();
|
||||
|
||||
int i = 0;
|
||||
for (const String &fav : favorites) {
|
||||
if (fav.ends_with("/")) {
|
||||
folder_write[i] = fav;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
folder_favorites.resize(i);
|
||||
return folder_favorites;
|
||||
}
|
||||
|
||||
HashMap<String, PackedStringArray> EditorSettings::get_favorite_properties() const {
|
||||
return favorite_properties;
|
||||
}
|
||||
@@ -1643,9 +1657,6 @@ HashMap<String, PackedStringArray> EditorSettings::get_favorite_properties() con
|
||||
void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs, bool p_update_file_dialog) {
|
||||
if (p_update_file_dialog) {
|
||||
FileDialog::set_recent_list(p_recent_dirs);
|
||||
} else if (p_recent_dirs == recent_dirs) {
|
||||
// If the list came from EditorFileDialog, it may be the same as before.
|
||||
return;
|
||||
}
|
||||
set_recent_dirs_bind(p_recent_dirs);
|
||||
}
|
||||
@@ -1694,7 +1705,7 @@ void EditorSettings::load_favorites_and_recent_dirs() {
|
||||
line = f->get_line().strip_edges();
|
||||
}
|
||||
}
|
||||
FileDialog::set_favorite_list(favorites);
|
||||
FileDialog::set_favorite_list(get_favorite_folders());
|
||||
|
||||
/// Inspector Favorites
|
||||
|
||||
@@ -2282,6 +2293,7 @@ void EditorSettings::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("mark_setting_changed", "setting"), &EditorSettings::mark_setting_changed);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("settings_changed"));
|
||||
ADD_SIGNAL(MethodInfo("_favorites_changed"));
|
||||
|
||||
BIND_CONSTANT(NOTIFICATION_EDITOR_SETTINGS_CHANGED);
|
||||
}
|
||||
|
||||
@@ -180,6 +180,7 @@ public:
|
||||
void set_favorites(const Vector<String> &p_favorites, bool p_update_file_dialog = true);
|
||||
void set_favorites_bind(const Vector<String> &p_favorites);
|
||||
Vector<String> get_favorites() const;
|
||||
Vector<String> get_favorite_folders() const;
|
||||
void set_favorite_properties(const HashMap<String, PackedStringArray> &p_favorite_properties);
|
||||
HashMap<String, PackedStringArray> get_favorite_properties() const;
|
||||
void set_recent_dirs(const Vector<String> &p_recent_dirs, bool p_update_file_dialog = true);
|
||||
|
||||
Reference in New Issue
Block a user