Connection dialog tweaks

This commit is contained in:
kobewi 2023-01-26 00:30:36 +01:00
parent 10d22a4b35
commit 24134710dd
2 changed files with 16 additions and 17 deletions

View File

@ -350,6 +350,7 @@ void ConnectDialog::_update_method_tree() {
} }
if (script_methods_only->is_pressed()) { if (script_methods_only->is_pressed()) {
empty_tree_label->set_visible(root_item->get_first_child() == nullptr);
return; return;
} }
@ -376,6 +377,8 @@ void ConnectDialog::_update_method_tree() {
} }
current_class = ClassDB::get_parent_class_nocheck(current_class); current_class = ClassDB::get_parent_class_nocheck(current_class);
} while (current_class != StringName()); } while (current_class != StringName());
empty_tree_label->set_visible(root_item->get_first_child() == nullptr);
} }
void ConnectDialog::_method_check_button_pressed(const CheckButton *p_button) { void ConnectDialog::_method_check_button_pressed(const CheckButton *p_button) {
@ -432,6 +435,7 @@ void ConnectDialog::_notification(int p_what) {
from_signal->add_theme_style_override("normal", style); from_signal->add_theme_style_override("normal", style);
} }
method_search->set_right_icon(get_theme_icon("Search", "EditorIcons")); method_search->set_right_icon(get_theme_icon("Search", "EditorIcons"));
open_method_tree->set_icon(get_theme_icon("Edit", "EditorIcons"));
} break; } break;
} }
} }
@ -597,18 +601,9 @@ ConnectDialog::ConnectDialog() {
main_hb->add_child(vbc_left); main_hb->add_child(vbc_left);
vbc_left->set_h_size_flags(Control::SIZE_EXPAND_FILL); vbc_left->set_h_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *from_signal_hb = memnew(HBoxContainer);
from_signal = memnew(LineEdit); from_signal = memnew(LineEdit);
vbc_left->add_margin_child(TTR("From Signal:"), from_signal);
from_signal->set_editable(false); from_signal->set_editable(false);
from_signal->set_h_size_flags(Control::SIZE_EXPAND_FILL);
from_signal_hb->add_child(from_signal);
advanced = memnew(CheckButton(TTR("Advanced")));
from_signal_hb->add_child(advanced);
advanced->connect("pressed", callable_mp(this, &ConnectDialog::_advanced_pressed));
vbc_left->add_margin_child(TTR("From Signal:"), from_signal_hb);
tree = memnew(SceneTreeEditor(false)); tree = memnew(SceneTreeEditor(false));
tree->set_connecting_signal(true); tree->set_connecting_signal(true);
@ -646,6 +641,10 @@ ConnectDialog::ConnectDialog() {
method_tree->connect("item_selected", callable_mp(this, &ConnectDialog::_method_selected)); method_tree->connect("item_selected", callable_mp(this, &ConnectDialog::_method_selected));
method_tree->connect("item_activated", callable_mp((Window *)method_popup, &Window::hide)); method_tree->connect("item_activated", callable_mp((Window *)method_popup, &Window::hide));
empty_tree_label = memnew(Label(TTR("No method found matching given filters.")));
method_tree->add_child(empty_tree_label);
empty_tree_label->set_anchors_and_offsets_preset(Control::PRESET_CENTER);
script_methods_only = memnew(CheckButton(TTR("Script Methods Only"))); script_methods_only = memnew(CheckButton(TTR("Script Methods Only")));
method_vbc->add_child(script_methods_only); method_vbc->add_child(script_methods_only);
script_methods_only->set_h_size_flags(Control::SIZE_SHRINK_END); script_methods_only->set_h_size_flags(Control::SIZE_SHRINK_END);
@ -712,15 +711,13 @@ ConnectDialog::ConnectDialog() {
dst_method->connect("text_submitted", callable_mp(this, &ConnectDialog::_text_submitted)); dst_method->connect("text_submitted", callable_mp(this, &ConnectDialog::_text_submitted));
hbc_method->add_child(dst_method); hbc_method->add_child(dst_method);
Button *open_tree_button = memnew(Button); open_method_tree = memnew(Button);
open_tree_button->set_flat(false); hbc_method->add_child(open_method_tree);
open_tree_button->set_text("..."); open_method_tree->set_text("Pick");
open_tree_button->connect("pressed", callable_mp(this, &ConnectDialog::_open_method_popup)); open_method_tree->connect("pressed", callable_mp(this, &ConnectDialog::_open_method_popup));
hbc_method->add_child(open_tree_button);
advanced = memnew(CheckButton); advanced = memnew(CheckButton(TTR("Advanced")));
vbc_left->add_child(advanced); vbc_left->add_child(advanced);
advanced->set_text(TTR("Advanced"));
advanced->set_h_size_flags(Control::SIZE_SHRINK_BEGIN | Control::SIZE_EXPAND); advanced->set_h_size_flags(Control::SIZE_SHRINK_BEGIN | Control::SIZE_EXPAND);
advanced->set_pressed(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "use_advanced_connections", false)); advanced->set_pressed(EditorSettings::get_singleton()->get_project_metadata("editor_metadata", "use_advanced_connections", false));
advanced->connect("pressed", callable_mp(this, &ConnectDialog::_advanced_pressed)); advanced->connect("pressed", callable_mp(this, &ConnectDialog::_advanced_pressed));

View File

@ -117,8 +117,10 @@ private:
SceneTreeEditor *tree = nullptr; SceneTreeEditor *tree = nullptr;
AcceptDialog *error = nullptr; AcceptDialog *error = nullptr;
Button *open_method_tree = nullptr;
AcceptDialog *method_popup = nullptr; AcceptDialog *method_popup = nullptr;
Tree *method_tree = nullptr; Tree *method_tree = nullptr;
Label *empty_tree_label = nullptr;
LineEdit *method_search = nullptr; LineEdit *method_search = nullptr;
CheckButton *script_methods_only = nullptr; CheckButton *script_methods_only = nullptr;
CheckButton *compatible_methods_only = nullptr; CheckButton *compatible_methods_only = nullptr;