refactor: Settings Dialog, update security layout

This commit is contained in:
sithlord48
2025-02-26 23:26:34 -05:00
committed by Nick Bolton
parent 3ae2de52f4
commit bae494476b
2 changed files with 74 additions and 81 deletions

View File

@ -66,7 +66,7 @@ void SettingsDialog::initConnections()
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &SettingsDialog::accept);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &SettingsDialog::reject);
connect(ui->cbEnableTls, &QCheckBox::toggled, this, &SettingsDialog::updateTlsControlsEnabled);
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->btnTlsCertPath, &QPushButton::clicked, this, &SettingsDialog::browseCertificatePath);
@ -156,7 +156,7 @@ void SettingsDialog::accept()
m_appConfig.setPreventSleep(ui->cbPreventSleep->isChecked());
m_appConfig.setTlsCertPath(ui->lineTlsCertPath->text());
m_appConfig.setTlsKeyLength(ui->comboTlsKeyLength->currentText().toInt());
m_appConfig.setTlsEnabled(ui->cbEnableTls->isChecked());
m_appConfig.setTlsEnabled(ui->groupSecurity->isChecked());
m_appConfig.setLanguageSync(ui->cbLanguageSync->isChecked());
m_appConfig.setInvertScrollDirection(ui->cbScrollDirection->isChecked());
m_appConfig.setEnableService(ui->cbServiceEnabled->isChecked());
@ -230,9 +230,9 @@ void SettingsDialog::updateTlsControls()
ui->lineTlsCertPath->setText(m_appConfig.tlsCertPath());
ui->cbRequireClientCert->setChecked(m_appConfig.requireClientCerts());
ui->cbEnableTls->setChecked(tlsEnabled);
ui->groupSecurity->setChecked(tlsEnabled);
ui->cbEnableTls->setEnabled(writable);
ui->groupSecurity->setEnabled(writable);
ui->comboTlsKeyLength->setEnabled(enabled);
ui->widgetTlsCert->setEnabled(enabled);
ui->lblTlsKeyLength->setEnabled(enabled);
@ -244,7 +244,7 @@ void SettingsDialog::updateTlsControlsEnabled()
{
const auto writable = m_appConfig.isActiveScopeWritable();
const auto clientMode = m_appConfig.clientGroupChecked();
const auto tlsChecked = ui->cbEnableTls->isChecked();
const auto tlsChecked = ui->groupSecurity->isChecked();
auto enabled = writable && tlsChecked && !clientMode;
ui->lblTlsKeyLength->setEnabled(enabled);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>550</width>
<height>684</height>
<height>612</height>
</rect>
</property>
<property name="windowTitle">
@ -145,11 +145,14 @@
</sizepolicy>
</property>
<property name="title">
<string>Security</string>
<string>Enable TLS Encryption</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>5</number>
<number>6</number>
</property>
<property name="topMargin">
<number>9</number>
@ -157,77 +160,21 @@
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="cbEnableTls">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Enable TLS encryption</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lblTlsKeyLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Key length</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboTlsKeyLength">
<property name="currentText">
<string>1024</string>
</property>
<item>
<property name="text">
<string>1024</string>
</property>
</item>
<item>
<property name="text">
<string>2048</string>
</property>
</item>
<item>
<property name="text">
<string>4096</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widgetTlsCert" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lblTlsCert">
<property name="sizePolicy">
@ -251,7 +198,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>30</width>
<width>20</width>
<height>20</height>
</size>
</property>
@ -287,12 +234,47 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="topMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_4">
<widget class="QLabel" name="lblTlsKeyLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Key length</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboTlsKeyLength">
<property name="currentText">
<string>1024</string>
</property>
<item>
<property name="text">
<string>1024</string>
</property>
</item>
<item>
<property name="text">
<string>2048</string>
</property>
</item>
<item>
<property name="text">
<string>4096</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
@ -745,20 +727,31 @@
</layout>
</widget>
<tabstops>
<tabstop>sbPort</tabstop>
<tabstop>lineInterface</tabstop>
<tabstop>cbEnableTls</tabstop>
<tabstop>comboTlsKeyLength</tabstop>
<tabstop>cbPreventSleep</tabstop>
<tabstop>cbLanguageSync</tabstop>
<tabstop>cbScrollDirection</tabstop>
<tabstop>cbAutoUpdate</tabstop>
<tabstop>cbCloseToTray</tabstop>
<tabstop>cbAutoHide</tabstop>
<tabstop>rbIconColorful</tabstop>
<tabstop>rbIconMono</tabstop>
<tabstop>groupSecurity</tabstop>
<tabstop>lineTlsCertPath</tabstop>
<tabstop>btnTlsCertPath</tabstop>
<tabstop>comboTlsKeyLength</tabstop>
<tabstop>btnTlsRegenCert</tabstop>
<tabstop>cbRequireClientCert</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>sbPort</tabstop>
<tabstop>lineInterface</tabstop>
<tabstop>cbLogToFile</tabstop>
<tabstop>comboLogLevel</tabstop>
<tabstop>lineLogFilename</tabstop>
<tabstop>btnBrowseLog</tabstop>
<tabstop>cbServiceEnabled</tabstop>
<tabstop>comboElevate</tabstop>
<tabstop>rbScopeUser</tabstop>
<tabstop>rbScopeSystem</tabstop>
<tabstop>comboElevate</tabstop>
</tabstops>
<resources/>
<connections/>