diff --git a/src/qt/languages/86box.pot b/src/qt/languages/86box.pot index 01cf55a54..c5d1d2514 100644 --- a/src/qt/languages/86box.pot +++ b/src/qt/languages/86box.pot @@ -3014,3 +3014,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/ca-ES.po b/src/qt/languages/ca-ES.po index 8e7f36249..ad9dd6eb1 100644 --- a/src/qt/languages/ca-ES.po +++ b/src/qt/languages/ca-ES.po @@ -3020,3 +3020,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/cs-CZ.po b/src/qt/languages/cs-CZ.po index 3c73eaa87..bed51f261 100644 --- a/src/qt/languages/cs-CZ.po +++ b/src/qt/languages/cs-CZ.po @@ -3020,3 +3020,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/de-DE.po b/src/qt/languages/de-DE.po index 689b52100..38e829861 100644 --- a/src/qt/languages/de-DE.po +++ b/src/qt/languages/de-DE.po @@ -3020,3 +3020,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/el-GR.po b/src/qt/languages/el-GR.po index 385e19fe8..9243c24fb 100644 --- a/src/qt/languages/el-GR.po +++ b/src/qt/languages/el-GR.po @@ -3077,3 +3077,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/es-ES.po b/src/qt/languages/es-ES.po index d190f5b48..3d339efd0 100644 --- a/src/qt/languages/es-ES.po +++ b/src/qt/languages/es-ES.po @@ -3020,3 +3020,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/fi-FI.po b/src/qt/languages/fi-FI.po index 77bcf1c72..fd6add696 100644 --- a/src/qt/languages/fi-FI.po +++ b/src/qt/languages/fi-FI.po @@ -3020,3 +3020,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/fr-FR.po b/src/qt/languages/fr-FR.po index 3eb05f967..2e1422a08 100644 --- a/src/qt/languages/fr-FR.po +++ b/src/qt/languages/fr-FR.po @@ -3020,3 +3020,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/hr-HR.po b/src/qt/languages/hr-HR.po index ea090cdda..b3d9a68f1 100644 --- a/src/qt/languages/hr-HR.po +++ b/src/qt/languages/hr-HR.po @@ -3022,3 +3022,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/it-IT.po b/src/qt/languages/it-IT.po index 77dc0ccd7..f4d16bf86 100644 --- a/src/qt/languages/it-IT.po +++ b/src/qt/languages/it-IT.po @@ -3020,3 +3020,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/ja-JP.po b/src/qt/languages/ja-JP.po index f38d2d652..2a7809a47 100644 --- a/src/qt/languages/ja-JP.po +++ b/src/qt/languages/ja-JP.po @@ -3021,3 +3021,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/ko-KR.po b/src/qt/languages/ko-KR.po index e3e32e851..0318e85f3 100644 --- a/src/qt/languages/ko-KR.po +++ b/src/qt/languages/ko-KR.po @@ -3014,3 +3014,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/nb-NO.po b/src/qt/languages/nb-NO.po index e7077cdfa..e31768305 100644 --- a/src/qt/languages/nb-NO.po +++ b/src/qt/languages/nb-NO.po @@ -3014,3 +3014,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/nl-NL.po b/src/qt/languages/nl-NL.po index 4a3b86b02..3d056a2ea 100644 --- a/src/qt/languages/nl-NL.po +++ b/src/qt/languages/nl-NL.po @@ -3014,3 +3014,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/pl-PL.po b/src/qt/languages/pl-PL.po index 6712e2c74..20317c9ec 100644 --- a/src/qt/languages/pl-PL.po +++ b/src/qt/languages/pl-PL.po @@ -3021,3 +3021,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/pt-BR.po b/src/qt/languages/pt-BR.po index 8af604120..31875d7ba 100644 --- a/src/qt/languages/pt-BR.po +++ b/src/qt/languages/pt-BR.po @@ -3014,3 +3014,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/pt-PT.po b/src/qt/languages/pt-PT.po index 557e0621c..f18eb8f1a 100644 --- a/src/qt/languages/pt-PT.po +++ b/src/qt/languages/pt-PT.po @@ -3021,3 +3021,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/ru-RU.po b/src/qt/languages/ru-RU.po index a8d5f7d70..6102dceed 100644 --- a/src/qt/languages/ru-RU.po +++ b/src/qt/languages/ru-RU.po @@ -3033,3 +3033,6 @@ msgstr "П&еремотка вперёд" msgid "Fast forward" msgstr "Перемотка вперёд" + +msgid "To change the system directory, stop all running machines." +msgstr "Чтобы изменить системную папку, остановите все запущенные машины." diff --git a/src/qt/languages/sk-SK.po b/src/qt/languages/sk-SK.po index 5ad0cf0ab..a112005da 100644 --- a/src/qt/languages/sk-SK.po +++ b/src/qt/languages/sk-SK.po @@ -3020,3 +3020,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/sl-SI.po b/src/qt/languages/sl-SI.po index 920af658d..64cc6e7eb 100644 --- a/src/qt/languages/sl-SI.po +++ b/src/qt/languages/sl-SI.po @@ -3022,3 +3022,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/sv-SE.po b/src/qt/languages/sv-SE.po index 70c575431..f49235919 100644 --- a/src/qt/languages/sv-SE.po +++ b/src/qt/languages/sv-SE.po @@ -3014,3 +3014,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/tr-TR.po b/src/qt/languages/tr-TR.po index 0210f505f..aad11ffda 100644 --- a/src/qt/languages/tr-TR.po +++ b/src/qt/languages/tr-TR.po @@ -3020,3 +3020,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/uk-UA.po b/src/qt/languages/uk-UA.po index ddb1e1ce1..7fd0d0b33 100644 --- a/src/qt/languages/uk-UA.po +++ b/src/qt/languages/uk-UA.po @@ -3022,3 +3022,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/vi-VN.po b/src/qt/languages/vi-VN.po index 05c10fe66..b2c7491a1 100644 --- a/src/qt/languages/vi-VN.po +++ b/src/qt/languages/vi-VN.po @@ -3014,3 +3014,6 @@ msgstr "" msgid "Fast forward" msgstr "" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/zh-CN.po b/src/qt/languages/zh-CN.po index 20322c19d..855bb72e8 100644 --- a/src/qt/languages/zh-CN.po +++ b/src/qt/languages/zh-CN.po @@ -3014,3 +3014,6 @@ msgstr "快进(&F)" msgid "Fast forward" msgstr "快进" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/languages/zh-TW.po b/src/qt/languages/zh-TW.po index 577e5bfde..68658b7c0 100644 --- a/src/qt/languages/zh-TW.po +++ b/src/qt/languages/zh-TW.po @@ -3021,3 +3021,6 @@ msgstr "快轉(&F)" msgid "Fast forward" msgstr "快轉" + +msgid "To change the system directory, stop all running machines." +msgstr "" diff --git a/src/qt/qt_vmmanager_details.cpp b/src/qt/qt_vmmanager_details.cpp index 396997e7d..c6d5631e1 100644 --- a/src/qt/qt_vmmanager_details.cpp +++ b/src/qt/qt_vmmanager_details.cpp @@ -122,6 +122,13 @@ VMManagerDetails::VMManagerDetails(QWidget *parent) } ui->ssNavTBHolder->setStyleSheet(toolButtonStyleSheet); + // Margins are a little different on macos +#ifdef Q_OS_MACOS + ui->systemLabel->setMargin(15); +#else + ui->systemLabel->setMargin(10); +#endif + pauseIcon = QIcon(":/menuicons/qt/icons/pause.ico"); runIcon = QIcon(":/menuicons/qt/icons/run.ico"); @@ -178,6 +185,61 @@ VMManagerDetails::~VMManagerDetails() delete ui; } +void +VMManagerDetails::reset() +{ + systemSection->clear(); + videoSection->clear(); + storageSection->clear(); + audioSection->clear(); + networkSection->clear(); + inputSection->clear(); + portsSection->clear(); + otherSection->clear(); + systemSection->setSections(); + videoSection->setSections(); + storageSection->setSections(); + audioSection->setSections(); + networkSection->setSections(); + inputSection->setSections(); + portsSection->setSections(); + otherSection->setSections(); + + ui->screenshotNext->setEnabled(false); + ui->screenshotPrevious->setEnabled(false); + ui->screenshotNextTB->setEnabled(false); + ui->screenshotPreviousTB->setEnabled(false); + ui->screenshot->setPixmap(QString()); + ui->screenshot->setFixedSize(240, 160); + ui->screenshot->setFrameStyle(QFrame::Box | QFrame::Sunken); + ui->screenshot->setText(tr("No screenshot")); + ui->screenshot->setEnabled(false); + ui->screenshot->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); +#ifdef Q_OS_WINDOWS + if (!util::isWindowsLightTheme()) { + ui->screenshot->setStyleSheet(SCREENSHOTBORDER_STYLESHEET_DARK); + } else { + ui->screenshot->setStyleSheet(""); + } +#endif + + startPauseButton->setEnabled(false); + resetButton->setEnabled(false); + stopButton->setEnabled(false); + configureButton->setEnabled(false); + cadButton->setEnabled(false); + + ui->systemLabel->setText(tr("No Machines Found!")); + ui->systemLabel->setStyleSheet(""); + ui->statusLabel->setText(""); + ui->scrollArea->setStyleSheet(""); + + ui->notesTextEdit->setPlainText(""); + ui->notesTextEdit->setEnabled(false); + + sysconfig = new VMManagerSystem(); +} + void VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) { @@ -191,12 +253,6 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) ui->scrollArea->setStyleSheet(SCROLLAREA_STYLESHEET_LIGHT); ui->systemLabel->setStyleSheet(SYSTEMLABEL_STYLESHEET_LIGHT); } - // Margins are a little different on macos -#ifdef Q_OS_MACOS - ui->systemLabel->setMargin(15); -#else - ui->systemLabel->setMargin(10); -#endif // disconnect old signals before assigning the passed systemconfig object disconnect(startPauseButton, &QToolButton::clicked, sysconfig, &VMManagerSystem::startButtonPressed); diff --git a/src/qt/qt_vmmanager_details.hpp b/src/qt/qt_vmmanager_details.hpp index efd2ec6cd..489f74a25 100644 --- a/src/qt/qt_vmmanager_details.hpp +++ b/src/qt/qt_vmmanager_details.hpp @@ -35,6 +35,8 @@ public: ~VMManagerDetails() override; + void reset(); + void updateData(VMManagerSystem *passed_sysconfig); void updateProcessStatus(); diff --git a/src/qt/qt_vmmanager_main.cpp b/src/qt/qt_vmmanager_main.cpp index 786ef9ca4..f1ca7d595 100644 --- a/src/qt/qt_vmmanager_main.cpp +++ b/src/qt/qt_vmmanager_main.cpp @@ -451,6 +451,56 @@ VMManagerMain::~VMManagerMain() delete vm_model; } +void +VMManagerMain::reload() +{ + // Disconnect and save the old selection mdoel to be deleted later + QItemSelectionModel *old_selection_model = ui->listView->selectionModel(); + disconnect(old_selection_model, &QItemSelectionModel::currentChanged, this, &VMManagerMain::currentSelectionChanged); + // Disconnect and delete the model and proxy model + disconnect(vm_model, &VMManagerModel::systemDataChanged, this, &VMManagerMain::modelDataChange); + disconnect(vm_model, &VMManagerModel::globalConfigurationChanged, this, nullptr); + delete proxy_model; + delete vm_model; + + // Reset the details view and toolbar to initial state + selected_sysconfig = new VMManagerSystem(); + vm_details->reset(); + emit selectionOrStateChanged(nullptr); + + // Create the new model and proxy model + vm_model = new VMManagerModel; + proxy_model = new StringListProxyModel(this); + proxy_model->setSourceModel(vm_model); + ui->listView->setModel(proxy_model); + // Delete the old selection model + delete old_selection_model; + + // Set up the new models + proxy_model->setSortCaseSensitivity(Qt::CaseInsensitive); + ui->listView->model()->sort(0, Qt::AscendingOrder); + connect(vm_model, &VMManagerModel::systemDataChanged, this, &VMManagerMain::modelDataChange); + connect(vm_model, &VMManagerModel::globalConfigurationChanged, this, []() { + vmm_main_window->updateSettings(); + }); + const QItemSelectionModel *selection_model = ui->listView->selectionModel(); + connect(selection_model, &QItemSelectionModel::currentChanged, this, &VMManagerMain::currentSelectionChanged); + + // Update the search completer + auto *completerModel = new QStringListModel(getSearchCompletionList(), ui->searchBar->completer()); + ui->searchBar->completer()->setModel(completerModel); + + // If machines are found, set the selection to the first one + if (proxy_model->rowCount(QModelIndex()) > 0) { + const QModelIndex first_index = proxy_model->index(0, 0); + ui->listView->setCurrentIndex(first_index); + emit selectionOrStateChanged(selected_sysconfig); + } + + // Notify the status bar + emit updateStatusRight(machineCountString()); +} + void VMManagerMain::updateGlobalSettings() { @@ -734,12 +784,9 @@ VMManagerMain::deleteSystem(VMManagerSystem *sysconfig) delete sysconfig; if (vm_model->rowCount(QModelIndex()) <= 0) { - selected_sysconfig = new VMManagerSystem(); /* no machines left - get rid of the last machine's leftovers */ - ui->detailsArea->layout()->removeWidget(vm_details); - delete vm_details; - vm_details = new VMManagerDetails(); - ui->detailsArea->layout()->addWidget(vm_details); + selected_sysconfig = new VMManagerSystem(); + vm_details->reset(); /* tell the mainwindow to disable the toolbar buttons */ emit selectionOrStateChanged(nullptr); } diff --git a/src/qt/qt_vmmanager_main.hpp b/src/qt/qt_vmmanager_main.hpp index c8e8822ad..f313fbb04 100644 --- a/src/qt/qt_vmmanager_main.hpp +++ b/src/qt/qt_vmmanager_main.hpp @@ -61,6 +61,7 @@ signals: void updateStatusRight(const QString &text); public slots: + void reload(); void startButtonPressed() const; void settingsButtonPressed(); void restartButtonPressed() const; diff --git a/src/qt/qt_vmmanager_mainwindow.cpp b/src/qt/qt_vmmanager_mainwindow.cpp index 846c3484b..17bd898bd 100644 --- a/src/qt/qt_vmmanager_mainwindow.cpp +++ b/src/qt/qt_vmmanager_mainwindow.cpp @@ -202,10 +202,19 @@ VMManagerMainWindow::vmmStateChanged(const VMManagerSystem *sysconfig) const void VMManagerMainWindow::preferencesTriggered() { - const auto prefs = new VMManagerPreferences(); + bool machinesRunning = (vmm->getActiveMachineCount() > 0); + auto old_vmm_path = QString(vmm_path_cfg); + const auto prefs = new VMManagerPreferences(this, machinesRunning); if (prefs->exec() == QDialog::Accepted) { emit preferencesUpdated(); updateLanguage(); + + auto new_vmm_path = QString(vmm_path_cfg); + if (!machinesRunning && (new_vmm_path != old_vmm_path)) { + qDebug() << "Machine path changed: old path " << old_vmm_path << ", new path " << new_vmm_path; + strncpy(vmm_path, vmm_path_cfg, sizeof(vmm_path)); + vmm->reload(); + } } } diff --git a/src/qt/qt_vmmanager_preferences.cpp b/src/qt/qt_vmmanager_preferences.cpp index 2de133254..77d5d1657 100644 --- a/src/qt/qt_vmmanager_preferences.cpp +++ b/src/qt/qt_vmmanager_preferences.cpp @@ -33,7 +33,7 @@ extern "C" { } VMManagerPreferences:: - VMManagerPreferences(QWidget *parent) + VMManagerPreferences(QWidget *parent, bool machinesRunning) : ui(new Ui::VMManagerPreferences) { ui->setupUi(this); @@ -50,6 +50,12 @@ VMManagerPreferences:: ui->systemDirectory->setText(QDir::toNativeSeparators(QDir(vmm_path).path())); } + if (machinesRunning) { + ui->systemDirectory->setEnabled(false); + ui->dirSelectButton->setEnabled(false); + ui->dirSelectButton->setToolTip(tr("To change the system directory, stop all running machines.")); + } + ui->comboBoxLanguage->setItemData(0, 0); for (int i = 1; i < ProgSettings::languages.length(); i++) { ui->comboBoxLanguage->addItem(ProgSettings::languages[i].second, i); diff --git a/src/qt/qt_vmmanager_preferences.hpp b/src/qt/qt_vmmanager_preferences.hpp index 4215eb768..1ddeedb51 100644 --- a/src/qt/qt_vmmanager_preferences.hpp +++ b/src/qt/qt_vmmanager_preferences.hpp @@ -26,7 +26,7 @@ QT_END_NAMESPACE class VMManagerPreferences final : public QDialog { Q_OBJECT public: - explicit VMManagerPreferences(QWidget *parent = nullptr); + explicit VMManagerPreferences(QWidget *parent = nullptr, bool machinesRunning = false); ~VMManagerPreferences() override; private: