Skip to content

Commit

Permalink
Merge pull request #62827 from fire-forge/ok-cancel
Browse files Browse the repository at this point in the history
Add `ok_button_text` to AcceptDialog and `cancel_button_text` to ConfirmationDialog
  • Loading branch information
akien-mga committed Jul 13, 2022
2 parents dd19513 + e406706 commit b942c1f
Show file tree
Hide file tree
Showing 59 changed files with 188 additions and 149 deletions.
4 changes: 4 additions & 0 deletions doc/classes/AcceptDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
Sets autowrapping for the text in the dialog.
</member>
<member name="dialog_close_on_escape" type="bool" setter="set_close_on_escape" getter="get_close_on_escape" default="true">
If [code]true[/code], the dialog will be hidden when the escape key ([constant @GlobalScope.KEY_ESCAPE]) is pressed.
</member>
<member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" default="true">
If [code]true[/code], the dialog is hidden when the OK button is pressed. You can set it to [code]false[/code] if you want to do e.g. input validation when receiving the [signal confirmed] signal, and handle hiding the dialog in your own logic.
Expand All @@ -71,6 +72,9 @@
The text displayed by the dialog.
</member>
<member name="exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" overrides="Window" default="true" />
<member name="ok_button_text" type="String" setter="set_ok_button_text" getter="get_ok_button_text" default="&quot;OK&quot;">
The text displayed by the OK button (see [method get_ok_button]).
</member>
<member name="title" type="String" setter="set_title" getter="get_title" overrides="Window" default="&quot;Alert!&quot;" />
<member name="transient" type="bool" setter="set_transient" getter="is_transient" overrides="Window" default="true" />
<member name="visible" type="bool" setter="set_visible" getter="is_visible" overrides="Window" default="false" />
Expand Down
3 changes: 3 additions & 0 deletions doc/classes/ConfirmationDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
</method>
</methods>
<members>
<member name="cancel_button_text" type="String" setter="set_cancel_button_text" getter="get_cancel_button_text" default="&quot;Cancel&quot;">
The text displayed by the cancel button (see [method get_cancel_button]).
</member>
<member name="min_size" type="Vector2i" setter="set_min_size" getter="get_min_size" overrides="Window" default="Vector2i(200, 70)" />
<member name="size" type="Vector2i" setter="set_size" getter="get_size" overrides="Window" default="Vector2i(200, 100)" />
<member name="title" type="String" setter="set_title" getter="get_title" overrides="Window" default="&quot;Please Confirm...&quot;" />
Expand Down
1 change: 1 addition & 0 deletions doc/classes/ScriptCreateDialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
</methods>
<members>
<member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" overrides="AcceptDialog" default="false" />
<member name="ok_button_text" type="String" setter="set_ok_button_text" getter="get_ok_button_text" overrides="AcceptDialog" default="&quot;Create&quot;" />
<member name="title" type="String" setter="set_title" getter="get_title" overrides="Window" default="&quot;Attach Node Script&quot;" />
</members>
<signals>
Expand Down
8 changes: 4 additions & 4 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3696,7 +3696,7 @@ void AnimationTrackEditor::commit_insert_queue() {
insert_confirm_bezier->set_visible(all_bezier);
insert_confirm_reset->set_visible(reset_allowed);

insert_confirm->get_ok_button()->set_text(TTR("Create"));
insert_confirm->set_ok_button_text(TTR("Create"));
insert_confirm->popup_centered();
} else {
_insert_track(reset_allowed && EDITOR_GET("editors/animation/default_create_reset_tracks"), all_bezier && EDITOR_GET("editors/animation/default_create_bezier_tracks"));
Expand Down Expand Up @@ -6473,7 +6473,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
optimize_max_angle->set_step(0.1);
optimize_max_angle->set_value(22);

optimize_dialog->get_ok_button()->set_text(TTR("Optimize"));
optimize_dialog->set_ok_button_text(TTR("Optimize"));
optimize_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed), varray(EDIT_OPTIMIZE_ANIMATION_CONFIRM));

//
Expand All @@ -6498,7 +6498,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
cleanup_vb->add_child(cleanup_all);

cleanup_dialog->set_title(TTR("Clean-Up Animation(s) (NO UNDO!)"));
cleanup_dialog->get_ok_button()->set_text(TTR("Clean-Up"));
cleanup_dialog->set_ok_button_text(TTR("Clean-Up"));

cleanup_dialog->connect("confirmed", callable_mp(this, &AnimationTrackEditor::_edit_menu_pressed), varray(EDIT_CLEAN_UP_ANIMATION_CONFIRM));

Expand All @@ -6518,7 +6518,7 @@ AnimationTrackEditor::AnimationTrackEditor() {
track_copy_dialog = memnew(ConfirmationDialog);
add_child(track_copy_dialog);
track_copy_dialog->set_title(TTR("Select Tracks to Copy"));
track_copy_dialog->get_ok_button()->set_text(TTR("Copy"));
track_copy_dialog->set_ok_button_text(TTR("Copy"));

VBoxContainer *track_vbox = memnew(VBoxContainer);
track_copy_dialog->add_child(track_vbox);
Expand Down
4 changes: 2 additions & 2 deletions editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ ConnectDialog::ConnectDialog() {
error = memnew(AcceptDialog);
add_child(error);
error->set_title(TTR("Cannot connect signal"));
error->get_ok_button()->set_text(TTR("Close"));
get_ok_button()->set_text(TTR("Connect"));
error->set_ok_button_text(TTR("Close"));
set_ok_button_text(TTR("Connect"));
}

ConnectDialog::~ConnectDialog() {
Expand Down
4 changes: 2 additions & 2 deletions editor/create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void CreateDialog::popup_create(bool p_dont_clear, bool p_replace_mode, const St

if (p_replace_mode) {
set_title(vformat(TTR("Change %s Type"), base_type));
get_ok_button()->set_text(TTR("Change"));
set_ok_button_text(TTR("Change"));
} else {
set_title(vformat(TTR("Create New %s"), base_type));
get_ok_button()->set_text(TTR("Create"));
set_ok_button_text(TTR("Create"));
}

_load_favorites_and_history();
Expand Down
8 changes: 4 additions & 4 deletions editor/dependency_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ void DependencyRemoveDialog::_bind_methods() {
}

DependencyRemoveDialog::DependencyRemoveDialog() {
get_ok_button()->set_text(TTR("Remove"));
set_ok_button_text(TTR("Remove"));

VBoxContainer *vb = memnew(VBoxContainer);
add_child(vb);
Expand Down Expand Up @@ -641,8 +641,8 @@ DependencyErrorDialog::DependencyErrorDialog() {
files->set_v_size_flags(Control::SIZE_EXPAND_FILL);

set_min_size(Size2(500, 220) * EDSCALE);
get_ok_button()->set_text(TTR("Open Anyway"));
get_cancel_button()->set_text(TTR("Close"));
set_ok_button_text(TTR("Open Anyway"));
set_cancel_button_text(TTR("Close"));

text = memnew(Label);
vb->add_child(text);
Expand Down Expand Up @@ -780,7 +780,7 @@ void OrphanResourcesDialog::_bind_methods() {
OrphanResourcesDialog::OrphanResourcesDialog() {
set_title(TTR("Orphan Resource Explorer"));
delete_confirm = memnew(ConfirmationDialog);
get_ok_button()->set_text(TTR("Delete"));
set_ok_button_text(TTR("Delete"));
add_child(delete_confirm);
dep_edit = memnew(DependencyEditor);
add_child(dep_edit);
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_asset_installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ EditorAssetInstaller::EditorAssetInstaller() {

error = memnew(AcceptDialog);
add_child(error);
get_ok_button()->set_text(TTR("Install"));
set_ok_button_text(TTR("Install"));
set_title(TTR("Asset Installer"));

set_hide_on_ok(true);
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_dir_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,5 +211,5 @@ EditorDirDialog::EditorDirDialog() {
mkdirerr->set_text(TTR("Could not create folder."));
add_child(mkdirerr);

get_ok_button()->set_text(TTR("Choose"));
set_ok_button_text(TTR("Choose"));
}
2 changes: 1 addition & 1 deletion editor/editor_feature_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
add_child(new_profile_dialog);
new_profile_dialog->connect("confirmed", callable_mp(this, &EditorFeatureProfileManager::_create_new_profile));
new_profile_dialog->register_text_enter(new_profile_name);
new_profile_dialog->get_ok_button()->set_text(TTR("Create"));
new_profile_dialog->set_ok_button_text(TTR("Create"));

erase_profile_dialog = memnew(ConfirmationDialog);
add_child(erase_profile_dialog);
Expand Down
20 changes: 10 additions & 10 deletions editor/editor_file_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ void EditorFileDialog::update_dir() {
switch (mode) {
case FILE_MODE_OPEN_FILE:
case FILE_MODE_OPEN_FILES:
get_ok_button()->set_text(TTR("Open"));
set_ok_button_text(TTR("Open"));
break;
case FILE_MODE_OPEN_DIR:
get_ok_button()->set_text(TTR("Select Current Folder"));
set_ok_button_text(TTR("Select Current Folder"));
break;
case FILE_MODE_OPEN_ANY:
case FILE_MODE_SAVE_FILE:
Expand Down Expand Up @@ -507,7 +507,7 @@ void EditorFileDialog::_item_selected(int p_item) {
file->set_text(d["name"]);
_request_single_thumbnail(get_current_dir().plus_file(get_current_file()));
} else if (mode == FILE_MODE_OPEN_DIR) {
get_ok_button()->set_text(TTR("Select This Folder"));
set_ok_button_text(TTR("Select This Folder"));
}

get_ok_button()->set_disabled(_is_open_should_be_disabled());
Expand Down Expand Up @@ -540,13 +540,13 @@ void EditorFileDialog::_items_clear_selection(const Vector2 &p_pos, MouseButton
switch (mode) {
case FILE_MODE_OPEN_FILE:
case FILE_MODE_OPEN_FILES:
get_ok_button()->set_text(TTR("Open"));
set_ok_button_text(TTR("Open"));
get_ok_button()->set_disabled(!item_list->is_anything_selected());
break;

case FILE_MODE_OPEN_DIR:
get_ok_button()->set_disabled(false);
get_ok_button()->set_text(TTR("Select Current Folder"));
set_ok_button_text(TTR("Select Current Folder"));
break;

case FILE_MODE_OPEN_ANY:
Expand Down Expand Up @@ -1037,27 +1037,27 @@ void EditorFileDialog::set_file_mode(FileMode p_mode) {
mode = p_mode;
switch (mode) {
case FILE_MODE_OPEN_FILE:
get_ok_button()->set_text(TTR("Open"));
set_ok_button_text(TTR("Open"));
set_title(TTR("Open a File"));
can_create_dir = false;
break;
case FILE_MODE_OPEN_FILES:
get_ok_button()->set_text(TTR("Open"));
set_ok_button_text(TTR("Open"));
set_title(TTR("Open File(s)"));
can_create_dir = false;
break;
case FILE_MODE_OPEN_DIR:
get_ok_button()->set_text(TTR("Open"));
set_ok_button_text(TTR("Open"));
set_title(TTR("Open a Directory"));
can_create_dir = true;
break;
case FILE_MODE_OPEN_ANY:
get_ok_button()->set_text(TTR("Open"));
set_ok_button_text(TTR("Open"));
set_title(TTR("Open a File or Directory"));
can_create_dir = true;
break;
case FILE_MODE_SAVE_FILE:
get_ok_button()->set_text(TTR("Save"));
set_ok_button_text(TTR("Save"));
set_title(TTR("Save a File"));
can_create_dir = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_help_search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ EditorHelpSearch::EditorHelpSearch() {
set_title(TTR("Search Help"));

get_ok_button()->set_disabled(true);
get_ok_button()->set_text(TTR("Open"));
set_ok_button_text(TTR("Open"));

// Split search and results area.
VBoxContainer *vbox = memnew(VBoxContainer);
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3781,7 +3781,7 @@ void EditorInspector::_show_add_meta_dialog() {
add_meta_type->add_icon_item(get_theme_icon(type, "EditorIcons"), type, i);
}
hbc->add_child(add_meta_type);
add_meta_dialog->get_ok_button()->set_text(TTR("Add"));
add_meta_dialog->set_ok_button_text(TTR("Add"));
add_child(add_meta_dialog);
add_meta_dialog->register_text_enter(add_meta_name);
add_meta_dialog->connect("confirmed", callable_mp(this, &EditorInspector::_add_meta_confirm));
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_locale_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,5 +552,5 @@ EditorLocaleDialog::EditorLocaleDialog() {
add_child(vb);
_update_tree();

get_ok_button()->set_text(TTR("Select"));
set_ok_button_text(TTR("Select"));
}
Loading

0 comments on commit b942c1f

Please sign in to comment.