chore: make all the regexes static const (#3647)

This commit is contained in:
Alexandru Ionut Tripon
2025-04-29 00:33:49 +03:00
committed by GitHub
37 changed files with 87 additions and 84 deletions

View File

@ -83,7 +83,8 @@ NewComponentDialog::~NewComponentDialog()
void NewComponentDialog::updateDialogState()
{
auto protoUid = ui->nameTextBox->text().toLower();
protoUid.remove(QRegularExpression("[^a-z]"));
static const QRegularExpression s_removeChars("[^a-z]");
protoUid.remove(s_removeChars);
if (protoUid.isEmpty()) {
ui->uidTextBox->setPlaceholderText(originalPlaceholderText);
} else {

View File

@ -59,9 +59,9 @@ ProfileSetupDialog::ProfileSetupDialog(MinecraftAccountPtr accountToSetup, QWidg
yellowIcon = APPLICATION->getThemedIcon("status-yellow");
badIcon = APPLICATION->getThemedIcon("status-bad");
QRegularExpression permittedNames("[a-zA-Z0-9_]{3,16}");
static const QRegularExpression s_permittedNames("[a-zA-Z0-9_]{3,16}");
auto nameEdit = ui->nameEdit;
nameEdit->setValidator(new QRegularExpressionValidator(permittedNames));
nameEdit->setValidator(new QRegularExpressionValidator(s_permittedNames));
nameEdit->setClearButtonEnabled(true);
validityAction = nameEdit->addAction(yellowIcon, QLineEdit::LeadingPosition);
connect(nameEdit, &QLineEdit::textEdited, this, &ProfileSetupDialog::nameEdited);
@ -268,7 +268,6 @@ void ProfileSetupDialog::setupProfileFinished()
QString errorMessage =
tr("Network Error: %1\nHTTP Status: %2").arg(m_profile_task->errorString(), QString::number(m_profile_task->replyStatusCode()));
if (parsedError.fullyParsed) {
errorMessage += "Path: " + parsedError.path + "\n";
errorMessage += "Error: " + parsedError.error + "\n";