Manager: Temporarily disable the system location option in the new machine wizard
This commit is contained in:
@@ -223,6 +223,7 @@ WithExistingConfigPage::isComplete() const
|
|||||||
NameAndLocationPage::
|
NameAndLocationPage::
|
||||||
NameAndLocationPage(QWidget *parent)
|
NameAndLocationPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
setTitle(tr("System name and location"));
|
setTitle(tr("System name and location"));
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@@ -234,6 +235,10 @@ NameAndLocationPage(QWidget *parent)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
const auto topLabel = new QLabel(tr("Enter the name of the system and choose the location"));
|
const auto topLabel = new QLabel(tr("Enter the name of the system and choose the location"));
|
||||||
|
#else
|
||||||
|
setTitle(tr("System name"));
|
||||||
|
const auto topLabel = new QLabel(tr("Enter the name of the system"));
|
||||||
|
#endif
|
||||||
topLabel->setWordWrap(true);
|
topLabel->setWordWrap(true);
|
||||||
|
|
||||||
const auto chooseDirectoryButton = new QPushButton();
|
const auto chooseDirectoryButton = new QPushButton();
|
||||||
@@ -246,6 +251,7 @@ NameAndLocationPage(QWidget *parent)
|
|||||||
registerField("systemName*", systemName);
|
registerField("systemName*", systemName);
|
||||||
systemNameValidation = new QLabel();
|
systemNameValidation = new QLabel();
|
||||||
|
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
const auto systemLocationLabel = new QLabel(tr("System Location"));
|
const auto systemLocationLabel = new QLabel(tr("System Location"));
|
||||||
systemLocation = new QLineEdit();
|
systemLocation = new QLineEdit();
|
||||||
// TODO: FIXME: This is using the CLI arg and needs to instead use a proper variable
|
// TODO: FIXME: This is using the CLI arg and needs to instead use a proper variable
|
||||||
@@ -253,6 +259,7 @@ NameAndLocationPage(QWidget *parent)
|
|||||||
registerField("systemLocation*", systemLocation);
|
registerField("systemLocation*", systemLocation);
|
||||||
systemLocationValidation = new QLabel();
|
systemLocationValidation = new QLabel();
|
||||||
systemLocationValidation->setWordWrap(true);
|
systemLocationValidation->setWordWrap(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
const auto layout = new QGridLayout();
|
const auto layout = new QGridLayout();
|
||||||
layout->addWidget(topLabel, 0, 0, 1, -1);
|
layout->addWidget(topLabel, 0, 0, 1, -1);
|
||||||
@@ -265,6 +272,7 @@ NameAndLocationPage(QWidget *parent)
|
|||||||
// Set height on validation because it may not always be present
|
// Set height on validation because it may not always be present
|
||||||
layout->setRowMinimumHeight(3, 20);
|
layout->setRowMinimumHeight(3, 20);
|
||||||
|
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
// Another spacer
|
// Another spacer
|
||||||
layout->setRowMinimumHeight(4, 20);
|
layout->setRowMinimumHeight(4, 20);
|
||||||
layout->addWidget(systemLocationLabel, 5, 0);
|
layout->addWidget(systemLocationLabel, 5, 0);
|
||||||
@@ -273,11 +281,13 @@ NameAndLocationPage(QWidget *parent)
|
|||||||
// Validation text
|
// Validation text
|
||||||
layout->addWidget(systemLocationValidation, 6, 0, 1, -1);
|
layout->addWidget(systemLocationValidation, 6, 0, 1, -1);
|
||||||
layout->setRowMinimumHeight(6, 20);
|
layout->setRowMinimumHeight(6, 20);
|
||||||
|
#endif
|
||||||
|
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
connect(chooseDirectoryButton, &QPushButton::clicked, this, &NameAndLocationPage::chooseDirectoryLocation);
|
connect(chooseDirectoryButton, &QPushButton::clicked, this, &NameAndLocationPage::chooseDirectoryLocation);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -286,6 +296,7 @@ NameAndLocationPage::nextId() const
|
|||||||
return VMManagerAddMachine::Page_Conclusion;
|
return VMManagerAddMachine::Page_Conclusion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
void
|
void
|
||||||
NameAndLocationPage::chooseDirectoryLocation()
|
NameAndLocationPage::chooseDirectoryLocation()
|
||||||
{
|
{
|
||||||
@@ -294,23 +305,31 @@ NameAndLocationPage::chooseDirectoryLocation()
|
|||||||
systemLocation->setText(QDir::toNativeSeparators(directory));
|
systemLocation->setText(QDir::toNativeSeparators(directory));
|
||||||
emit completeChanged();
|
emit completeChanged();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
bool
|
bool
|
||||||
NameAndLocationPage::isComplete() const
|
NameAndLocationPage::isComplete() const
|
||||||
{
|
{
|
||||||
bool nameValid = false;
|
bool nameValid = false;
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
bool locationValid = false;
|
bool locationValid = false;
|
||||||
|
#endif
|
||||||
// return true if complete
|
// return true if complete
|
||||||
if (systemName->text().isEmpty()) {
|
if (systemName->text().isEmpty()) {
|
||||||
systemNameValidation->setText(tr("Please enter a system name"));
|
systemNameValidation->setText(tr("Please enter a system name"));
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
} else if (!systemName->text().contains(dirValidate)) {
|
} else if (!systemName->text().contains(dirValidate)) {
|
||||||
systemNameValidation->setText(tr("System name cannot contain certain characters"));
|
systemNameValidation->setText(tr("System name cannot contain certain characters"));
|
||||||
} else if (const QDir newDir = QDir::cleanPath(systemLocation->text() + "/" + systemName->text()); newDir.exists()) {
|
} else if (const QDir newDir = QDir::cleanPath(systemLocation->text() + "/" + systemName->text()); newDir.exists()) {
|
||||||
|
#else
|
||||||
|
} else if (const QDir newDir = QDir::cleanPath(QString(vmm_path) + "/" + systemName->text()); newDir.exists()) {
|
||||||
|
#endif
|
||||||
systemNameValidation->setText(tr("System name already exists"));
|
systemNameValidation->setText(tr("System name already exists"));
|
||||||
} else {
|
} else {
|
||||||
systemNameValidation->clear();
|
systemNameValidation->clear();
|
||||||
nameValid = true;
|
nameValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
if (systemLocation->text().isEmpty()) {
|
if (systemLocation->text().isEmpty()) {
|
||||||
systemLocationValidation->setText(tr("Please enter a directory for the system"));
|
systemLocationValidation->setText(tr("Please enter a directory for the system"));
|
||||||
} else if (const auto dir = QDir(systemLocation->text()); !dir.exists()) {
|
} else if (const auto dir = QDir(systemLocation->text()); !dir.exists()) {
|
||||||
@@ -321,6 +340,9 @@ NameAndLocationPage::isComplete() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return nameValid && locationValid;
|
return nameValid && locationValid;
|
||||||
|
#else
|
||||||
|
return nameValid;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
bool
|
bool
|
||||||
NameAndLocationPage::eventFilter(QObject *watched, QEvent *event)
|
NameAndLocationPage::eventFilter(QObject *watched, QEvent *event)
|
||||||
@@ -354,17 +376,21 @@ ConclusionPage(QWidget *parent)
|
|||||||
const auto systemNameLabel = new QLabel(tr("System name:"));
|
const auto systemNameLabel = new QLabel(tr("System name:"));
|
||||||
systemNameLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
systemNameLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||||
systemName = new QLabel();
|
systemName = new QLabel();
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
const auto systemLocationLabel = new QLabel(tr("System location:"));
|
const auto systemLocationLabel = new QLabel(tr("System location:"));
|
||||||
systemLocationLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
systemLocationLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||||
systemLocation = new QLabel();
|
systemLocation = new QLabel();
|
||||||
|
#endif
|
||||||
|
|
||||||
const auto layout = new QGridLayout();
|
const auto layout = new QGridLayout();
|
||||||
layout->addWidget(topLabel, 0, 0, 1, -1);
|
layout->addWidget(topLabel, 0, 0, 1, -1);
|
||||||
layout->setRowMinimumHeight(1, 20);
|
layout->setRowMinimumHeight(1, 20);
|
||||||
layout->addWidget(systemNameLabel, 2, 0);
|
layout->addWidget(systemNameLabel, 2, 0);
|
||||||
layout->addWidget(systemName, 2, 1);
|
layout->addWidget(systemName, 2, 1);
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
layout->addWidget(systemLocationLabel, 3, 0);
|
layout->addWidget(systemLocationLabel, 3, 0);
|
||||||
layout->addWidget(systemLocation, 3, 1);
|
layout->addWidget(systemLocation, 3, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
}
|
}
|
||||||
@@ -373,10 +399,14 @@ ConclusionPage(QWidget *parent)
|
|||||||
void
|
void
|
||||||
ConclusionPage::initializePage()
|
ConclusionPage::initializePage()
|
||||||
{
|
{
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
const auto finalPath = QDir::cleanPath(field("systemLocation").toString() + "/" + field("systemName").toString());
|
const auto finalPath = QDir::cleanPath(field("systemLocation").toString() + "/" + field("systemName").toString());
|
||||||
const auto nativePath = QDir::toNativeSeparators(finalPath);
|
const auto nativePath = QDir::toNativeSeparators(finalPath);
|
||||||
|
#endif
|
||||||
const auto systemNameDisplay = field("systemName").toString();
|
const auto systemNameDisplay = field("systemName").toString();
|
||||||
|
|
||||||
systemName->setText(systemNameDisplay);
|
systemName->setText(systemNameDisplay);
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
systemLocation->setText(nativePath);
|
systemLocation->setText(nativePath);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,12 +90,16 @@ public:
|
|||||||
[[nodiscard]] int nextId() const override;
|
[[nodiscard]] int nextId() const override;
|
||||||
private:
|
private:
|
||||||
QLineEdit *systemName;
|
QLineEdit *systemName;
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
QLineEdit *systemLocation;
|
QLineEdit *systemLocation;
|
||||||
|
#endif
|
||||||
QLabel *systemNameValidation;
|
QLabel *systemNameValidation;
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
QLabel *systemLocationValidation;
|
QLabel *systemLocationValidation;
|
||||||
QRegularExpression dirValidate;
|
QRegularExpression dirValidate;
|
||||||
private slots:
|
private slots:
|
||||||
void chooseDirectoryLocation();
|
void chooseDirectoryLocation();
|
||||||
|
#endif
|
||||||
protected:
|
protected:
|
||||||
[[nodiscard]] bool isComplete() const override;
|
[[nodiscard]] bool isComplete() const override;
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
@@ -109,7 +113,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
QLabel *topLabel;
|
QLabel *topLabel;
|
||||||
QLabel *systemName;
|
QLabel *systemName;
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
QLabel *systemLocation;
|
QLabel *systemLocation;
|
||||||
|
#endif
|
||||||
protected:
|
protected:
|
||||||
void initializePage() override;
|
void initializePage() override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -349,7 +349,11 @@ VMManagerMain::newMachineWizard()
|
|||||||
const auto wizard = new VMManagerAddMachine(this);
|
const auto wizard = new VMManagerAddMachine(this);
|
||||||
if (wizard->exec() == QDialog::Accepted) {
|
if (wizard->exec() == QDialog::Accepted) {
|
||||||
const auto newName = wizard->field("systemName").toString();
|
const auto newName = wizard->field("systemName").toString();
|
||||||
|
#ifdef CUSTOM_SYSTEM_LOCATION
|
||||||
const auto systemDir = wizard->field("systemLocation").toString();
|
const auto systemDir = wizard->field("systemLocation").toString();
|
||||||
|
#else
|
||||||
|
const auto systemDir = QDir(vmm_path).path();
|
||||||
|
#endif
|
||||||
const auto existingConfiguration = wizard->field("existingConfiguration").toString();
|
const auto existingConfiguration = wizard->field("existingConfiguration").toString();
|
||||||
addNewSystem(newName, systemDir, existingConfiguration);
|
addNewSystem(newName, systemDir, existingConfiguration);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user