From 41aa3cbd67a5ff1af4e689482d314ccb5b8cadc0 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 12 Jan 2024 12:56:23 +0100 Subject: [PATCH] Removed the delete file option from the editor's text editor module. --- .../text_editor/text_file_editor.cpp | 53 ------------------- editor_modules/text_editor/text_file_editor.h | 7 +-- 2 files changed, 2 insertions(+), 58 deletions(-) diff --git a/editor_modules/text_editor/text_file_editor.cpp b/editor_modules/text_editor/text_file_editor.cpp index d18679ed8..f03398484 100644 --- a/editor_modules/text_editor/text_file_editor.cpp +++ b/editor_modules/text_editor/text_file_editor.cpp @@ -73,10 +73,6 @@ void TextFileEditor::create_selected_file() { file_list->set_mode(FileDialog::MODE_SAVE_FILE); file_list->set_title("Create a new File"); - if (file_list->is_connected("file_selected", this, "delete_file")) { - file_list->disconnect("file_selected", this, "delete_file"); - } - if (file_list->is_connected("file_selected", this, "open_file")) { file_list->disconnect("file_selected", this, "open_file"); } @@ -94,10 +90,6 @@ void TextFileEditor::open_selected_file() { file_list->set_mode(FileDialog::MODE_OPEN_FILE); file_list->set_title("Select a File you want to edit"); - if (file_list->is_connected("file_selected", this, "delete_file")) { - file_list->disconnect("file_selected", this, "delete_file"); - } - if (file_list->is_connected("file_selected", this, "create_new_file")) { file_list->disconnect("file_selected", this, "create_new_file"); } @@ -109,37 +101,12 @@ void TextFileEditor::open_selected_file() { open_file_list(); } -void TextFileEditor::delete_selected_file() { - update_list(); - - file_list->set_mode(FileDialog::MODE_OPEN_FILES); - file_list->set_title("Select one or more Files you want to delete"); - - if (file_list->is_connected("file_selected", this, "open_file")) { - file_list->disconnect("file_selected", this, "open_file"); - } - - if (file_list->is_connected("file_selected", this, "create_new_file")) { - file_list->disconnect("file_selected", this, "create_new_file"); - } - - if (!file_list->is_connected("files_selected", this, "delete_file")) { - file_list->connect("files_selected", this, "delete_file"); - } - - open_file_list(); -} - void TextFileEditor::save_current_file_as() { update_list(); file_list->set_mode(FileDialog::MODE_SAVE_FILE); file_list->set_title("Save this File as..."); - if (file_list->is_connected("file_selected", this, "delete_file")) { - file_list->disconnect("file_selected", this, "delete_file"); - } - if (file_list->is_connected("file_selected", this, "open_file")) { file_list->disconnect("file_selected", this, "open_file"); } @@ -177,9 +144,6 @@ void TextFileEditor::_on_file_btn_pressed(const int index) { save_current_file_as(); } } break; - case FILE_MENU_OPTION_DELETE: { - delete_selected_file(); - } break; case FILE_MENU_OPTION_SEARCH: { current_editor->open_search_box(); } break; @@ -368,15 +332,6 @@ void TextFileEditor::_on_update_file() { current_editor->new_file_open(current_content, last_modified, current_file_path); } -void TextFileEditor::delete_file(const PoolStringArray &files_selected) { - for (int i = 0; i < files_selected.size(); ++i) { - String file = files_selected[i]; - DirAccess::remove_file_or_error(file); - } - - update_list(); -} - void TextFileEditor::open_new_file_dialogue() { new_file_dialogue->popup(); new_file_dialogue->set_position(OS::get_singleton()->get_screen_size() / 2 - new_file_dialogue->get_size() / 2); @@ -613,12 +568,6 @@ TextFileEditor::TextFileEditor() { hotkey->set_alt(true); file_btn_popup->add_item("Save File as...", FILE_MENU_OPTION_SAVE_AS, hotkey->get_scancode_with_modifiers()); - //hotkey = InputEventKey.new(); - //hotkey.scancode = KEY_D; - //hotkey.control = true; - //file_btn_popup.add_item("Delete File", FileMenuOptions.FILE_MENU_OPTION_DELETE, hotkey.get_scancode_with_modifiers()); - file_btn_popup->add_item("Delete File", FILE_MENU_OPTION_DELETE); - file_btn_popup->add_separator(); hotkey.instance(); @@ -789,7 +738,6 @@ void TextFileEditor::_bind_methods() { //ClassDB::bind_method(D_METHOD("connect_signals"), &TextFileEditor::connect_signals); //ClassDB::bind_method(D_METHOD("create_selected_file"), &TextFileEditor::create_selected_file); //ClassDB::bind_method(D_METHOD("open_selected_file"), &TextFileEditor::open_selected_file); - // ClassDB::bind_method(D_METHOD("delete_selected_file"), &TextFileEditor::delete_selected_file); //ClassDB::bind_method(D_METHOD("save_current_file_as"), &TextFileEditor::save_current_file_as); ClassDB::bind_method(D_METHOD("_on_file_btn_pressed", "index"), &TextFileEditor::_on_file_btn_pressed); @@ -806,7 +754,6 @@ void TextFileEditor::_bind_methods() { //ClassDB::bind_method(D_METHOD("confirm_close", "index"), &TextFileEditor::confirm_close); ClassDB::bind_method(D_METHOD("_on_update_file"), &TextFileEditor::_on_update_file); - ClassDB::bind_method(D_METHOD("delete_file", "files_selected"), &TextFileEditor::delete_file); //ClassDB::bind_method(D_METHOD("open_new_file_dialogue"), &TextFileEditor::open_new_file_dialogue); //ClassDB::bind_method(D_METHOD("open_file_list"), &TextFileEditor::open_file_list); ClassDB::bind_method(D_METHOD("create_new_file", "given_path"), &TextFileEditor::create_new_file); diff --git a/editor_modules/text_editor/text_file_editor.h b/editor_modules/text_editor/text_file_editor.h index b80b91fd8..1ee06f1f6 100644 --- a/editor_modules/text_editor/text_file_editor.h +++ b/editor_modules/text_editor/text_file_editor.h @@ -63,16 +63,14 @@ public: FILE_MENU_OPTION_CLOSE = 2, FILE_MENU_OPTION_SAVE = 3, FILE_MENU_OPTION_SAVE_AS = 4, - FILE_MENU_OPTION_DELETE = 5, - FILE_MENU_OPTION_SEARCH = 6, - FILE_MENU_OPTION_REPLACE = 7, + FILE_MENU_OPTION_SEARCH = 5, + FILE_MENU_OPTION_REPLACE = 6, }; void connect_signals(); void create_selected_file(); void open_selected_file(); - void delete_selected_file(); void save_current_file_as(); void _on_file_btn_pressed(const int index); @@ -89,7 +87,6 @@ public: void _on_update_file(); - void delete_file(const PoolStringArray &files_selected); void open_new_file_dialogue(); void open_file_list(); void create_new_file(const String &given_path);