mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 09:35:32 -07:00
Merge pull request #6715 from lemondrops/manager-reload
Manager: Reload VMs after changing the system directory
This commit is contained in:
@@ -3014,3 +3014,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3020,3 +3020,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3020,3 +3020,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3020,3 +3020,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3077,3 +3077,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3020,3 +3020,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3020,3 +3020,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3020,3 +3020,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3022,3 +3022,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3020,3 +3020,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3021,3 +3021,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3014,3 +3014,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3014,3 +3014,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3014,3 +3014,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3021,3 +3021,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3014,3 +3014,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3021,3 +3021,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3033,3 +3033,6 @@ msgstr "П&еремотка вперёд"
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr "Перемотка вперёд"
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr "Чтобы изменить системную папку, остановите все запущенные машины."
|
||||
|
||||
@@ -3020,3 +3020,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3022,3 +3022,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3014,3 +3014,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3020,3 +3020,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3022,3 +3022,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3014,3 +3014,6 @@ msgstr ""
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr ""
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3014,3 +3014,6 @@ msgstr "快进(&F)"
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr "快进"
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -3021,3 +3021,6 @@ msgstr "快轉(&F)"
|
||||
|
||||
msgid "Fast forward"
|
||||
msgstr "快轉"
|
||||
|
||||
msgid "To change the system directory, stop all running machines."
|
||||
msgstr ""
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
|
||||
~VMManagerDetails() override;
|
||||
|
||||
void reset();
|
||||
|
||||
void updateData(VMManagerSystem *passed_sysconfig);
|
||||
|
||||
void updateProcessStatus();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ signals:
|
||||
void updateStatusRight(const QString &text);
|
||||
|
||||
public slots:
|
||||
void reload();
|
||||
void startButtonPressed() const;
|
||||
void settingsButtonPressed();
|
||||
void restartButtonPressed() const;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user