2
0
mirror of https://github.com/godotengine/godot.git synced 2025-04-25 01:48:08 +08:00

Make swap_cancel_ok setting 3-state instead of boolean.

This commit is contained in:
Pāvels Nadtočajevs 2025-04-03 11:09:37 +03:00
parent 1f56d96cf2
commit 2f8b96e8a2
No known key found for this signature in database
GPG Key ID: 8413210218EF35D2
5 changed files with 20 additions and 9 deletions

@ -805,7 +805,7 @@
</member>
<member name="interface/editor/accept_dialog_cancel_ok_buttons" type="int" setter="" getter="">
How to position the Cancel and OK buttons in the editor's [AcceptDialog]s. Different platforms have different standard behaviors for this, which can be overridden using this setting. This is useful if you use Godot both on Windows and macOS/Linux and your Godot muscle memory is stronger than your OS specific one.
- [b]Auto[/b] follows the platform convention: Cancel first on macOS and Linux, OK first on Windows.
- [b]Auto[/b] follows the platform convention: OK first on Windows, KDE, and LXQt, Cancel first on macOS and other Linux desktop environments.
- [b]Cancel First[/b] forces the ordering Cancel/OK.
- [b]OK First[/b] forces the ordering OK/Cancel.
</member>

@ -1125,8 +1125,11 @@
<member name="gui/common/snap_controls_to_pixels" type="bool" setter="" getter="" default="true">
If [code]true[/code], snaps [Control] node vertices to the nearest pixel to ensure they remain crisp even when the camera moves or zooms.
</member>
<member name="gui/common/swap_cancel_ok" type="bool" setter="" getter="">
If [code]true[/code], swaps [b]Cancel[/b] and [b]OK[/b] buttons in dialogs on Windows to follow interface conventions. [method DisplayServer.get_swap_cancel_ok] can be used to query whether buttons are swapped at run-time.
<member name="gui/common/swap_cancel_ok" type="int" setter="" getter="" default="0">
How to position the Cancel and OK buttons in the project's [AcceptDialog]s. Different platforms have different standard behaviors for this, which can be overridden using this setting.
- [b]Auto[/b] ([code]0[/code]) follows the platform convention: OK first on Windows, KDE, and LXQt, Cancel first on macOS and other Linux desktop environments. [method DisplayServer.get_swap_cancel_ok] can be used to query whether buttons are swapped at run-time.
- [b]Cancel First[/b] ([code]1[/code]) forces the ordering Cancel/OK.
- [b]OK First[/b] ([code]2[/code]) forces the ordering OK/Cancel.
[b]Note:[/b] This doesn't affect native dialogs such as the ones spawned by [method DisplayServer.dialog_show].
</member>
<member name="gui/common/text_edit_undo_stack_max_size" type="int" setter="" getter="" default="1024">

@ -1630,7 +1630,11 @@ ProjectManager::ProjectManager() {
ask_update_settings = memnew(ConfirmationDialog);
ask_update_settings->set_autowrap(true);
ask_update_settings->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_open_selected_projects_with_migration));
full_convert_button = ask_update_settings->add_button(TTR("Convert Full Project"), !GLOBAL_GET("gui/common/swap_cancel_ok"));
int ed_swap_cancel_ok = EDITOR_GET("interface/editor/accept_dialog_cancel_ok_buttons");
if (ed_swap_cancel_ok == 0) {
ed_swap_cancel_ok = DisplayServer::get_singleton()->get_swap_cancel_ok() ? 2 : 1;
}
full_convert_button = ask_update_settings->add_button(TTR("Convert Full Project"), ed_swap_cancel_ok != 2);
full_convert_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_full_convert_button_pressed));
add_child(ask_update_settings);

@ -192,7 +192,11 @@ void QuickSettingsDialog::_set_setting_value(const String &p_setting, const Vari
restart_required_label->show();
if (!restart_required_button) {
restart_required_button = add_button(TTR("Restart Now"), !GLOBAL_GET("gui/common/swap_cancel_ok"));
int ed_swap_cancel_ok = EDITOR_GET("interface/editor/accept_dialog_cancel_ok_buttons");
if (ed_swap_cancel_ok == 0) {
ed_swap_cancel_ok = DisplayServer::get_singleton()->get_swap_cancel_ok() ? 2 : 1;
}
restart_required_button = add_button(TTR("Restart Now"), ed_swap_cancel_ok != 2);
restart_required_button->connect(SceneStringName(pressed), callable_mp(this, &QuickSettingsDialog::_request_restart));
}
}

@ -521,11 +521,11 @@ void register_scene_types() {
OS::get_singleton()->yield(); // may take time to init
bool swap_cancel_ok = false;
if (DisplayServer::get_singleton()) {
swap_cancel_ok = GLOBAL_DEF_NOVAL("gui/common/swap_cancel_ok", bool(DisplayServer::get_singleton()->get_swap_cancel_ok()));
int swap_cancel_ok = GLOBAL_DEF(PropertyInfo(Variant::INT, "gui/common/swap_cancel_ok", PROPERTY_HINT_ENUM, "Auto,Cancel First,OK First"), 0);
if (DisplayServer::get_singleton() && swap_cancel_ok == 0) {
swap_cancel_ok = DisplayServer::get_singleton()->get_swap_cancel_ok() ? 2 : 1;
}
AcceptDialog::set_swap_cancel_ok(swap_cancel_ok);
AcceptDialog::set_swap_cancel_ok(swap_cancel_ok == 2);
#endif
int root_dir = GLOBAL_GET("internationalization/rendering/root_node_layout_direction");