Improve the editor feature profiles UX

- Add an help message when no profile is selected.
  - This replaces the class/property trees which are now hidden
    when no profile is selected.
- Display `(none)` as the current profile when no profile is
  currently active.
- Make the newly created/imported profile the current if it's the
  first profile to be added to the list.
- Make more strings localizable.
This commit is contained in:
Hugo Locurcio 2020-03-22 21:52:06 +01:00
parent 7acdf74a6a
commit 4a1f22d1ec
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
2 changed files with 33 additions and 5 deletions

View file

@ -361,7 +361,7 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr
}
if (name == current_profile) {
name += " (current)";
name += " " + TTR("(current)");
}
profile_list->add_item(name);
int index = profile_list->get_item_count() - 1;
@ -371,12 +371,15 @@ void EditorFeatureProfileManager::_update_profile_list(const String &p_select_pr
}
}
class_list_vbc->set_visible(selected_profile != String());
property_list_vbc->set_visible(selected_profile != String());
no_profile_selected_help->set_visible(selected_profile == String());
profile_actions[PROFILE_CLEAR]->set_disabled(current_profile == String());
profile_actions[PROFILE_ERASE]->set_disabled(selected_profile == String());
profile_actions[PROFILE_EXPORT]->set_disabled(selected_profile == String());
profile_actions[PROFILE_SET]->set_disabled(selected_profile == String());
current_profile_name->set_text(current_profile);
current_profile_name->set_text(current_profile != String() ? current_profile : TTR("(none)"));
_update_selected_profile();
}
@ -467,6 +470,10 @@ void EditorFeatureProfileManager::_create_new_profile() {
new_profile->save_to_file(file);
_update_profile_list(name);
// The newly created profile is the first one, make it the current profile automatically.
if (profile_list->get_item_count() == 1) {
_profile_action(PROFILE_SET);
}
}
void EditorFeatureProfileManager::_profile_selected(int p_what) {
@ -750,6 +757,10 @@ void EditorFeatureProfileManager::_import_profiles(const Vector<String> &p_paths
}
_update_profile_list();
// The newly imported profile is the first one, make it the current profile automatically.
if (profile_list->get_item_count() == 1) {
_profile_action(PROFILE_SET);
}
}
void EditorFeatureProfileManager::_export_profile(const String &p_path) {
@ -804,6 +815,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
HBoxContainer *name_hbc = memnew(HBoxContainer);
current_profile_name = memnew(LineEdit);
name_hbc->add_child(current_profile_name);
current_profile_name->set_text(TTR("(none)"));
current_profile_name->set_editable(false);
current_profile_name->set_h_size_flags(SIZE_EXPAND_FILL);
profile_actions[PROFILE_CLEAR] = memnew(Button(TTR("Unset")));
@ -852,7 +864,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
h_split->set_v_size_flags(SIZE_EXPAND_FILL);
main_vbc->add_child(h_split);
VBoxContainer *class_list_vbc = memnew(VBoxContainer);
class_list_vbc = memnew(VBoxContainer);
h_split->add_child(class_list_vbc);
class_list_vbc->set_h_size_flags(SIZE_EXPAND_FILL);
@ -862,17 +874,30 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() {
class_list->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
class_list->connect("cell_selected", callable_mp(this, &EditorFeatureProfileManager::_class_list_item_selected));
class_list->connect("item_edited", callable_mp(this, &EditorFeatureProfileManager::_class_list_item_edited), varray(), CONNECT_DEFERRED);
// It will be displayed once the user creates or chooses a profile.
class_list_vbc->hide();
VBoxContainer *property_list_vbc = memnew(VBoxContainer);
property_list_vbc = memnew(VBoxContainer);
h_split->add_child(property_list_vbc);
property_list_vbc->set_h_size_flags(SIZE_EXPAND_FILL);
property_list = memnew(Tree);
property_list_vbc->add_margin_child(TTR("Class Options"), property_list, true);
property_list_vbc->add_margin_child(TTR("Class Options:"), property_list, true);
property_list->set_hide_root(true);
property_list->set_hide_folding(true);
property_list->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
property_list->connect("item_edited", callable_mp(this, &EditorFeatureProfileManager::_property_item_edited), varray(), CONNECT_DEFERRED);
// It will be displayed once the user creates or chooses a profile.
property_list_vbc->hide();
no_profile_selected_help = memnew(Label(TTR("Create or import a profile to edit available classes and properties.")));
// Add some spacing above the help label.
Ref<StyleBoxEmpty> sb = memnew(StyleBoxEmpty);
sb->set_default_margin(MARGIN_TOP, 20 * EDSCALE);
no_profile_selected_help->add_style_override("normal", sb);
no_profile_selected_help->set_align(Label::ALIGN_CENTER);
no_profile_selected_help->set_v_size_flags(SIZE_EXPAND_FILL);
h_split->add_child(no_profile_selected_help);
new_profile_dialog = memnew(ConfirmationDialog);
new_profile_dialog->set_title(TTR("New profile name:"));

View file

@ -121,8 +121,11 @@ class EditorFeatureProfileManager : public AcceptDialog {
HSplitContainer *h_split;
VBoxContainer *class_list_vbc;
Tree *class_list;
VBoxContainer *property_list_vbc;
Tree *property_list;
Label *no_profile_selected_help;
EditorFileDialog *import_profiles;
EditorFileDialog *export_profile;