Removed the delete file option from the editor's text editor module.

This commit is contained in:
Relintai 2024-01-12 12:56:23 +01:00
parent 929461fb08
commit 41aa3cbd67
2 changed files with 2 additions and 58 deletions

View File

@ -73,10 +73,6 @@ void TextFileEditor::create_selected_file() {
file_list->set_mode(FileDialog::MODE_SAVE_FILE); file_list->set_mode(FileDialog::MODE_SAVE_FILE);
file_list->set_title("Create a new 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")) { if (file_list->is_connected("file_selected", this, "open_file")) {
file_list->disconnect("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_mode(FileDialog::MODE_OPEN_FILE);
file_list->set_title("Select a File you want to edit"); 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")) { if (file_list->is_connected("file_selected", this, "create_new_file")) {
file_list->disconnect("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(); 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() { void TextFileEditor::save_current_file_as() {
update_list(); update_list();
file_list->set_mode(FileDialog::MODE_SAVE_FILE); file_list->set_mode(FileDialog::MODE_SAVE_FILE);
file_list->set_title("Save this File as..."); 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")) { if (file_list->is_connected("file_selected", this, "open_file")) {
file_list->disconnect("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(); save_current_file_as();
} }
} break; } break;
case FILE_MENU_OPTION_DELETE: {
delete_selected_file();
} break;
case FILE_MENU_OPTION_SEARCH: { case FILE_MENU_OPTION_SEARCH: {
current_editor->open_search_box(); current_editor->open_search_box();
} break; } break;
@ -368,15 +332,6 @@ void TextFileEditor::_on_update_file() {
current_editor->new_file_open(current_content, last_modified, current_file_path); 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() { void TextFileEditor::open_new_file_dialogue() {
new_file_dialogue->popup(); new_file_dialogue->popup();
new_file_dialogue->set_position(OS::get_singleton()->get_screen_size() / 2 - new_file_dialogue->get_size() / 2); 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); hotkey->set_alt(true);
file_btn_popup->add_item("Save File as...", FILE_MENU_OPTION_SAVE_AS, hotkey->get_scancode_with_modifiers()); 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(); file_btn_popup->add_separator();
hotkey.instance(); 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("connect_signals"), &TextFileEditor::connect_signals);
//ClassDB::bind_method(D_METHOD("create_selected_file"), &TextFileEditor::create_selected_file); //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("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("save_current_file_as"), &TextFileEditor::save_current_file_as);
ClassDB::bind_method(D_METHOD("_on_file_btn_pressed", "index"), &TextFileEditor::_on_file_btn_pressed); 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("confirm_close", "index"), &TextFileEditor::confirm_close);
ClassDB::bind_method(D_METHOD("_on_update_file"), &TextFileEditor::_on_update_file); 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_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("open_file_list"), &TextFileEditor::open_file_list);
ClassDB::bind_method(D_METHOD("create_new_file", "given_path"), &TextFileEditor::create_new_file); ClassDB::bind_method(D_METHOD("create_new_file", "given_path"), &TextFileEditor::create_new_file);

View File

@ -63,16 +63,14 @@ public:
FILE_MENU_OPTION_CLOSE = 2, FILE_MENU_OPTION_CLOSE = 2,
FILE_MENU_OPTION_SAVE = 3, FILE_MENU_OPTION_SAVE = 3,
FILE_MENU_OPTION_SAVE_AS = 4, FILE_MENU_OPTION_SAVE_AS = 4,
FILE_MENU_OPTION_DELETE = 5, FILE_MENU_OPTION_SEARCH = 5,
FILE_MENU_OPTION_SEARCH = 6, FILE_MENU_OPTION_REPLACE = 6,
FILE_MENU_OPTION_REPLACE = 7,
}; };
void connect_signals(); void connect_signals();
void create_selected_file(); void create_selected_file();
void open_selected_file(); void open_selected_file();
void delete_selected_file();
void save_current_file_as(); void save_current_file_as();
void _on_file_btn_pressed(const int index); void _on_file_btn_pressed(const int index);
@ -89,7 +87,6 @@ public:
void _on_update_file(); void _on_update_file();
void delete_file(const PoolStringArray &files_selected);
void open_new_file_dialogue(); void open_new_file_dialogue();
void open_file_list(); void open_file_list();
void create_new_file(const String &given_path); void create_new_file(const String &given_path);