fix: user can not start in client mode without a remote host

do not auto start the client if the remote host is empty
fixes #8478
This commit is contained in:
sithlord48 2025-04-19 13:26:41 -04:00 committed by Nick Bolton
parent fcaadc2cd4
commit 17c7b0f8bf
2 changed files with 25 additions and 1 deletions

View file

@ -320,7 +320,7 @@ void MainWindow::connectSlots()
connect(ui->btnConnect, &QPushButton::clicked, this, &MainWindow::resetCore); connect(ui->btnConnect, &QPushButton::clicked, this, &MainWindow::resetCore);
connect(ui->lineHostname, &QLineEdit::returnPressed, ui->btnConnect, &QPushButton::click); connect(ui->lineHostname, &QLineEdit::returnPressed, ui->btnConnect, &QPushButton::click);
connect(ui->lineHostname, &QLineEdit::textChanged, &m_coreProcess, &deskflow::gui::CoreProcess::setAddress); connect(ui->lineHostname, &QLineEdit::textChanged, this, &MainWindow::remoteHostChanged);
connect(ui->btnSaveServerConfig, &QPushButton::clicked, this, &MainWindow::saveServerConfig); connect(ui->btnSaveServerConfig, &QPushButton::clicked, this, &MainWindow::saveServerConfig);
connect(ui->btnConfigureServer, &QPushButton::clicked, this, [this] { showConfigureServer(""); }); connect(ui->btnConfigureServer, &QPushButton::clicked, this, [this] { showConfigureServer(""); });
@ -379,6 +379,8 @@ void MainWindow::firstShown()
} }
if (Settings::value(Settings::Core::StartedBefore).toBool()) { if (Settings::value(Settings::Core::StartedBefore).toBool()) {
if (ui->rbModeClient->isChecked() && ui->lineHostname->text().isEmpty())
return;
m_coreProcess.start(); m_coreProcess.start();
} }
} }
@ -585,6 +587,8 @@ void MainWindow::updateModeControls(bool serverMode)
m_coreProcess.start(); m_coreProcess.start();
} }
} }
toggleCanRunCore((!serverMode && !ui->lineHostname->text().isEmpty()) || serverMode);
} }
void MainWindow::updateSecurityIcon(bool visible) void MainWindow::updateSecurityIcon(bool visible)
@ -1144,3 +1148,21 @@ void MainWindow::daemonIpcClientConnectFailed()
m_coreProcess.retryDaemon(); m_coreProcess.retryDaemon();
} }
} }
void MainWindow::toggleCanRunCore(bool enableButtons)
{
ui->btnToggleCore->setEnabled(enableButtons);
ui->btnConnect->setEnabled(enableButtons);
ui->btnApplySettings->setEnabled(enableButtons);
m_actionStartCore->setEnabled(enableButtons);
m_actionStopCore->setEnabled(enableButtons);
}
void MainWindow::remoteHostChanged(const QString newRemoteHost)
{
m_coreProcess.setAddress(newRemoteHost);
toggleCanRunCore(!newRemoteHost.isEmpty() && ui->rbModeClient->isChecked());
if (newRemoteHost.isEmpty()) {
Settings::setValue(Settings::Client::RemoteHost, QVariant());
}
}

View file

@ -159,6 +159,8 @@ private:
void showHostNameEditor(); void showHostNameEditor();
void setHostName(); void setHostName();
void daemonIpcClientConnectFailed(); void daemonIpcClientConnectFailed();
void toggleCanRunCore(bool enableButtons);
void remoteHostChanged(const QString newRemoteHost);
/** /**
* @brief trustedFingerprintDb get the fingerprintDb for the trusted clients or trusted servers. * @brief trustedFingerprintDb get the fingerprintDb for the trusted clients or trusted servers.