Consolidate remembering window settings into single config

This commit is contained in:
Brandon Chang 2024-09-22 13:36:41 -04:00 committed by Rémi Verschelde
parent e3213aaef5
commit e0957c2fa3
No known key found for this signature in database
GPG Key ID: C3336907360768E1
4 changed files with 22 additions and 17 deletions

View File

@ -772,7 +772,7 @@
Translations are provided by the community. If you spot a mistake, [url=$DOCS_URL/contributing/documentation/editor_and_docs_localization.html]contribute to editor translations on Weblate![/url]
</member>
<member name="interface/editor/editor_screen" type="int" setter="" getter="">
The preferred monitor to display the editor.
The preferred monitor to display the editor. If [b]Auto[/b], the editor will remember the last screen it was displayed on across restarts.
</member>
<member name="interface/editor/expand_to_title" type="bool" setter="" getter="">
Expanding main editor window content to the title, if supported by [DisplayServer]. See [constant DisplayServer.WINDOW_FLAG_EXTEND_TO_TITLE].
@ -826,9 +826,6 @@
<member name="interface/editor/project_manager_screen" type="int" setter="" getter="">
The preferred monitor to display the project manager.
</member>
<member name="interface/editor/remember_window_size_and_position" type="bool" setter="" getter="">
If [code]true[/code], the editor window will remember its size, position, and which screen it was displayed on across restarts.
</member>
<member name="interface/editor/save_each_scene_on_quit" type="bool" setter="" getter="">
If [code]false[/code], the editor will save all scenes when confirming the [b]Save[/b] action when quitting the editor or quitting to the project list. If [code]true[/code], the editor will ask to save each scene individually.
</member>

View File

@ -426,12 +426,17 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING_USAGE(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/display_scale", 0, display_scale_hint_string, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED | PROPERTY_USAGE_EDITOR_BASIC_SETTING)
EDITOR_SETTING_USAGE(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/editor/custom_display_scale", 1.0, "0.5,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED | PROPERTY_USAGE_EDITOR_BASIC_SETTING)
String ed_screen_hints = "Screen With Mouse Pointer:-4,Screen With Keyboard Focus:-3,Primary Screen:-2"; // Note: Main Window Screen:-1 is not used for the main window.
String ed_screen_hints = "Auto (Remembers last position):-5,Screen With Mouse Pointer:-4,Screen With Keyboard Focus:-3,Primary Screen:-2";
for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) {
ed_screen_hints += ",Screen " + itos(i + 1) + ":" + itos(i);
}
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/editor_screen", -2, ed_screen_hints)
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/project_manager_screen", -2, ed_screen_hints)
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/editor_screen", EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO, ed_screen_hints)
String project_manager_screen_hints = "Screen With Mouse Pointer:-4,Screen With Keyboard Focus:-3,Primary Screen:-2";
for (int i = 0; i < DisplayServer::get_singleton()->get_screen_count(); i++) {
project_manager_screen_hints += ",Screen " + itos(i + 1) + ":" + itos(i);
}
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/editor/project_manager_screen", EditorSettings::InitialScreen::INITIAL_SCREEN_PRIMARY, project_manager_screen_hints)
{
EngineUpdateLabel::UpdateMode default_update_mode = EngineUpdateLabel::UpdateMode::NEWEST_UNSTABLE;
@ -466,7 +471,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/editor/separate_distraction_mode", false, true);
_initial_set("interface/editor/automatically_open_screenshots", true, true);
EDITOR_SETTING_USAGE(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/single_window_mode", false, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED | PROPERTY_USAGE_EDITOR_BASIC_SETTING)
_initial_set("interface/editor/remember_window_size_and_position", true, true);
_initial_set("interface/editor/mouse_extra_buttons_navigate_history", true);
_initial_set("interface/editor/save_each_scene_on_quit", true, true); // Regression
EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/save_on_focus_loss", false, "")

View File

@ -62,6 +62,13 @@ public:
NETWORK_ONLINE,
};
enum InitialScreen {
INITIAL_SCREEN_AUTO = -5, // Remembers last screen position.
INITIAL_SCREEN_WITH_MOUSE_FOCUS = -4,
INITIAL_SCREEN_WITH_KEYBOARD_FOCUS = -3,
INITIAL_SCREEN_PRIMARY = -2,
};
private:
struct VariantContainer {
int order = 0;

View File

@ -2755,7 +2755,6 @@ Error Main::setup2(bool p_show_boot_logo) {
bool prefer_wayland_found = false;
bool prefer_wayland = false;
bool remember_window_size_and_position_found = false;
if (editor) {
screen_property = "interface/editor/editor_screen";
@ -2771,7 +2770,7 @@ Error Main::setup2(bool p_show_boot_logo) {
prefer_wayland_found = true;
}
while (!screen_found || !prefer_wayland_found || !remember_window_size_and_position_found) {
while (!screen_found || !prefer_wayland_found) {
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();
@ -2785,17 +2784,16 @@ Error Main::setup2(bool p_show_boot_logo) {
if (!screen_found && assign == screen_property) {
init_screen = value;
screen_found = true;
if (editor) {
restore_editor_window_layout = value.operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO;
}
}
if (!prefer_wayland_found && assign == "run/platforms/linuxbsd/prefer_wayland") {
prefer_wayland = value;
prefer_wayland_found = true;
}
if (!remember_window_size_and_position_found && assign == "interface/editor/remember_window_size_and_position") {
restore_editor_window_layout = value;
remember_window_size_and_position_found = true;
}
}
}
@ -4095,8 +4093,7 @@ int Main::start() {
if (editor_embed_subwindows) {
sml->get_root()->set_embedding_subwindows(true);
}
restore_editor_window_layout = EditorSettings::get_singleton()->get_setting(
"interface/editor/remember_window_size_and_position");
restore_editor_window_layout = EditorSettings::get_singleton()->get_setting("interface/editor/editor_screen").operator int() == EditorSettings::InitialScreen::INITIAL_SCREEN_AUTO;
}
#endif