mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Merge pull request #108125 from Calinou/project-manager-tags-auto-underscore-lowercase
Replace spaces and use lowercase automatically for project manager tags
This commit is contained in:
commit
376a19e0bd
1 changed files with 10 additions and 14 deletions
|
|
@ -1073,11 +1073,6 @@ void ProjectManager::_set_new_tag_name(const String p_name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_name.contains_char(' ')) {
|
|
||||||
tag_error->set_text(TTRC("Tag name can't contain spaces."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_name[0] == '_' || p_name[p_name.length() - 1] == '_') {
|
if (p_name[0] == '_' || p_name[p_name.length() - 1] == '_') {
|
||||||
tag_error->set_text(TTRC("Tag name can't begin or end with underscore."));
|
tag_error->set_text(TTRC("Tag name can't begin or end with underscore."));
|
||||||
return;
|
return;
|
||||||
|
|
@ -1085,9 +1080,10 @@ void ProjectManager::_set_new_tag_name(const String p_name) {
|
||||||
|
|
||||||
bool was_underscore = false;
|
bool was_underscore = false;
|
||||||
for (const char32_t &c : p_name.span()) {
|
for (const char32_t &c : p_name.span()) {
|
||||||
if (c == '_') {
|
// Treat spaces as underscores, as we convert spaces to underscores automatically in the tag input field.
|
||||||
|
if (c == '_' || c == ' ') {
|
||||||
if (was_underscore) {
|
if (was_underscore) {
|
||||||
tag_error->set_text(TTRC("Tag name can't contain consecutive underscores."));
|
tag_error->set_text(TTRC("Tag name can't contain consecutive underscores or spaces."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
was_underscore = true;
|
was_underscore = true;
|
||||||
|
|
@ -1103,11 +1099,6 @@ void ProjectManager::_set_new_tag_name(const String p_name) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_name.to_lower() != p_name) {
|
|
||||||
tag_error->set_text(TTRC("Tag name must be lowercase."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
tag_error->set_text("");
|
tag_error->set_text("");
|
||||||
create_tag_dialog->get_ok_button()->set_disabled(false);
|
create_tag_dialog->get_ok_button()->set_disabled(false);
|
||||||
}
|
}
|
||||||
|
|
@ -1117,8 +1108,12 @@ void ProjectManager::_create_new_tag() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
create_tag_dialog->hide(); // When using text_submitted, need to hide manually.
|
create_tag_dialog->hide(); // When using text_submitted, need to hide manually.
|
||||||
add_new_tag(new_tag_name->get_text());
|
|
||||||
_add_project_tag(new_tag_name->get_text());
|
// Enforce a valid tag name (no spaces, lowercase only) automatically.
|
||||||
|
// The project manager displays underscores as spaces, and capitalization is performed automatically.
|
||||||
|
const String new_tag = new_tag_name->get_text().strip_edges().to_lower().replace_char(' ', '_');
|
||||||
|
add_new_tag(new_tag);
|
||||||
|
_add_project_tag(new_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectManager::add_new_tag(const String &p_tag) {
|
void ProjectManager::add_new_tag(const String &p_tag) {
|
||||||
|
|
@ -1880,6 +1875,7 @@ ProjectManager::ProjectManager() {
|
||||||
new_tag_name = memnew(LineEdit);
|
new_tag_name = memnew(LineEdit);
|
||||||
tag_vb->add_child(new_tag_name);
|
tag_vb->add_child(new_tag_name);
|
||||||
new_tag_name->set_accessibility_name(TTRC("New Tag Name"));
|
new_tag_name->set_accessibility_name(TTRC("New Tag Name"));
|
||||||
|
new_tag_name->set_placeholder(TTRC("example_tag (will display as Example Tag)"));
|
||||||
new_tag_name->connect(SceneStringName(text_changed), callable_mp(this, &ProjectManager::_set_new_tag_name));
|
new_tag_name->connect(SceneStringName(text_changed), callable_mp(this, &ProjectManager::_set_new_tag_name));
|
||||||
new_tag_name->connect(SceneStringName(text_submitted), callable_mp(this, &ProjectManager::_create_new_tag).unbind(1));
|
new_tag_name->connect(SceneStringName(text_submitted), callable_mp(this, &ProjectManager::_create_new_tag).unbind(1));
|
||||||
create_tag_dialog->connect("about_to_popup", callable_mp(new_tag_name, &LineEdit::clear));
|
create_tag_dialog->connect("about_to_popup", callable_mp(new_tag_name, &LineEdit::clear));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue