Disable OK button when creating new VG with name of an existing one.

This commit is contained in:
Chantara Tith 2016-08-08 10:49:41 +07:00 committed by Andrius Štikonas
parent 5775560759
commit 1472b310fd
4 changed files with 16 additions and 3 deletions

View File

@ -36,7 +36,8 @@
CreateVolumeDialog::CreateVolumeDialog(QWidget* parent, QString& vgname, QStringList& pvlist, qint32& pesize) :
VolumeDialog(parent, vgname, pvlist),
m_PESize(pesize)
m_PESize(pesize),
m_SystemVGList(LvmDevice::getVGs())
{
setWindowTitle(xi18nc("@title:window", "Create new Volume Group"));
@ -78,7 +79,11 @@ void CreateVolumeDialog::accept()
void CreateVolumeDialog::onVGNameChanged(const QString& vgname)
{
Q_UNUSED(vgname);
if (m_SystemVGList.contains(vgname)) {
m_IsValidName = false;
} else {
m_IsValidName = true;
}
updateOkButtonStatus();
}

View File

@ -42,6 +42,8 @@ protected:
}
qint32& m_PESize;
private:
QStringList m_SystemVGList;
};
#endif

View File

@ -45,6 +45,7 @@ VolumeDialog::VolumeDialog(QWidget* parent, QString& vgname, QStringList& pvlist
m_TargetName(vgname),
m_TargetPVList(pvlist),
m_IsValidSize(false),
m_IsValidName(true),
m_TotalSize(0),
m_TotalUsedSize(0),
m_ExtentSize(0)
@ -121,7 +122,7 @@ void VolumeDialog::updateOkButtonStatus()
{
bool enable = isValidSize();
if (dialogWidget().vgName().text().isEmpty()) {
if (dialogWidget().vgName().text().isEmpty() || !isValidName()) {
enable = false;
}
if (dialogWidget().spinPESize().value() <= 0) {

View File

@ -80,6 +80,10 @@ protected:
return m_IsValidSize;
}
bool isValidName() const {
return m_IsValidName;
}
protected:
virtual void onPartitionListChanged();
@ -88,6 +92,7 @@ protected:
QString& m_TargetName;
QStringList& m_TargetPVList;
bool m_IsValidSize;
bool m_IsValidName;
qint64 m_TotalSize;
qint64 m_TotalUsedSize;