3030
3131#include " history_dock.h"
3232
33+ #include " core/io/config_file.h"
3334#include " editor/editor_node.h"
3435#include " editor/editor_settings.h"
3536#include " editor/editor_string_names.h"
@@ -172,6 +173,17 @@ void HistoryDock::refresh_version() {
172173 action_list->set_current (idx);
173174}
174175
176+ void HistoryDock::_save_layout_to_config (Ref<ConfigFile> p_layout, const String &p_section) const {
177+ p_layout->set_value (p_section, " dock_history_include_scene" , current_scene_checkbox->is_pressed ());
178+ p_layout->set_value (p_section, " dock_history_include_global" , global_history_checkbox->is_pressed ());
179+ }
180+
181+ void HistoryDock::_load_layout_from_config (Ref<ConfigFile> p_layout, const String &p_section) {
182+ current_scene_checkbox->set_pressed_no_signal (p_layout->get_value (p_section, " dock_history_include_scene" , true ));
183+ global_history_checkbox->set_pressed_no_signal (p_layout->get_value (p_section, " dock_history_include_global" , true ));
184+ refresh_history ();
185+ }
186+
175187void HistoryDock::seek_history (int p_index) {
176188 bool include_scene = current_scene_checkbox->is_pressed ();
177189 bool include_global = global_history_checkbox->is_pressed ();
@@ -220,9 +232,9 @@ void HistoryDock::_notification(int p_notification) {
220232 }
221233}
222234
223- void HistoryDock::save_options () {
224- EditorSettings::get_singleton ()-> set_project_metadata ( " history " , " include_scene " , current_scene_checkbox-> is_pressed () );
225- EditorSettings::get_singleton ()-> set_project_metadata ( " history " , " include_global " , global_history_checkbox-> is_pressed () );
235+ void HistoryDock::_bind_methods () {
236+ ClassDB::bind_method ( D_METHOD ( " _save_layout_to_config " ), &HistoryDock::_save_layout_to_config );
237+ ClassDB::bind_method ( D_METHOD ( " _load_layout_from_config " ), &HistoryDock::_load_layout_from_config );
226238}
227239
228240HistoryDock::HistoryDock () {
@@ -235,28 +247,21 @@ HistoryDock::HistoryDock() {
235247 HBoxContainer *mode_hb = memnew (HBoxContainer);
236248 add_child (mode_hb);
237249
238- bool include_scene = EditorSettings::get_singleton ()->get_project_metadata (" history" , " include_scene" , true );
239- bool include_global = EditorSettings::get_singleton ()->get_project_metadata (" history" , " include_global" , true );
240-
241250 current_scene_checkbox = memnew (CheckBox);
242251 mode_hb->add_child (current_scene_checkbox);
243252 current_scene_checkbox->set_flat (true );
244- current_scene_checkbox->set_pressed (include_scene);
245253 current_scene_checkbox->set_text (TTR (" Scene" ));
246254 current_scene_checkbox->set_h_size_flags (SIZE_EXPAND_FILL);
247255 current_scene_checkbox->set_clip_text (true );
248256 current_scene_checkbox->connect (SceneStringName (toggled), callable_mp (this , &HistoryDock::refresh_history).unbind (1 ));
249- current_scene_checkbox->connect (SceneStringName (toggled), callable_mp (this , &HistoryDock::save_options).unbind (1 ));
250257
251258 global_history_checkbox = memnew (CheckBox);
252259 mode_hb->add_child (global_history_checkbox);
253260 global_history_checkbox->set_flat (true );
254- global_history_checkbox->set_pressed (include_global);
255261 global_history_checkbox->set_text (TTR (" Global" ));
256262 global_history_checkbox->set_h_size_flags (SIZE_EXPAND_FILL);
257263 global_history_checkbox->set_clip_text (true );
258264 global_history_checkbox->connect (SceneStringName (toggled), callable_mp (this , &HistoryDock::refresh_history).unbind (1 ));
259- global_history_checkbox->connect (SceneStringName (toggled), callable_mp (this , &HistoryDock::save_options).unbind (1 ));
260265
261266 action_list = memnew (ItemList);
262267 action_list->set_auto_translate_mode (AUTO_TRANSLATE_MODE_DISABLED);
0 commit comments