diff --git a/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp b/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp index ad12f6f6d..b6d99fd1c 100644 --- a/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp +++ b/src/apps/deskflow-gui/dialogs/SettingsDialog.cpp @@ -34,6 +34,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const IServerConfig &serverConfi ui->comboTlsKeyLength->setItemIcon(0, QIcon::fromTheme(QIcon::ThemeIcon::SecurityLow)); ui->comboTlsKeyLength->setItemIcon(1, QIcon::fromTheme(QStringLiteral("security-medium"))); ui->comboTlsKeyLength->setItemIcon(2, QIcon::fromTheme(QIcon::ThemeIcon::SecurityHigh)); + ui->lblTlsCertInfo->setFixedSize(28, 28); ui->rbIconMono->setIcon(QIcon::fromTheme(QStringLiteral("deskflow-symbolic"))); ui->rbIconColorful->setIcon(QIcon::fromTheme(QStringLiteral("deskflow"))); @@ -64,6 +65,7 @@ void SettingsDialog::initConnections() connect(ui->groupSecurity, &QGroupBox::toggled, this, &SettingsDialog::updateTlsControlsEnabled); connect(ui->cbServiceEnabled, &QCheckBox::toggled, this, &SettingsDialog::updateControls); connect(ui->btnTlsRegenCert, &QPushButton::clicked, this, &SettingsDialog::regenCertificates); + connect(ui->comboTlsKeyLength, &QComboBox::currentIndexChanged, this, &SettingsDialog::updateRequestedKeySize); connect(ui->btnTlsCertPath, &QPushButton::clicked, this, &SettingsDialog::browseCertificatePath); connect(ui->btnBrowseLog, &QPushButton::clicked, this, &SettingsDialog::browseLogPath); connect(ui->cbLogToFile, &QCheckBox::toggled, this, &SettingsDialog::setLogToFile); @@ -73,6 +75,8 @@ void SettingsDialog::regenCertificates() { if (m_tlsUtility.generateCertificate()) { QMessageBox::information(this, tr("TLS Certificate Regenerated"), tr("TLS certificate regenerated successfully.")); + const auto certificate = Settings::value(Settings::Security::Certificate).toString(); + updateKeyLengthOnFile(certificate); } } @@ -184,11 +188,10 @@ void SettingsDialog::updateTlsControls() const auto certificate = Settings::value(Settings::Security::Certificate).toString(); if (QFile(certificate).exists()) { updateKeyLengthOnFile(certificate); - } else { - const auto keyLengthText = Settings::value(Settings::Security::KeySize).toString(); - ui->comboTlsKeyLength->setCurrentText(keyLengthText); } + ui->comboTlsKeyLength->setCurrentText(Settings::value(Settings::Security::KeySize).toString()); + const auto tlsEnabled = Settings::value(Settings::Security::TlsEnabled).toBool(); const auto writable = Settings::isWritable(); const auto enabled = writable && tlsEnabled; @@ -234,8 +237,14 @@ void SettingsDialog::updateKeyLengthOnFile(const QString &path) } auto length = ssl.getCertKeyLength(path); - ui->comboTlsKeyLength->setCurrentText(QString::number(length)); - Settings::setValue(Settings::Security::KeySize, length); + QPixmap labelIcon = QPixmap(QIcon::fromTheme(QIcon::ThemeIcon::SecurityLow).pixmap(24, 24)); + if (length == 2048) + labelIcon = QPixmap(QIcon::fromTheme(QStringLiteral("security-medium")).pixmap(24, 24)); + if (length == 4096) + labelIcon = QPixmap(QIcon::fromTheme(QIcon::ThemeIcon::SecurityHigh).pixmap(24, 24)); + + ui->lblTlsCertInfo->setPixmap(labelIcon); + ui->lblTlsCertInfo->setToolTip(QStringLiteral("Key length: %1 bits").arg(QString::number(length))); } void SettingsDialog::updateControls() @@ -275,4 +284,11 @@ void SettingsDialog::updateControls() updateTlsControls(); } +void SettingsDialog::updateRequestedKeySize() +{ + if (ui->comboTlsKeyLength->currentText() == Settings::value(Settings::Security::KeySize).toString()) + return; + Settings::setValue(Settings::Security::KeySize, ui->comboTlsKeyLength->currentText()); +} + SettingsDialog::~SettingsDialog() = default; diff --git a/src/apps/deskflow-gui/dialogs/SettingsDialog.h b/src/apps/deskflow-gui/dialogs/SettingsDialog.h index e686a54c6..cd133e0c0 100644 --- a/src/apps/deskflow-gui/dialogs/SettingsDialog.h +++ b/src/apps/deskflow-gui/dialogs/SettingsDialog.h @@ -58,6 +58,9 @@ private: /// @brief Enables controls when they should be. void updateControls(); + /// @brief updates the setting vaule for key size. + void updateRequestedKeySize(); + std::unique_ptr ui; const IServerConfig &m_serverConfig; const CoreProcess &m_coreProcess; diff --git a/src/apps/deskflow-gui/dialogs/SettingsDialog.ui b/src/apps/deskflow-gui/dialogs/SettingsDialog.ui index a9637e94d..bf01dda3b 100644 --- a/src/apps/deskflow-gui/dialogs/SettingsDialog.ui +++ b/src/apps/deskflow-gui/dialogs/SettingsDialog.ui @@ -163,6 +163,13 @@ 0 + + + + + + + @@ -176,22 +183,6 @@ - - - - Qt::Orientation::Horizontal - - - QSizePolicy::Policy::Minimum - - - - 20 - 20 - - - -