From 7b5a861005e06caf28e8a60c1b251aefa7493468 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Fri, 8 Aug 2025 00:51:46 +0500 Subject: [PATCH 1/2] Manager: Temporarily disable the system location option in the new machine wizard --- src/qt/qt_vmmanager_addmachine.cpp | 32 +++++++++++++++++++++++++++++- src/qt/qt_vmmanager_addmachine.hpp | 6 ++++++ src/qt/qt_vmmanager_main.cpp | 4 ++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/qt/qt_vmmanager_addmachine.cpp b/src/qt/qt_vmmanager_addmachine.cpp index 55ff7274b..719f9be43 100644 --- a/src/qt/qt_vmmanager_addmachine.cpp +++ b/src/qt/qt_vmmanager_addmachine.cpp @@ -223,6 +223,7 @@ WithExistingConfigPage::isComplete() const NameAndLocationPage:: NameAndLocationPage(QWidget *parent) { +#ifdef CUSTOM_SYSTEM_LOCATION setTitle(tr("System name and location")); #if defined(_WIN32) @@ -234,6 +235,10 @@ NameAndLocationPage(QWidget *parent) #endif 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); const auto chooseDirectoryButton = new QPushButton(); @@ -246,6 +251,7 @@ NameAndLocationPage(QWidget *parent) registerField("systemName*", systemName); systemNameValidation = new QLabel(); +#ifdef CUSTOM_SYSTEM_LOCATION const auto systemLocationLabel = new QLabel(tr("System Location")); systemLocation = new QLineEdit(); // 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); systemLocationValidation = new QLabel(); systemLocationValidation->setWordWrap(true); +#endif const auto layout = new QGridLayout(); 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 layout->setRowMinimumHeight(3, 20); +#ifdef CUSTOM_SYSTEM_LOCATION // Another spacer layout->setRowMinimumHeight(4, 20); layout->addWidget(systemLocationLabel, 5, 0); @@ -273,11 +281,13 @@ NameAndLocationPage(QWidget *parent) // Validation text layout->addWidget(systemLocationValidation, 6, 0, 1, -1); layout->setRowMinimumHeight(6, 20); +#endif setLayout(layout); - +#ifdef CUSTOM_SYSTEM_LOCATION connect(chooseDirectoryButton, &QPushButton::clicked, this, &NameAndLocationPage::chooseDirectoryLocation); +#endif } int @@ -286,6 +296,7 @@ NameAndLocationPage::nextId() const return VMManagerAddMachine::Page_Conclusion; } +#ifdef CUSTOM_SYSTEM_LOCATION void NameAndLocationPage::chooseDirectoryLocation() { @@ -294,23 +305,31 @@ NameAndLocationPage::chooseDirectoryLocation() systemLocation->setText(QDir::toNativeSeparators(directory)); emit completeChanged(); } +#endif bool NameAndLocationPage::isComplete() const { bool nameValid = false; +#ifdef CUSTOM_SYSTEM_LOCATION bool locationValid = false; +#endif // return true if complete if (systemName->text().isEmpty()) { systemNameValidation->setText(tr("Please enter a system name")); +#ifdef CUSTOM_SYSTEM_LOCATION } else if (!systemName->text().contains(dirValidate)) { systemNameValidation->setText(tr("System name cannot contain certain characters")); } 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")); } else { systemNameValidation->clear(); nameValid = true; } +#ifdef CUSTOM_SYSTEM_LOCATION if (systemLocation->text().isEmpty()) { systemLocationValidation->setText(tr("Please enter a directory for the system")); } else if (const auto dir = QDir(systemLocation->text()); !dir.exists()) { @@ -321,6 +340,9 @@ NameAndLocationPage::isComplete() const } return nameValid && locationValid; +#else + return nameValid; +#endif } bool NameAndLocationPage::eventFilter(QObject *watched, QEvent *event) @@ -354,17 +376,21 @@ ConclusionPage(QWidget *parent) const auto systemNameLabel = new QLabel(tr("System name:")); systemNameLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); systemName = new QLabel(); +#ifdef CUSTOM_SYSTEM_LOCATION const auto systemLocationLabel = new QLabel(tr("System location:")); systemLocationLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); systemLocation = new QLabel(); +#endif const auto layout = new QGridLayout(); layout->addWidget(topLabel, 0, 0, 1, -1); layout->setRowMinimumHeight(1, 20); layout->addWidget(systemNameLabel, 2, 0); layout->addWidget(systemName, 2, 1); +#ifdef CUSTOM_SYSTEM_LOCATION layout->addWidget(systemLocationLabel, 3, 0); layout->addWidget(systemLocation, 3, 1); +#endif setLayout(layout); } @@ -373,10 +399,14 @@ ConclusionPage(QWidget *parent) void ConclusionPage::initializePage() { +#ifdef CUSTOM_SYSTEM_LOCATION const auto finalPath = QDir::cleanPath(field("systemLocation").toString() + "/" + field("systemName").toString()); const auto nativePath = QDir::toNativeSeparators(finalPath); +#endif const auto systemNameDisplay = field("systemName").toString(); systemName->setText(systemNameDisplay); +#ifdef CUSTOM_SYSTEM_LOCATION systemLocation->setText(nativePath); +#endif } diff --git a/src/qt/qt_vmmanager_addmachine.hpp b/src/qt/qt_vmmanager_addmachine.hpp index 6ba1a53ce..6e573d905 100644 --- a/src/qt/qt_vmmanager_addmachine.hpp +++ b/src/qt/qt_vmmanager_addmachine.hpp @@ -90,12 +90,16 @@ public: [[nodiscard]] int nextId() const override; private: QLineEdit *systemName; +#ifdef CUSTOM_SYSTEM_LOCATION QLineEdit *systemLocation; +#endif QLabel *systemNameValidation; +#ifdef CUSTOM_SYSTEM_LOCATION QLabel *systemLocationValidation; QRegularExpression dirValidate; private slots: void chooseDirectoryLocation(); +#endif protected: [[nodiscard]] bool isComplete() const override; bool eventFilter(QObject *watched, QEvent *event) override; @@ -109,7 +113,9 @@ public: private: QLabel *topLabel; QLabel *systemName; +#ifdef CUSTOM_SYSTEM_LOCATION QLabel *systemLocation; +#endif protected: void initializePage() override; }; diff --git a/src/qt/qt_vmmanager_main.cpp b/src/qt/qt_vmmanager_main.cpp index 38a3d7340..73f54c69c 100644 --- a/src/qt/qt_vmmanager_main.cpp +++ b/src/qt/qt_vmmanager_main.cpp @@ -349,7 +349,11 @@ VMManagerMain::newMachineWizard() const auto wizard = new VMManagerAddMachine(this); if (wizard->exec() == QDialog::Accepted) { const auto newName = wizard->field("systemName").toString(); +#ifdef CUSTOM_SYSTEM_LOCATION const auto systemDir = wizard->field("systemLocation").toString(); +#else + const auto systemDir = QDir(vmm_path).path(); +#endif const auto existingConfiguration = wizard->field("existingConfiguration").toString(); addNewSystem(newName, systemDir, existingConfiguration); } From fcf85d40a60be6e34f0cb2d91e94c4250f049aa4 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Fri, 8 Aug 2025 00:52:16 +0500 Subject: [PATCH 2/2] Manager: Add display name to new machine wizard --- src/qt/qt_vmmanager_addmachine.cpp | 24 ++++++++++++++++++++++++ src/qt/qt_vmmanager_addmachine.hpp | 3 +++ src/qt/qt_vmmanager_main.cpp | 7 +++++-- src/qt/qt_vmmanager_main.hpp | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/qt/qt_vmmanager_addmachine.cpp b/src/qt/qt_vmmanager_addmachine.cpp index 719f9be43..12b736fb3 100644 --- a/src/qt/qt_vmmanager_addmachine.cpp +++ b/src/qt/qt_vmmanager_addmachine.cpp @@ -261,6 +261,12 @@ NameAndLocationPage(QWidget *parent) systemLocationValidation->setWordWrap(true); #endif + const auto displayNameLabel = new QLabel(tr("Display Name (optional)")); + displayName = new QLineEdit(); + // Special event filter to override enter key + displayName->installEventFilter(this); + registerField("displayName*", displayName); + const auto layout = new QGridLayout(); layout->addWidget(topLabel, 0, 0, 1, -1); // Spacer row @@ -283,6 +289,11 @@ NameAndLocationPage(QWidget *parent) layout->setRowMinimumHeight(6, 20); #endif + // Another spacer + layout->setRowMinimumHeight(7, 20); + layout->addWidget(displayNameLabel, 8, 0); + layout->addWidget(displayName, 8, 1); + setLayout(layout); #ifdef CUSTOM_SYSTEM_LOCATION @@ -382,6 +393,10 @@ ConclusionPage(QWidget *parent) systemLocation = new QLabel(); #endif + displayNameLabel = new QLabel(tr("Display name:")); + displayNameLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); + displayName = new QLabel(); + const auto layout = new QGridLayout(); layout->addWidget(topLabel, 0, 0, 1, -1); layout->setRowMinimumHeight(1, 20); @@ -391,6 +406,8 @@ ConclusionPage(QWidget *parent) layout->addWidget(systemLocationLabel, 3, 0); layout->addWidget(systemLocation, 3, 1); #endif + layout->addWidget(displayNameLabel, 4, 0); + layout->addWidget(displayName, 4, 1); setLayout(layout); } @@ -404,9 +421,16 @@ ConclusionPage::initializePage() const auto nativePath = QDir::toNativeSeparators(finalPath); #endif const auto systemNameDisplay = field("systemName").toString(); + const auto displayNameDisplay = field("displayName").toString(); systemName->setText(systemNameDisplay); #ifdef CUSTOM_SYSTEM_LOCATION systemLocation->setText(nativePath); #endif + if (!displayNameDisplay.isEmpty()) + displayName->setText(displayNameDisplay); + else { + displayNameLabel->setVisible(false); + displayName->setVisible(false); + } } diff --git a/src/qt/qt_vmmanager_addmachine.hpp b/src/qt/qt_vmmanager_addmachine.hpp index 6e573d905..92a12398a 100644 --- a/src/qt/qt_vmmanager_addmachine.hpp +++ b/src/qt/qt_vmmanager_addmachine.hpp @@ -93,6 +93,7 @@ private: #ifdef CUSTOM_SYSTEM_LOCATION QLineEdit *systemLocation; #endif + QLineEdit *displayName; QLabel *systemNameValidation; #ifdef CUSTOM_SYSTEM_LOCATION QLabel *systemLocationValidation; @@ -116,6 +117,8 @@ private: #ifdef CUSTOM_SYSTEM_LOCATION QLabel *systemLocation; #endif + QLabel *displayNameLabel; + QLabel *displayName; protected: void initializePage() override; }; diff --git a/src/qt/qt_vmmanager_main.cpp b/src/qt/qt_vmmanager_main.cpp index 73f54c69c..bf22e367e 100644 --- a/src/qt/qt_vmmanager_main.cpp +++ b/src/qt/qt_vmmanager_main.cpp @@ -355,12 +355,13 @@ VMManagerMain::newMachineWizard() const auto systemDir = QDir(vmm_path).path(); #endif const auto existingConfiguration = wizard->field("existingConfiguration").toString(); - addNewSystem(newName, systemDir, existingConfiguration); + const auto displayName = wizard->field("displayName").toString(); + addNewSystem(newName, systemDir, displayName, existingConfiguration); } } void -VMManagerMain::addNewSystem(const QString &name, const QString &dir, const QString &configFile) +VMManagerMain::addNewSystem(const QString &name, const QString &dir, const QString &displayName, const QString &configFile) { const auto newSytemDirectory = QDir(QDir::cleanPath(dir + "/" + name)); @@ -423,6 +424,8 @@ VMManagerMain::addNewSystem(const QString &name, const QString &dir, const QStri delete new_system; return; } + auto added_system = vm_model->getConfigObjectForIndex(created_object); + added_system->setDisplayName(displayName); // Get the index of the newly-created system and select it const QModelIndex mapped_index = proxy_model->mapFromSource(created_object); ui->listView->setCurrentIndex(mapped_index); diff --git a/src/qt/qt_vmmanager_main.hpp b/src/qt/qt_vmmanager_main.hpp index fc21d577f..d41d57938 100644 --- a/src/qt/qt_vmmanager_main.hpp +++ b/src/qt/qt_vmmanager_main.hpp @@ -70,7 +70,7 @@ public slots: void shutdownForceButtonPressed() const; void searchSystems(const QString &text) const; void newMachineWizard(); - void addNewSystem(const QString &name, const QString &dir, const QString &configFile = {}); + void addNewSystem(const QString &name, const QString &dir, const QString &displayName = QString(), const QString &configFile = {}); #if __GNUC__ >= 11 [[nodiscard]] QStringList getSearchCompletionList() const; #else