summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-08-18 18:24:20 +0200
committerGitHub <noreply@github.com>2020-08-18 18:24:20 +0200
commit65730ab9f6fbae34bb161113161b43f8b3fcd4d2 (patch)
tree144d54c6ea9637a98fd52061db8c5818c69c6dfe /editor
parentf97280a0127950f5ae7d2e38f239ab9633afb041 (diff)
parent8f54e8bfb54512b55de72047683ffc42ba64d748 (diff)
Merge pull request #41247 from EricEzaM/project-settings-fix-bugs-and-add-delete-confirmation
Fixed issues with adding custom project settings and added confirmation dialog when deleting settings.
Diffstat (limited to 'editor')
-rw-r--r--editor/project_settings_editor.cpp14
-rw-r--r--editor/project_settings_editor.h4
2 files changed, 15 insertions, 3 deletions
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 89feb436d8..82ac225ddb 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -113,11 +113,17 @@ void ProjectSettingsEditor::_add_setting() {
inspector->set_current_section(setting.get_slice("/", 1));
}
-void ProjectSettingsEditor::_delete_setting() {
+void ProjectSettingsEditor::_delete_setting(bool p_confirmed) {
String setting = _get_setting_name();
Variant value = ps->get(setting);
int order = ps->get_order(setting);
+ if (!p_confirmed) {
+ del_confirmation->set_text(vformat(TTR("Are you sure you want to delete '%s'?"), setting));
+ del_confirmation->popup_centered();
+ return;
+ }
+
undo_redo->create_action(TTR("Delete Item"));
undo_redo->add_do_method(ps, "clear", setting);
@@ -394,7 +400,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
del_button = memnew(Button);
del_button->set_flat(true);
- del_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_delete_setting));
+ del_button->connect("pressed", callable_mp(this, &ProjectSettingsEditor::_delete_setting), varray(false));
hbc->add_child(del_button);
error_label = memnew(Label);
@@ -466,6 +472,10 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
timer->set_one_shot(true);
add_child(timer);
+ del_confirmation = memnew(ConfirmationDialog);
+ del_confirmation->connect("confirmed", callable_mp(this, &ProjectSettingsEditor::_delete_setting), varray(true));
+ add_child(del_confirmation);
+
get_ok()->set_text(TTR("Close"));
set_hide_on_ok(true);
}
diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h
index 0d7e19b242..4ecd28e514 100644
--- a/editor/project_settings_editor.h
+++ b/editor/project_settings_editor.h
@@ -77,6 +77,8 @@ class ProjectSettingsEditor : public AcceptDialog {
OptionButton *feature_override;
Label *error_label;
+ ConfirmationDialog *del_confirmation;
+
Label *restart_label;
TextureRect *restart_icon;
PanelContainer *restart_container;
@@ -94,7 +96,7 @@ class ProjectSettingsEditor : public AcceptDialog {
void _setting_edited(const String &p_name);
void _setting_selected(const String &p_path);
void _add_setting();
- void _delete_setting();
+ void _delete_setting(bool p_confirmed);
void _editor_restart_request();
void _editor_restart();