mirror of
https://github.com/86Box/86Box.git
synced 2026-02-22 09:35:32 -07:00
Manager: Sync toolbar button state with selected VM's state
This commit is contained in:
@@ -427,7 +427,7 @@ illegal_chars:
|
||||
// Set initial status bar after the event loop starts
|
||||
emit updateStatusRight(machineCountString());
|
||||
// Tell the mainwindow to enable the toolbar buttons if needed
|
||||
emit selectionChanged((this->proxy_model->rowCount(QModelIndex()) > 0) ? selected_sysconfig : nullptr);
|
||||
emit selectionOrStateChanged((this->proxy_model->rowCount(QModelIndex()) > 0) ? selected_sysconfig : nullptr);
|
||||
});
|
||||
|
||||
#if EMU_BUILD_NUM != 0
|
||||
@@ -458,12 +458,21 @@ VMManagerMain::currentSelectionChanged(const QModelIndex ¤t,
|
||||
if (!current.isValid())
|
||||
return;
|
||||
|
||||
disconnect(selected_sysconfig->process, &QProcess::stateChanged, this, &VMManagerMain::vmStateChange);
|
||||
disconnect(selected_sysconfig, &VMManagerSystem::windowStatusChanged, this, &VMManagerMain::vmStateChange);
|
||||
disconnect(selected_sysconfig, &VMManagerSystem::clientProcessStatusChanged, this, &VMManagerMain::vmStateChange);
|
||||
|
||||
const auto mapped_index = proxy_model->mapToSource(current);
|
||||
selected_sysconfig = vm_model->getConfigObjectForIndex(mapped_index);
|
||||
vm_details->updateData(selected_sysconfig);
|
||||
|
||||
// Emit that the selection changed, include with the process state
|
||||
emit selectionChanged(selected_sysconfig);
|
||||
emit selectionOrStateChanged(selected_sysconfig);
|
||||
|
||||
connect(selected_sysconfig->process, &QProcess::stateChanged, this, &VMManagerMain::vmStateChange);
|
||||
connect(selected_sysconfig, &VMManagerSystem::windowStatusChanged, this, &VMManagerMain::vmStateChange);
|
||||
connect(selected_sysconfig, &VMManagerSystem::clientProcessStatusChanged, this, &VMManagerMain::vmStateChange);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
@@ -719,13 +728,14 @@ 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);
|
||||
/* tell the mainwindow to disable the toolbar buttons */
|
||||
emit selectionChanged(nullptr);
|
||||
emit selectionOrStateChanged(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -799,6 +809,15 @@ VMManagerMain::modelDataChange()
|
||||
emit updateStatusRight(machineCountString(states));
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMain::vmStateChange()
|
||||
{
|
||||
if (!currentSelectionIsValid())
|
||||
return;
|
||||
|
||||
emit selectionOrStateChanged(selected_sysconfig);
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMain::onPreferencesUpdated()
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
Settings,
|
||||
};
|
||||
signals:
|
||||
void selectionChanged(VMManagerSystem *sysconfig);
|
||||
void selectionOrStateChanged(VMManagerSystem *sysconfig);
|
||||
void updateStatusLeft(const QString &text);
|
||||
void updateStatusRight(const QString &text);
|
||||
|
||||
@@ -115,6 +115,7 @@ private:
|
||||
#endif
|
||||
void showTextFileContents(const QString &title, const QString &path);
|
||||
private slots:
|
||||
void vmStateChange();
|
||||
#if EMU_BUILD_NUM != 0
|
||||
void backgroundUpdateCheckComplete(const UpdateCheck::UpdateResult &result);
|
||||
void backgroundUpdateCheckError(const QString &errorMsg);
|
||||
|
||||
@@ -50,7 +50,7 @@ VMManagerMainWindow::
|
||||
pauseIcon = QIcon(":/menuicons/qt/icons/pause.ico");
|
||||
|
||||
// Connect signals from the VMManagerMain widget
|
||||
connect(vmm, &VMManagerMain::selectionChanged, this, &VMManagerMainWindow::vmmSelectionChanged);
|
||||
connect(vmm, &VMManagerMain::selectionOrStateChanged, this, &VMManagerMainWindow::vmmStateChanged);
|
||||
|
||||
setWindowTitle(tr("%1 VM Manager").arg(EMU_NAME));
|
||||
setCentralWidget(vmm);
|
||||
@@ -71,7 +71,7 @@ VMManagerMainWindow::
|
||||
connect(ui->actionCheck_for_updates, &QAction::triggered, this, &VMManagerMainWindow::checkForUpdatesTriggered);
|
||||
#endif
|
||||
|
||||
// TODO: Unhide the toolbar once the actions are fixed to properly update on VM status change
|
||||
// Set up the toolbar
|
||||
ui->actionStartPause->setEnabled(false);
|
||||
ui->actionStartPause->setIcon(runIcon);
|
||||
ui->actionStartPause->setText(tr("Start"));
|
||||
@@ -151,7 +151,7 @@ VMManagerMainWindow::~VMManagerMainWindow()
|
||||
= default;
|
||||
|
||||
void
|
||||
VMManagerMainWindow::vmmSelectionChanged(const VMManagerSystem *sysconfig) const
|
||||
VMManagerMainWindow::vmmStateChanged(const VMManagerSystem *sysconfig) const
|
||||
{
|
||||
if (sysconfig == nullptr) {
|
||||
// This doubles both as a safety check and a way to disable
|
||||
@@ -176,12 +176,14 @@ VMManagerMainWindow::vmmSelectionChanged(const VMManagerSystem *sysconfig) const
|
||||
ui->actionStartPause->setToolTip(tr("Continue"));
|
||||
}
|
||||
disconnect(ui->actionStartPause, &QAction::triggered, vmm, &VMManagerMain::startButtonPressed);
|
||||
disconnect(ui->actionStartPause, &QAction::triggered, vmm, &VMManagerMain::pauseButtonPressed);
|
||||
connect(ui->actionStartPause, &QAction::triggered, vmm, &VMManagerMain::pauseButtonPressed);
|
||||
} else {
|
||||
ui->actionStartPause->setIcon(runIcon);
|
||||
ui->actionStartPause->setText(tr("Start"));
|
||||
ui->actionStartPause->setToolTip(tr("Start"));
|
||||
disconnect(ui->actionStartPause, &QAction::triggered, vmm, &VMManagerMain::pauseButtonPressed);
|
||||
disconnect(ui->actionStartPause, &QAction::triggered, vmm, &VMManagerMain::startButtonPressed);
|
||||
connect(ui->actionStartPause, &QAction::triggered, vmm, &VMManagerMain::startButtonPressed);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public slots:
|
||||
#endif
|
||||
|
||||
private slots:
|
||||
void vmmSelectionChanged(const VMManagerSystem *sysconfig) const;
|
||||
void vmmStateChanged(const VMManagerSystem *sysconfig) const;
|
||||
void preferencesTriggered();
|
||||
#if EMU_BUILD_NUM != 0
|
||||
void checkForUpdatesTriggered();
|
||||
|
||||
Reference in New Issue
Block a user