mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-12-25 15:16:02 +00:00
GH-2355 Do not allow instances to be created with whitespace prefix or suffix
This commit is contained in:
parent
4169f53b19
commit
12f2716f31
@ -62,12 +62,22 @@ CopyInstanceDialog::~CopyInstanceDialog()
|
||||
|
||||
void CopyInstanceDialog::updateDialogState()
|
||||
{
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!instName().isEmpty());
|
||||
auto allowOK = !instName().isEmpty();
|
||||
auto OkButton = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
if(OkButton->isEnabled() != allowOK)
|
||||
{
|
||||
OkButton->setEnabled(allowOK);
|
||||
}
|
||||
}
|
||||
|
||||
QString CopyInstanceDialog::instName() const
|
||||
{
|
||||
return ui->instNameTextBox->text();
|
||||
auto result = ui->instNameTextBox->text().trimmed();
|
||||
if(result.size())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString CopyInstanceDialog::iconKey() const
|
||||
|
@ -165,15 +165,15 @@ void NewInstanceDialog::updateDialogState()
|
||||
|
||||
QString NewInstanceDialog::instName() const
|
||||
{
|
||||
auto result = ui->instNameTextBox->text();
|
||||
auto result = ui->instNameTextBox->text().trimmed();
|
||||
if(result.size())
|
||||
{
|
||||
return result.trimmed();
|
||||
return result;
|
||||
}
|
||||
result = ui->instNameTextBox->placeholderText();
|
||||
result = ui->instNameTextBox->placeholderText().trimmed();
|
||||
if(result.size())
|
||||
{
|
||||
return result.trimmed();
|
||||
return result;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user