fix: SetttingsDialog KeySize Combobox does not set key length
fixes #8380
This commit is contained in:
parent
96b50b7d1c
commit
e624e6f174
3 changed files with 31 additions and 21 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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::SettingsDialog> ui;
|
||||
const IServerConfig &m_serverConfig;
|
||||
const CoreProcess &m_coreProcess;
|
||||
|
|
|
|||
|
|
@ -163,6 +163,13 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblTlsCertInfo">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblTlsCert">
|
||||
<property name="sizePolicy">
|
||||
|
|
@ -176,22 +183,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Policy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineTlsCertPath">
|
||||
<property name="minimumSize">
|
||||
|
|
|
|||
Loading…
Reference in a new issue