Manager: Update machine configuration on change
(signaled by the VM or upon closing the standalone settings dialog)
This commit is contained in:
@@ -814,6 +814,7 @@ main(int argc, char *argv[])
|
||||
emit main_window->close();
|
||||
});
|
||||
QObject::connect(main_window, &MainWindow::vmmRunningStateChanged, &manager_socket, &VMManagerClientSocket::clientRunningStateChanged);
|
||||
QObject::connect(main_window, &MainWindow::vmmConfigurationChanged, &manager_socket, &VMManagerClientSocket::configurationChanged);
|
||||
main_window->installEventFilter(&manager_socket);
|
||||
|
||||
manager_socket.sendWinIdMessage(main_window->winId());
|
||||
|
||||
@@ -1129,7 +1129,8 @@ MainWindow::on_actionSettings_triggered()
|
||||
case QDialog::Accepted:
|
||||
settings.save();
|
||||
config_changed = 2;
|
||||
updateShortcuts();
|
||||
updateShortcuts();
|
||||
emit vmmConfigurationChanged();
|
||||
pc_reset_hard();
|
||||
break;
|
||||
case QDialog::Rejected:
|
||||
|
||||
@@ -67,6 +67,7 @@ signals:
|
||||
void getTitleForNonQtThread(wchar_t *title);
|
||||
|
||||
void vmmRunningStateChanged(VMManagerProtocol::RunningState state);
|
||||
void vmmConfigurationChanged();
|
||||
public slots:
|
||||
void showSettings();
|
||||
void hardReset();
|
||||
|
||||
@@ -247,3 +247,9 @@ VMManagerClientSocket::clientRunningStateChanged(VMManagerProtocol::RunningState
|
||||
extra_object["status"] = static_cast<int>(state);
|
||||
sendMessageWithObject(VMManagerProtocol::ClientMessage::RunningStateChanged, extra_object);
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerClientSocket::configurationChanged() const
|
||||
{
|
||||
sendMessage(VMManagerProtocol::ClientMessage::ConfigurationChanged);
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ signals:
|
||||
|
||||
public slots:
|
||||
void clientRunningStateChanged(VMManagerProtocol::RunningState state) const;
|
||||
void configurationChanged() const;
|
||||
|
||||
private:
|
||||
QString server_name;
|
||||
|
||||
@@ -198,6 +198,30 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) {
|
||||
startPauseButton->setEnabled(true);
|
||||
configureButton->setEnabled(true);
|
||||
|
||||
updateConfig(passed_sysconfig);
|
||||
updateScreenshots(passed_sysconfig);
|
||||
|
||||
ui->systemLabel->setText(passed_sysconfig->displayName);
|
||||
ui->statusLabel->setText(sysconfig->process->processId() == 0 ?
|
||||
tr("Not running") :
|
||||
QString("%1: PID %2").arg(tr("Running"), QString::number(sysconfig->process->processId())));
|
||||
ui->notesTextEdit->setPlainText(passed_sysconfig->notes);
|
||||
ui->notesTextEdit->setEnabled(true);
|
||||
|
||||
disconnect(sysconfig->process, &QProcess::stateChanged, this, &VMManagerDetails::updateProcessStatus);
|
||||
connect(sysconfig->process, &QProcess::stateChanged, this, &VMManagerDetails::updateProcessStatus);
|
||||
|
||||
disconnect(sysconfig, &VMManagerSystem::windowStatusChanged, this, &VMManagerDetails::updateWindowStatus);
|
||||
connect(sysconfig, &VMManagerSystem::windowStatusChanged, this, &VMManagerDetails::updateWindowStatus);
|
||||
|
||||
disconnect(sysconfig, &VMManagerSystem::clientProcessStatusChanged, this, &VMManagerDetails::updateProcessStatus);
|
||||
connect(sysconfig, &VMManagerSystem::clientProcessStatusChanged, this, &VMManagerDetails::updateProcessStatus);
|
||||
|
||||
updateProcessStatus();
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerDetails::updateConfig(VMManagerSystem *passed_sysconfig) {
|
||||
// Each detail section here has its own VMManagerDetailSection.
|
||||
// When a system is selected in the list view it is updated here, through this object:
|
||||
// * First you clear it with VMManagerDetailSection::clear()
|
||||
@@ -242,6 +266,10 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) {
|
||||
portsSection->addSection(tr("Serial Ports"), passed_sysconfig->getDisplayValue(Display::Name::Serial));
|
||||
portsSection->addSection(tr("Parallel Ports"), passed_sysconfig->getDisplayValue(Display::Name::Parallel));
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerDetails::updateScreenshots(VMManagerSystem *passed_sysconfig) {
|
||||
// Disable screenshot navigation buttons by default
|
||||
ui->screenshotNext->setEnabled(false);
|
||||
ui->screenshotPrevious->setEnabled(false);
|
||||
@@ -286,24 +314,6 @@ VMManagerDetails::updateData(VMManagerSystem *passed_sysconfig) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ui->systemLabel->setText(passed_sysconfig->displayName);
|
||||
ui->statusLabel->setText(sysconfig->process->processId() == 0 ?
|
||||
tr("Not running") :
|
||||
QString("%1: PID %2").arg(tr("Running"), QString::number(sysconfig->process->processId())));
|
||||
ui->notesTextEdit->setPlainText(passed_sysconfig->notes);
|
||||
ui->notesTextEdit->setEnabled(true);
|
||||
|
||||
disconnect(sysconfig->process, &QProcess::stateChanged, this, &VMManagerDetails::updateProcessStatus);
|
||||
connect(sysconfig->process, &QProcess::stateChanged, this, &VMManagerDetails::updateProcessStatus);
|
||||
|
||||
disconnect(sysconfig, &VMManagerSystem::windowStatusChanged, this, &VMManagerDetails::updateWindowStatus);
|
||||
connect(sysconfig, &VMManagerSystem::windowStatusChanged, this, &VMManagerDetails::updateWindowStatus);
|
||||
|
||||
disconnect(sysconfig, &VMManagerSystem::clientProcessStatusChanged, this, &VMManagerDetails::updateProcessStatus);
|
||||
connect(sysconfig, &VMManagerSystem::clientProcessStatusChanged, this, &VMManagerDetails::updateProcessStatus);
|
||||
|
||||
updateProcessStatus();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -67,6 +67,8 @@ private:
|
||||
QToolButton *configureButton;
|
||||
QToolButton *cadButton;
|
||||
|
||||
void updateConfig(VMManagerSystem *passed_sysconfig);
|
||||
void updateScreenshots(VMManagerSystem *passed_sysconfig);
|
||||
static QWidget* createHorizontalLine(int leftSpacing = 25, int rightSpacing = 25);
|
||||
// QVBoxLayout *detailsLayout;
|
||||
private slots:
|
||||
|
||||
@@ -181,9 +181,11 @@ VMManagerMain::currentSelectionChanged(const QModelIndex ¤t,
|
||||
return;
|
||||
}
|
||||
|
||||
disconnect(selected_sysconfig, &VMManagerSystem::configurationChanged, this, &VMManagerMain::onConfigUpdated);
|
||||
const auto mapped_index = proxy_model->mapToSource(current);
|
||||
selected_sysconfig = vm_model->getConfigObjectForIndex(mapped_index);
|
||||
vm_details->updateData(selected_sysconfig);
|
||||
connect(selected_sysconfig, &VMManagerSystem::configurationChanged, this, &VMManagerMain::onConfigUpdated);
|
||||
|
||||
// Emit that the selection changed, include with the process state
|
||||
emit selectionChanged(current, selected_sysconfig->process->state());
|
||||
@@ -309,6 +311,12 @@ VMManagerMain::currentSelectionIsValid() const
|
||||
return ui->listView->currentIndex().isValid() && selected_sysconfig->isValid();
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMain::onConfigUpdated(const QString &uuid)
|
||||
{
|
||||
if (selected_sysconfig->uuid == uuid)
|
||||
vm_details->updateData(selected_sysconfig);
|
||||
}
|
||||
// Used from MainWindow during app exit to obtain and persist the current selection
|
||||
QString
|
||||
VMManagerMain::getCurrentSelection() const
|
||||
|
||||
@@ -78,6 +78,7 @@ public slots:
|
||||
#endif
|
||||
void modelDataChange();
|
||||
void onPreferencesUpdated();
|
||||
void onConfigUpdated(const QString &uuid);
|
||||
int getActiveMachineCount();
|
||||
|
||||
private:
|
||||
|
||||
@@ -128,6 +128,8 @@ VMManagerMainWindow::vmmSelectionChanged(const QModelIndex ¤tSelection, co
|
||||
ui->actionStartPause->setIcon(QIcon(":/menuicons/qt/icons/pause.ico"));
|
||||
ui->actionStartPause->setText(tr("Pause"));
|
||||
ui->actionStartPause->setToolTip(tr("Pause"));
|
||||
disconnect(ui->actionStartPause, &QAction::triggered, vmm, &VMManagerMain::startButtonPressed);
|
||||
connect(ui->actionStartPause, &QAction::triggered, vmm, &VMManagerMain::pauseButtonPressed);
|
||||
ui->actionHard_Reset->setEnabled(true);
|
||||
ui->actionForce_Shutdown->setEnabled(true);
|
||||
ui->actionCtrl_Alt_Del->setEnabled(true);
|
||||
@@ -136,6 +138,8 @@ VMManagerMainWindow::vmmSelectionChanged(const QModelIndex ¤tSelection, co
|
||||
ui->actionStartPause->setIcon(QIcon(":/menuicons/qt/icons/run.ico"));
|
||||
ui->actionStartPause->setText(tr("Start"));
|
||||
ui->actionStartPause->setToolTip(tr("Start"));
|
||||
disconnect(ui->actionStartPause, &QAction::triggered, vmm, &VMManagerMain::pauseButtonPressed);
|
||||
connect(ui->actionStartPause, &QAction::triggered, vmm, &VMManagerMain::startButtonPressed);
|
||||
ui->actionHard_Reset->setEnabled(false);
|
||||
ui->actionForce_Shutdown->setEnabled(false);
|
||||
ui->actionCtrl_Alt_Del->setEnabled(false);
|
||||
|
||||
@@ -113,6 +113,12 @@ VMManagerModel::reload(QWidget* parent)
|
||||
// TODO: Remove missing configs
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerModel::refreshConfigs() {
|
||||
for ( const auto& each_config : machines)
|
||||
each_config->reloadConfig();
|
||||
}
|
||||
|
||||
QModelIndex
|
||||
VMManagerModel::getIndexForConfigFile(const QFileInfo& config_file)
|
||||
{
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
void updateDisplayName(const QModelIndex &index, const QString &newDisplayName);
|
||||
QHash <QString, int> getProcessStats();
|
||||
int getActiveMachineCount();
|
||||
void refreshConfigs();
|
||||
signals:
|
||||
void systemDataChanged();
|
||||
|
||||
|
||||
@@ -91,6 +91,8 @@ VMManagerProtocol::getClientMessageType(const QJsonObject &json_document)
|
||||
return VMManagerProtocol::ClientMessage::WindowUnblocked;
|
||||
} else if (message_type == "RunningStateChanged") {
|
||||
return VMManagerProtocol::ClientMessage::RunningStateChanged;
|
||||
} else if (message_type == "ConfigurationChanged") {
|
||||
return VMManagerProtocol::ClientMessage::ConfigurationChanged;
|
||||
} else if (message_type == "WinIdMessage") {
|
||||
return VMManagerProtocol::ClientMessage::WinIdMessage;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ public:
|
||||
WindowBlocked,
|
||||
WindowUnblocked,
|
||||
RunningStateChanged,
|
||||
ConfigurationChanged,
|
||||
WinIdMessage,
|
||||
UnknownMessage,
|
||||
};
|
||||
|
||||
@@ -185,6 +185,10 @@ VMManagerServerSocket::jsonReceived(const QJsonObject &json)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VMManagerProtocol::ClientMessage::ConfigurationChanged:
|
||||
qDebug("Configuration change received from client");
|
||||
emit configurationChanged();
|
||||
break;
|
||||
default:
|
||||
qDebug("Unknown client message type received:");
|
||||
qDebug() << json;
|
||||
|
||||
@@ -75,6 +75,7 @@ signals:
|
||||
void dataReceived();
|
||||
void windowStatusChanged(int status);
|
||||
void runningStatusChanged(VMManagerProtocol::RunningState state);
|
||||
void configurationChanged();
|
||||
void winIdReceived(WId id);
|
||||
|
||||
|
||||
|
||||
@@ -482,6 +482,8 @@ VMManagerSystem::launchSettings() {
|
||||
qInfo().nospace().noquote() << "Abnormal program termination while launching settings: exit code " << exitCode << ", exit status " << exitStatus;
|
||||
return;
|
||||
}
|
||||
|
||||
configurationChangeReceived();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -818,6 +820,7 @@ VMManagerSystem::startServer() {
|
||||
connect(socket_server, &VMManagerServerSocket::dataReceived, this, &VMManagerSystem::dataReceived);
|
||||
connect(socket_server, &VMManagerServerSocket::windowStatusChanged, this, &VMManagerSystem::windowStatusChangeReceived);
|
||||
connect(socket_server, &VMManagerServerSocket::runningStatusChanged, this, &VMManagerSystem::runningStatusChangeReceived);
|
||||
connect(socket_server, &VMManagerServerSocket::configurationChanged, this, &VMManagerSystem::configurationChangeReceived);
|
||||
connect(socket_server, &VMManagerServerSocket::winIdReceived, this, [this] (WId id) { this->id = id; });
|
||||
return true;
|
||||
} else {
|
||||
@@ -956,6 +959,12 @@ VMManagerSystem::runningStatusChangeReceived(VMManagerProtocol::RunningState sta
|
||||
processStatusChanged();
|
||||
}
|
||||
void
|
||||
VMManagerSystem::configurationChangeReceived()
|
||||
{
|
||||
reloadConfig();
|
||||
emit configurationChanged(this->uuid);
|
||||
}
|
||||
void
|
||||
VMManagerSystem::reloadConfig()
|
||||
{
|
||||
loadSettings();
|
||||
|
||||
@@ -148,6 +148,7 @@ signals:
|
||||
void windowStatusChanged();
|
||||
void itemDataChanged();
|
||||
void clientProcessStatusChanged();
|
||||
void configurationChanged(const QString &uuid);
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
@@ -188,6 +189,7 @@ private:
|
||||
void dataReceived();
|
||||
void windowStatusChangeReceived(int status);
|
||||
void runningStatusChangeReceived(VMManagerProtocol::RunningState state);
|
||||
void configurationChangeReceived();
|
||||
void processStatusChanged();
|
||||
void statusRefresh();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user