diff options
author | unknown <numaanzaheerahmed@yahoo.com> | 2020-04-05 04:38:23 +0530 |
---|---|---|
committer | unknown <numaanzaheerahmed@yahoo.com> | 2020-04-05 14:10:30 +0530 |
commit | 600f7cb97ceb12ac6cde6f3f57a9f59bd3c33baf (patch) | |
tree | 527519fb889b7cbca247957778fd9c72f52a950f /editor | |
parent | 321ce4d4c46a998baa26e8e562775b7e28030339 (diff) |
Dissolving class EditorLineEditFileChooser into EditorAutoloadSettings.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_autoload_settings.cpp | 47 | ||||
-rw-r--r-- | editor/editor_autoload_settings.h | 7 | ||||
-rw-r--r-- | editor/editor_file_dialog.cpp | 39 | ||||
-rw-r--r-- | editor/editor_file_dialog.h | 22 |
4 files changed, 41 insertions, 74 deletions
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index ed628ff620..6917b2b775 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -48,8 +48,6 @@ void EditorAutoloadSettings::_notification(int p_what) { ResourceLoader::get_recognized_extensions_for_type("Script", &afn); ResourceLoader::get_recognized_extensions_for_type("PackedScene", &afn); - EditorFileDialog *file_dialog = autoload_add_path->get_file_dialog(); - for (List<String>::Element *E = afn.front(); E; E = E->next()) { file_dialog->add_filter("*." + E->get()); @@ -61,6 +59,9 @@ void EditorAutoloadSettings::_notification(int p_what) { get_tree()->get_root()->call_deferred("add_child", info.node); } } + browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); + } else if (p_what == NOTIFICATION_THEME_CHANGED) { + browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); } } @@ -116,8 +117,8 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin void EditorAutoloadSettings::_autoload_add() { - if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_line_edit()->get_text())) - autoload_add_path->get_line_edit()->set_text(""); + if (autoload_add(autoload_add_name->get_text(), autoload_add_path->get_text())) + autoload_add_path->set_text(""); autoload_add_name->set_text(""); add_autoload->set_disabled(true); @@ -326,7 +327,7 @@ void EditorAutoloadSettings::_autoload_file_callback(const String &p_path) { void EditorAutoloadSettings::_autoload_text_entered(const String p_name) { - if (autoload_add_path->get_line_edit()->get_text() != "" && _autoload_name_is_valid(p_name, nullptr)) { + if (autoload_add_path->get_text() != "" && _autoload_name_is_valid(p_name, nullptr)) { _autoload_add(); } } @@ -340,7 +341,7 @@ void EditorAutoloadSettings::_autoload_path_text_changed(const String p_path) { void EditorAutoloadSettings::_autoload_text_changed(const String p_name) { add_autoload->set_disabled( - autoload_add_path->get_line_edit()->get_text() == "" || !_autoload_name_is_valid(p_name, nullptr)); + autoload_add_path->get_text() == "" || !_autoload_name_is_valid(p_name, nullptr)); } Node *EditorAutoloadSettings::_create_autoload(const String &p_path) { @@ -823,13 +824,24 @@ EditorAutoloadSettings::EditorAutoloadSettings() { l->set_text(TTR("Path:")); hbc->add_child(l); - autoload_add_path = memnew(EditorLineEditFileChooser); - autoload_add_path->set_h_size_flags(SIZE_EXPAND_FILL); - autoload_add_path->get_file_dialog()->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); - autoload_add_path->get_file_dialog()->connect("file_selected", callable_mp(this, &EditorAutoloadSettings::_autoload_file_callback)); - autoload_add_path->get_line_edit()->connect("text_changed", callable_mp(this, &EditorAutoloadSettings::_autoload_path_text_changed)); - + autoload_add_path = memnew(LineEdit); hbc->add_child(autoload_add_path); + autoload_add_path->set_h_size_flags(Control::SIZE_EXPAND_FILL); + autoload_add_path->connect("text_changed", callable_mp(this, &EditorAutoloadSettings::_autoload_path_text_changed)); + + browse_button = memnew(Button); + hbc->add_child(browse_button); + browse_button->connect("pressed", callable_mp(this, &EditorAutoloadSettings::_browse_autoload_add_path)); + + file_dialog = memnew(EditorFileDialog); + hbc->add_child(file_dialog); + file_dialog->connect("file_selected", callable_mp(this, &EditorAutoloadSettings::_set_autoload_add_path)); + file_dialog->connect("dir_selected", callable_mp(this, &EditorAutoloadSettings::_set_autoload_add_path)); + file_dialog->connect("files_selected", callable_mp(this, &EditorAutoloadSettings::_set_autoload_add_path)); + + hbc->set_h_size_flags(SIZE_EXPAND_FILL); + file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE); + file_dialog->connect("file_selected", callable_mp(this, &EditorAutoloadSettings::_autoload_file_callback)); l = memnew(Label); l->set_text(TTR("Node Name:")); @@ -890,3 +902,14 @@ EditorAutoloadSettings::~EditorAutoloadSettings() { } } } + +void EditorAutoloadSettings::_set_autoload_add_path(const String &p_text) { + + autoload_add_path->set_text(p_text); + autoload_add_path->emit_signal("text_entered", p_text); +} + +void EditorAutoloadSettings::_browse_autoload_add_path() { + + file_dialog->popup_centered_ratio(); +}
\ No newline at end of file diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h index 2716442ec9..94a581401c 100644 --- a/editor/editor_autoload_settings.h +++ b/editor/editor_autoload_settings.h @@ -74,9 +74,11 @@ class EditorAutoloadSettings : public VBoxContainer { String selected_autoload; Tree *tree; - EditorLineEditFileChooser *autoload_add_path; LineEdit *autoload_add_name; Button *add_autoload; + LineEdit *autoload_add_path; + Button *browse_button; + EditorFileDialog *file_dialog; bool _autoload_name_is_valid(const String &p_name, String *r_error = nullptr); @@ -96,6 +98,9 @@ class EditorAutoloadSettings : public VBoxContainer { bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_control); + void _set_autoload_add_path(const String &p_text); + void _browse_autoload_add_path(); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 71ade56e39..3c6ea125b7 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -1733,42 +1733,3 @@ EditorFileDialog::~EditorFileDialog() { unregister_func(this); memdelete(dir_access); } - -void EditorLineEditFileChooser::_notification(int p_what) { - - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) - button->set_icon(get_theme_icon("Folder", "EditorIcons")); -} - -void EditorLineEditFileChooser::_bind_methods() { - - ClassDB::bind_method(D_METHOD("get_button"), &EditorLineEditFileChooser::get_button); - ClassDB::bind_method(D_METHOD("get_line_edit"), &EditorLineEditFileChooser::get_line_edit); - ClassDB::bind_method(D_METHOD("get_file_dialog"), &EditorLineEditFileChooser::get_file_dialog); -} - -void EditorLineEditFileChooser::_chosen(const String &p_text) { - - line_edit->set_text(p_text); - line_edit->emit_signal("text_entered", p_text); -} - -void EditorLineEditFileChooser::_browse() { - - dialog->popup_centered_ratio(); -} - -EditorLineEditFileChooser::EditorLineEditFileChooser() { - - line_edit = memnew(LineEdit); - add_child(line_edit); - line_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL); - button = memnew(Button); - add_child(button); - button->connect("pressed", callable_mp(this, &EditorLineEditFileChooser::_browse)); - dialog = memnew(EditorFileDialog); - add_child(dialog); - dialog->connect("file_selected", callable_mp(this, &EditorLineEditFileChooser::_chosen)); - dialog->connect("dir_selected", callable_mp(this, &EditorLineEditFileChooser::_chosen)); - dialog->connect("files_selected", callable_mp(this, &EditorLineEditFileChooser::_chosen)); -} diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index ed23f14ebe..8efb8f5368 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -245,28 +245,6 @@ public: ~EditorFileDialog(); }; -class EditorLineEditFileChooser : public HBoxContainer { - - GDCLASS(EditorLineEditFileChooser, HBoxContainer); - Button *button; - LineEdit *line_edit; - EditorFileDialog *dialog; - - void _chosen(const String &p_text); - void _browse(); - -protected: - void _notification(int p_what); - static void _bind_methods(); - -public: - Button *get_button() { return button; } - LineEdit *get_line_edit() { return line_edit; } - EditorFileDialog *get_file_dialog() { return dialog; } - - EditorLineEditFileChooser(); -}; - VARIANT_ENUM_CAST(EditorFileDialog::FileMode); VARIANT_ENUM_CAST(EditorFileDialog::Access); VARIANT_ENUM_CAST(EditorFileDialog::DisplayMode); |