From c91b924f0ebec0ddcf72fca3bf144c82ea83ff99 Mon Sep 17 00:00:00 2001 From: tt2468 Date: Wed, 28 Apr 2021 12:18:46 -0700 Subject: [PATCH] SettingsDialog: Server port had no logic for some reason. Also restart server if settings are changed --- src/forms/SettingsDialog.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/forms/SettingsDialog.cpp b/src/forms/SettingsDialog.cpp index 4d28f089..f0dc9045 100644 --- a/src/forms/SettingsDialog.cpp +++ b/src/forms/SettingsDialog.cpp @@ -50,6 +50,7 @@ void SettingsDialog::showEvent(QShowEvent *event) ui->enableAuthenticationCheckBox->setChecked(conf->AuthRequired); ui->serverPasswordLineEdit->setText(conf->ServerPassword); ui->serverPasswordLineEdit->setEnabled(conf->AuthRequired); + ui->serverPortSpinBox->setValue(conf->ServerPort); FillSessionTable(); @@ -121,13 +122,34 @@ void SettingsDialog::FormAccepted() return; } + bool needsRestart = false; + + if (conf->ServerEnabled != ui->enableWebSocketServerCheckBox->isChecked()) { + needsRestart = true; + } else if (conf->AuthRequired != ui->enableAuthenticationCheckBox->isChecked()) { + needsRestart = true; + } else if (conf->ServerPassword != ui->serverPasswordLineEdit->text()) { + needsRestart = true; + } else if (conf->ServerPort != ui->serverPortSpinBox->value()) { + needsRestart = true; + } + conf->ServerEnabled = ui->enableWebSocketServerCheckBox->isChecked(); conf->AlertsEnabled = ui->enableSystemTrayAlertsCheckBox->isChecked(); conf->DebugEnabled = ui->enableDebugLoggingCheckBox->isChecked(); conf->AuthRequired = ui->enableAuthenticationCheckBox->isChecked(); conf->ServerPassword = ui->serverPasswordLineEdit->text(); + conf->ServerPort = ui->serverPortSpinBox->value(); conf->Save(); + + if (needsRestart) { + auto server = GetWebSocketServer(); + server->Stop(); + if (conf->ServerEnabled) { + server->Start(); + } + } } void SettingsDialog::EnableAuthenticationCheckBoxChanged()