summaryrefslogtreecommitdiffstats
path: root/application/dialogs/CopyInstanceDialog.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2018-07-28 22:08:09 +0200
committerPetr Mrázek <peterix@gmail.com>2018-07-28 22:08:09 +0200
commit12f2716f31e09d18d47ffdbb6c06dfb71c6ec8fb (patch)
tree28fa09d8cdf4942f2425c695803203f4e2081e44 /application/dialogs/CopyInstanceDialog.cpp
parent4169f53b19372ccb978f6384b8f89e2819e1f00f (diff)
downloadMultiMC-12f2716f31e09d18d47ffdbb6c06dfb71c6ec8fb.tar
MultiMC-12f2716f31e09d18d47ffdbb6c06dfb71c6ec8fb.tar.gz
MultiMC-12f2716f31e09d18d47ffdbb6c06dfb71c6ec8fb.tar.lz
MultiMC-12f2716f31e09d18d47ffdbb6c06dfb71c6ec8fb.tar.xz
MultiMC-12f2716f31e09d18d47ffdbb6c06dfb71c6ec8fb.zip
GH-2355 Do not allow instances to be created with whitespace prefix or suffix
Diffstat (limited to 'application/dialogs/CopyInstanceDialog.cpp')
-rw-r--r--application/dialogs/CopyInstanceDialog.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/application/dialogs/CopyInstanceDialog.cpp b/application/dialogs/CopyInstanceDialog.cpp
index c565510c..b16684c6 100644
--- a/application/dialogs/CopyInstanceDialog.cpp
+++ b/application/dialogs/CopyInstanceDialog.cpp
@@ -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