Add a validator for LVM LV names.

This commit is contained in:
Andrius Štikonas 2017-10-09 23:56:15 +01:00
parent f30a3c999f
commit f105f448b3
1 changed files with 7 additions and 0 deletions

View File

@ -115,6 +115,13 @@ void NewDialog::setupDialog()
detailsButton->hide();
dialogWidget().comboFileSystem().removeItem(dialogWidget().comboFileSystem().findText(QStringLiteral("lvm2 pv")));
m_IsValidLVName = false;
/* LVM logical volume name can consist of: letters numbers _ . - +
* It cannot start with underscore _ and must not be equal to . or .. or any entry in /dev/
* QLineEdit accepts QValidator::Intermediate, so we just disable . at the beginning */
QRegularExpression re(QStringLiteral(R"(^(?!_|\.)[\w\-.+]+)"));
QRegularExpressionValidator *validator = new QRegularExpressionValidator(re, this);
dialogWidget().lvName().setValidator(validator);
}
dialogWidget().editPassphrase().setMinimumPasswordLength(1);