Skip to content

Commit 2f8b96e

Browse files
committed
Make swap_cancel_ok setting 3-state instead of boolean.
1 parent 1f56d96 commit 2f8b96e

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

doc/classes/EditorSettings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@
805805
</member>
806806
<member name="interface/editor/accept_dialog_cancel_ok_buttons" type="int" setter="" getter="">
807807
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.
808-
- [b]Auto[/b] follows the platform convention: Cancel first on macOS and Linux, OK first on Windows.
808+
- [b]Auto[/b] follows the platform convention: OK first on Windows, KDE, and LXQt, Cancel first on macOS and other Linux desktop environments.
809809
- [b]Cancel First[/b] forces the ordering Cancel/OK.
810810
- [b]OK First[/b] forces the ordering OK/Cancel.
811811
</member>

doc/classes/ProjectSettings.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,11 @@
11251125
<member name="gui/common/snap_controls_to_pixels" type="bool" setter="" getter="" default="true">
11261126
If [code]true[/code], snaps [Control] node vertices to the nearest pixel to ensure they remain crisp even when the camera moves or zooms.
11271127
</member>
1128-
<member name="gui/common/swap_cancel_ok" type="bool" setter="" getter="">
1129-
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.
1128+
<member name="gui/common/swap_cancel_ok" type="int" setter="" getter="" default="0">
1129+
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.
1130+
- [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.
1131+
- [b]Cancel First[/b] ([code]1[/code]) forces the ordering Cancel/OK.
1132+
- [b]OK First[/b] ([code]2[/code]) forces the ordering OK/Cancel.
11301133
[b]Note:[/b] This doesn't affect native dialogs such as the ones spawned by [method DisplayServer.dialog_show].
11311134
</member>
11321135
<member name="gui/common/text_edit_undo_stack_max_size" type="int" setter="" getter="" default="1024">

editor/project_manager.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,11 @@ ProjectManager::ProjectManager() {
16301630
ask_update_settings = memnew(ConfirmationDialog);
16311631
ask_update_settings->set_autowrap(true);
16321632
ask_update_settings->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_open_selected_projects_with_migration));
1633-
full_convert_button = ask_update_settings->add_button(TTR("Convert Full Project"), !GLOBAL_GET("gui/common/swap_cancel_ok"));
1633+
int ed_swap_cancel_ok = EDITOR_GET("interface/editor/accept_dialog_cancel_ok_buttons");
1634+
if (ed_swap_cancel_ok == 0) {
1635+
ed_swap_cancel_ok = DisplayServer::get_singleton()->get_swap_cancel_ok() ? 2 : 1;
1636+
}
1637+
full_convert_button = ask_update_settings->add_button(TTR("Convert Full Project"), ed_swap_cancel_ok != 2);
16341638
full_convert_button->connect(SceneStringName(pressed), callable_mp(this, &ProjectManager::_full_convert_button_pressed));
16351639
add_child(ask_update_settings);
16361640

editor/project_manager/quick_settings_dialog.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ void QuickSettingsDialog::_set_setting_value(const String &p_setting, const Vari
192192
restart_required_label->show();
193193

194194
if (!restart_required_button) {
195-
restart_required_button = add_button(TTR("Restart Now"), !GLOBAL_GET("gui/common/swap_cancel_ok"));
195+
int ed_swap_cancel_ok = EDITOR_GET("interface/editor/accept_dialog_cancel_ok_buttons");
196+
if (ed_swap_cancel_ok == 0) {
197+
ed_swap_cancel_ok = DisplayServer::get_singleton()->get_swap_cancel_ok() ? 2 : 1;
198+
}
199+
restart_required_button = add_button(TTR("Restart Now"), ed_swap_cancel_ok != 2);
196200
restart_required_button->connect(SceneStringName(pressed), callable_mp(this, &QuickSettingsDialog::_request_restart));
197201
}
198202
}

scene/register_scene_types.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,11 @@ void register_scene_types() {
521521

522522
OS::get_singleton()->yield(); // may take time to init
523523

524-
bool swap_cancel_ok = false;
525-
if (DisplayServer::get_singleton()) {
526-
swap_cancel_ok = GLOBAL_DEF_NOVAL("gui/common/swap_cancel_ok", bool(DisplayServer::get_singleton()->get_swap_cancel_ok()));
524+
int swap_cancel_ok = GLOBAL_DEF(PropertyInfo(Variant::INT, "gui/common/swap_cancel_ok", PROPERTY_HINT_ENUM, "Auto,Cancel First,OK First"), 0);
525+
if (DisplayServer::get_singleton() && swap_cancel_ok == 0) {
526+
swap_cancel_ok = DisplayServer::get_singleton()->get_swap_cancel_ok() ? 2 : 1;
527527
}
528-
AcceptDialog::set_swap_cancel_ok(swap_cancel_ok);
528+
AcceptDialog::set_swap_cancel_ok(swap_cancel_ok == 2);
529529
#endif
530530

531531
int root_dir = GLOBAL_GET("internationalization/rendering/root_node_layout_direction");

0 commit comments

Comments
 (0)