Add a "save on focus loss" editor setting (disabled by default)

This performs a Ctrl + S action every time the editor window loses focus,
saving both scenes and scripts as needed.

(cherry picked from commit f10c30a9ed)
This commit is contained in:
Hugo Locurcio 2021-04-11 15:39:31 +02:00 committed by Rémi Verschelde
parent 7991d0fb22
commit 415c1ccaaa
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -515,7 +515,7 @@ void EditorNode::_notification(int p_what) {
} break;
case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
// Restore the original FPS cap after focusing back on the editor
// Restore the original FPS cap after focusing back on the editor.
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/low_processor_mode_sleep_usec")));
EditorFileSystem::get_singleton()->scan_changes();
@ -523,7 +523,12 @@ void EditorNode::_notification(int p_what) {
} break;
case MainLoop::NOTIFICATION_WM_FOCUS_OUT: {
// Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused
// Save on focus loss before applying the FPS limit to avoid slowing down the saving process.
if (EDITOR_GET("interface/editor/save_on_focus_loss")) {
_menu_option_confirm(FILE_SAVE_SCENE, false);
}
// Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused.
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec")));
} break;
@ -5833,6 +5838,7 @@ EditorNode::EditorNode() {
EDITOR_DEF("run/output/always_open_output_on_play", true);
EDITOR_DEF("run/output/always_close_output_on_stop", true);
EDITOR_DEF("run/auto_save/save_before_running", true);
EDITOR_DEF("interface/editor/save_on_focus_loss", false);
EDITOR_DEF_RST("interface/editor/save_each_scene_on_quit", true);
EDITOR_DEF("interface/editor/quit_confirmation", true);
EDITOR_DEF("interface/editor/show_update_spinner", false);