Manager: Reload VMs if the system directory has been changed

This commit is contained in:
Alexander Babikov
2026-01-13 03:30:07 +05:00
parent 304d843267
commit 535a87a0e1
29 changed files with 137 additions and 0 deletions

View File

@@ -3017,3 +3017,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3023,3 +3023,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3023,3 +3023,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3023,3 +3023,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3080,3 +3080,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3023,3 +3023,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3023,3 +3023,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3023,3 +3023,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3025,3 +3025,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3023,3 +3023,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3024,3 +3024,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3017,3 +3017,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3017,3 +3017,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3017,3 +3017,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3024,3 +3024,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3017,3 +3017,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3024,3 +3024,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3036,3 +3036,6 @@ msgstr "П&еремотка вперёд"
msgid "Fast forward"
msgstr "Перемотка вперёд"
msgid "To change the system directory, stop all running machines."
msgstr "Чтобы изменить системную папку, остановите все запущенные машины."

View File

@@ -3023,3 +3023,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3025,3 +3025,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3017,3 +3017,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3023,3 +3023,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3025,3 +3025,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3017,3 +3017,6 @@ msgstr ""
msgid "Fast forward"
msgstr ""
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3017,3 +3017,6 @@ msgstr "快进(&F)"
msgid "Fast forward"
msgstr "快进"
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -3024,3 +3024,6 @@ msgstr "快轉(&F)"
msgid "Fast forward"
msgstr "快轉"
msgid "To change the system directory, stop all running machines."
msgstr ""

View File

@@ -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()
{

View File

@@ -61,6 +61,7 @@ signals:
void updateStatusRight(const QString &text);
public slots:
void reload();
void startButtonPressed() const;
void settingsButtonPressed();
void restartButtonPressed() const;

View File

@@ -203,10 +203,18 @@ void
VMManagerMainWindow::preferencesTriggered()
{
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();
}
}
}