Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Control hiding in PluginConfigDialog #85470

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions editor/plugin_config_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void PluginConfigDialog::_notification(int p_what) {
}

void PluginConfigDialog::config(const String &p_config_path) {
if (p_config_path.length()) {
if (!p_config_path.is_empty()) {
Ref<ConfigFile> cf = memnew(ConfigFile);
Error err = cf->load(p_config_path);
ERR_FAIL_COND_MSG(err != OK, "Cannot load config file from path '" + p_config_path + "'.");
Expand All @@ -159,20 +159,17 @@ void PluginConfigDialog::config(const String &p_config_path) {
script_edit->set_text(cf->get_value("plugin", "script", ""));

_edit_mode = true;
active_edit->hide();
Object::cast_to<Label>(active_edit->get_parent()->get_child(active_edit->get_index() - 1))->hide();
subfolder_edit->hide();
Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 1))->hide();
set_title(TTR("Edit a Plugin"));
} else {
_clear_fields();
_edit_mode = false;
active_edit->show();
Object::cast_to<Label>(active_edit->get_parent()->get_child(active_edit->get_index() - 1))->show();
subfolder_edit->show();
Object::cast_to<Label>(subfolder_edit->get_parent()->get_child(subfolder_edit->get_index() - 1))->show();
set_title(TTR("Create a Plugin"));
}

for (Control *control : plugin_edit_hidden_controls) {
control->set_visible(!_edit_mode);
}

validation_panel->update();

get_ok_button()->set_disabled(!_edit_mode);
Expand Down Expand Up @@ -214,12 +211,14 @@ PluginConfigDialog::PluginConfigDialog() {
subfolder_lb->set_text(TTR("Subfolder:"));
subfolder_lb->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
grid->add_child(subfolder_lb);
plugin_edit_hidden_controls.push_back(subfolder_lb);

subfolder_edit = memnew(LineEdit);
subfolder_edit->set_placeholder("\"my_plugin\" -> res://addons/my_plugin");
subfolder_edit->set_tooltip_text(TTR("Optional. The folder name should generally use `snake_case` naming (avoid spaces and special characters).\nIf left empty, the folder will be named after the plugin name converted to `snake_case`."));
subfolder_edit->set_h_size_flags(Control::SIZE_EXPAND_FILL);
grid->add_child(subfolder_edit);
plugin_edit_hidden_controls.push_back(subfolder_edit);

// Description
Label *desc_lb = memnew(Label);
Expand Down Expand Up @@ -296,10 +295,12 @@ PluginConfigDialog::PluginConfigDialog() {
active_lb->set_text(TTR("Activate now?"));
active_lb->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
grid->add_child(active_lb);
plugin_edit_hidden_controls.push_back(active_lb);

active_edit = memnew(CheckBox);
active_edit->set_pressed(true);
grid->add_child(active_edit);
plugin_edit_hidden_controls.push_back(active_edit);

Control *spacing = memnew(Control);
vbox->add_child(spacing);
Expand Down
2 changes: 2 additions & 0 deletions editor/plugin_config_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class PluginConfigDialog : public ConfirmationDialog {
LineEdit *script_edit = nullptr;
CheckBox *active_edit = nullptr;

LocalVector<Control *> plugin_edit_hidden_controls;

EditorValidationPanel *validation_panel = nullptr;

bool _edit_mode = false;
Expand Down
Loading