refactor: SettingsDialog update ux for initial window state

This commit is contained in:
sithlord48
2026-03-04 16:54:49 -05:00
committed by Nick Bolton
parent 8f8874370e
commit 90e79dad75
8 changed files with 121 additions and 61 deletions

View File

@ -115,9 +115,9 @@ void SettingsDialog::initConnections() const
connect(ui->comboInterface, &QComboBox::currentIndexChanged, this, &SettingsDialog::setButtonBoxEnabledButtons); connect(ui->comboInterface, &QComboBox::currentIndexChanged, this, &SettingsDialog::setButtonBoxEnabledButtons);
connect(ui->comboTlsKeyLength, &QComboBox::currentIndexChanged, this, &SettingsDialog::setButtonBoxEnabledButtons); connect(ui->comboTlsKeyLength, &QComboBox::currentIndexChanged, this, &SettingsDialog::setButtonBoxEnabledButtons);
connect(ui->comboLanguage, &QComboBox::currentIndexChanged, this, &SettingsDialog::setButtonBoxEnabledButtons); connect(ui->comboLanguage, &QComboBox::currentIndexChanged, this, &SettingsDialog::setButtonBoxEnabledButtons);
connect(ui->cbAutoHide, &QCheckBox::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons); connect(ui->rbAutoHide, &QRadioButton::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons);
connect(ui->cbPreventSleep, &QCheckBox::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons); connect(ui->cbPreventSleep, &QCheckBox::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons);
connect(ui->rbCloseToTray, &QCheckBox::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons); connect(ui->rbCloseToTray, &QRadioButton::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons);
connect(ui->cbElevateDaemon, &QCheckBox::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons); connect(ui->cbElevateDaemon, &QCheckBox::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons);
connect(ui->cbAutoUpdate, &QCheckBox::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons); connect(ui->cbAutoUpdate, &QCheckBox::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons);
connect(ui->cbGuiDebug, &QCheckBox::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons); connect(ui->cbGuiDebug, &QCheckBox::toggled, this, &SettingsDialog::setButtonBoxEnabledButtons);
@ -211,7 +211,7 @@ void SettingsDialog::accept()
Settings::setValue(Settings::Log::ToFile, ui->groupLogToFile->isChecked()); Settings::setValue(Settings::Log::ToFile, ui->groupLogToFile->isChecked());
Settings::setValue(Settings::Log::File, ui->lineLogFilename->text()); Settings::setValue(Settings::Log::File, ui->lineLogFilename->text());
Settings::setValue(Settings::Daemon::Elevate, ui->cbElevateDaemon->isChecked()); Settings::setValue(Settings::Daemon::Elevate, ui->cbElevateDaemon->isChecked());
Settings::setValue(Settings::Gui::Autohide, ui->cbAutoHide->isChecked()); Settings::setValue(Settings::Gui::Autohide, ui->rbAutoHide->isChecked());
Settings::setValue(Settings::Gui::AutoUpdateCheck, ui->cbAutoUpdate->isChecked()); Settings::setValue(Settings::Gui::AutoUpdateCheck, ui->cbAutoUpdate->isChecked());
Settings::setValue(Settings::Core::PreventSleep, ui->cbPreventSleep->isChecked()); Settings::setValue(Settings::Core::PreventSleep, ui->cbPreventSleep->isChecked());
Settings::setValue(Settings::Security::Certificate, ui->lineTlsCertPath->text()); Settings::setValue(Settings::Security::Certificate, ui->lineTlsCertPath->text());
@ -241,7 +241,6 @@ void SettingsDialog::loadFromConfig()
ui->comboLogLevel->setCurrentIndex(Settings::value(Settings::Log::Level).toInt()); ui->comboLogLevel->setCurrentIndex(Settings::value(Settings::Log::Level).toInt());
ui->groupLogToFile->setChecked(Settings::value(Settings::Log::ToFile).toBool()); ui->groupLogToFile->setChecked(Settings::value(Settings::Log::ToFile).toBool());
ui->lineLogFilename->setText(Settings::value(Settings::Log::File).toString()); ui->lineLogFilename->setText(Settings::value(Settings::Log::File).toString());
ui->cbAutoHide->setChecked(Settings::value(Settings::Gui::Autohide).toBool());
ui->cbPreventSleep->setChecked(Settings::value(Settings::Core::PreventSleep).toBool()); ui->cbPreventSleep->setChecked(Settings::value(Settings::Core::PreventSleep).toBool());
ui->cbElevateDaemon->setChecked(Settings::value(Settings::Daemon::Elevate).toBool()); ui->cbElevateDaemon->setChecked(Settings::value(Settings::Daemon::Elevate).toBool());
ui->cbAutoUpdate->setChecked(Settings::value(Settings::Gui::AutoUpdateCheck).toBool()); ui->cbAutoUpdate->setChecked(Settings::value(Settings::Gui::AutoUpdateCheck).toBool());
@ -260,6 +259,10 @@ void SettingsDialog::loadFromConfig()
else else
ui->rbIconColorful->setChecked(true); ui->rbIconColorful->setChecked(true);
const auto autoHide = Settings::value(Settings::Gui::Autohide).toBool();
ui->rbAutoHide->setChecked(autoHide);
ui->rbShowOnStart->setChecked(!autoHide);
const auto closeToTray = Settings::value(Settings::Gui::CloseToTray).toBool(); const auto closeToTray = Settings::value(Settings::Gui::CloseToTray).toBool();
ui->rbCloseToTray->setChecked(closeToTray); ui->rbCloseToTray->setChecked(closeToTray);
ui->rbExitOnClose->setChecked(!closeToTray); ui->rbExitOnClose->setChecked(!closeToTray);
@ -345,7 +348,8 @@ void SettingsDialog::updateControls()
ui->comboInterface->setEnabled(writable); ui->comboInterface->setEnabled(writable);
ui->comboLogLevel->setEnabled(writable); ui->comboLogLevel->setEnabled(writable);
ui->groupLogToFile->setEnabled(writable); ui->groupLogToFile->setEnabled(writable);
ui->cbAutoHide->setEnabled(writable); ui->rbAutoHide->setEnabled(writable);
ui->rbShowOnStart->setEnabled(writable);
ui->cbAutoUpdate->setEnabled(writable); ui->cbAutoUpdate->setEnabled(writable);
ui->cbPreventSleep->setEnabled(writable); ui->cbPreventSleep->setEnabled(writable);
ui->lineTlsCertPath->setEnabled(writable); ui->lineTlsCertPath->setEnabled(writable);
@ -397,7 +401,7 @@ bool SettingsDialog::isModified() const
(ui->comboLogLevel->currentIndex() != Settings::value(Settings::Log::Level).toInt()) || (ui->comboLogLevel->currentIndex() != Settings::value(Settings::Log::Level).toInt()) ||
(ui->groupLogToFile->isChecked() != Settings::value(Settings::Log::ToFile).toBool()) || (ui->groupLogToFile->isChecked() != Settings::value(Settings::Log::ToFile).toBool()) ||
(ui->lineLogFilename->text() != Settings::value(Settings::Log::File).toString()) || (ui->lineLogFilename->text() != Settings::value(Settings::Log::File).toString()) ||
(ui->cbAutoHide->isChecked() != Settings::value(Settings::Gui::Autohide).toBool()) || (ui->rbAutoHide->isChecked() != Settings::value(Settings::Gui::Autohide).toBool()) ||
(ui->cbPreventSleep->isChecked() != Settings::value(Settings::Core::PreventSleep).toBool()) || (ui->cbPreventSleep->isChecked() != Settings::value(Settings::Core::PreventSleep).toBool()) ||
(ui->rbCloseToTray->isChecked() != Settings::value(Settings::Gui::CloseToTray).toBool()) || (ui->rbCloseToTray->isChecked() != Settings::value(Settings::Gui::CloseToTray).toBool()) ||
(ui->cbElevateDaemon->isChecked() != Settings::value(Settings::Daemon::Elevate).toBool()) || (ui->cbElevateDaemon->isChecked() != Settings::value(Settings::Daemon::Elevate).toBool()) ||
@ -427,7 +431,7 @@ bool SettingsDialog::isDefault() const
(ui->comboLogLevel->currentIndex() == Settings::defaultValue(Settings::Log::Level).toInt()) && (ui->comboLogLevel->currentIndex() == Settings::defaultValue(Settings::Log::Level).toInt()) &&
(ui->groupLogToFile->isChecked() == Settings::defaultValue(Settings::Log::ToFile).toBool()) && (ui->groupLogToFile->isChecked() == Settings::defaultValue(Settings::Log::ToFile).toBool()) &&
(ui->lineLogFilename->text() == Settings::defaultValue(Settings::Log::File).toString()) && (ui->lineLogFilename->text() == Settings::defaultValue(Settings::Log::File).toString()) &&
(ui->cbAutoHide->isChecked() == Settings::defaultValue(Settings::Gui::Autohide).toBool()) && (ui->rbAutoHide->isChecked() == Settings::defaultValue(Settings::Gui::Autohide).toBool()) &&
(ui->cbPreventSleep->isChecked() == Settings::defaultValue(Settings::Core::PreventSleep).toBool()) && (ui->cbPreventSleep->isChecked() == Settings::defaultValue(Settings::Core::PreventSleep).toBool()) &&
(ui->rbCloseToTray->isChecked() == Settings::defaultValue(Settings::Gui::CloseToTray).toBool()) && (ui->rbCloseToTray->isChecked() == Settings::defaultValue(Settings::Gui::CloseToTray).toBool()) &&
(ui->cbElevateDaemon->isChecked() == Settings::defaultValue(Settings::Daemon::Elevate).toBool()) && (ui->cbElevateDaemon->isChecked() == Settings::defaultValue(Settings::Daemon::Elevate).toBool()) &&
@ -452,7 +456,6 @@ void SettingsDialog::resetToDefault()
ui->comboLogLevel->setCurrentIndex(Settings::defaultValue(Settings::Log::Level).toInt()); ui->comboLogLevel->setCurrentIndex(Settings::defaultValue(Settings::Log::Level).toInt());
ui->groupLogToFile->setChecked(Settings::defaultValue(Settings::Log::ToFile).toBool()); ui->groupLogToFile->setChecked(Settings::defaultValue(Settings::Log::ToFile).toBool());
ui->lineLogFilename->setText(Settings::defaultValue(Settings::Log::File).toString()); ui->lineLogFilename->setText(Settings::defaultValue(Settings::Log::File).toString());
ui->cbAutoHide->setChecked(Settings::defaultValue(Settings::Gui::Autohide).toBool());
ui->cbPreventSleep->setChecked(Settings::defaultValue(Settings::Core::PreventSleep).toBool()); ui->cbPreventSleep->setChecked(Settings::defaultValue(Settings::Core::PreventSleep).toBool());
ui->cbElevateDaemon->setChecked(Settings::defaultValue(Settings::Daemon::Elevate).toBool()); ui->cbElevateDaemon->setChecked(Settings::defaultValue(Settings::Daemon::Elevate).toBool());
ui->cbAutoUpdate->setChecked(Settings::defaultValue(Settings::Gui::AutoUpdateCheck).toBool()); ui->cbAutoUpdate->setChecked(Settings::defaultValue(Settings::Gui::AutoUpdateCheck).toBool());
@ -460,6 +463,10 @@ void SettingsDialog::resetToDefault()
ui->cbUseWlClipboard->setChecked(Settings::defaultValue(Settings::Core::UseWlClipboard).toBool()); ui->cbUseWlClipboard->setChecked(Settings::defaultValue(Settings::Core::UseWlClipboard).toBool());
ui->cbShowVersion->setChecked(Settings::defaultValue(Settings::Gui::ShowVersionInTitle).toBool()); ui->cbShowVersion->setChecked(Settings::defaultValue(Settings::Gui::ShowVersionInTitle).toBool());
const auto autoHide = Settings::defaultValue(Settings::Gui::Autohide).toBool();
ui->rbCloseToTray->setChecked(autoHide);
ui->rbExitOnClose->setChecked(!autoHide);
const auto closeToTray = Settings::defaultValue(Settings::Gui::CloseToTray).toBool(); const auto closeToTray = Settings::defaultValue(Settings::Gui::CloseToTray).toBool();
ui->rbCloseToTray->setChecked(closeToTray); ui->rbCloseToTray->setChecked(closeToTray);
ui->rbExitOnClose->setChecked(!closeToTray); ui->rbExitOnClose->setChecked(!closeToTray);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>554</width> <width>564</width>
<height>447</height> <height>431</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -139,9 +139,9 @@
<attribute name="title"> <attribute name="title">
<string>&amp;Window</string> <string>&amp;Window</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_14">
<property name="spacing"> <property name="spacing">
<number>20</number> <number>9</number>
</property> </property>
<property name="leftMargin"> <property name="leftMargin">
<number>12</number> <number>12</number>
@ -168,23 +168,39 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QCheckBox" name="cbShowVersion">
<property name="text">
<string>Include version in the window title</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbAutoHide">
<property name="text">
<string>Hide the window when the app starts</string>
</property>
</widget>
</item>
<item> <item>
<layout class="QFormLayout" name="formLayout_2"> <layout class="QFormLayout" name="formLayout_2">
<property name="labelAlignment">
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>When the application starts</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="rbShowOnStart">
<property name="text">
<string>Show the main window</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbAutoHide">
<property name="text">
<string>Send to background</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>When the main window is closed</string> <string>When the main window is closed</string>
@ -194,22 +210,35 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QRadioButton" name="rbExitOnClose">
<property name="text">
<string>Exit</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QRadioButton" name="rbCloseToTray"> <widget class="QWidget" name="widget_2" native="true">
<property name="text"> <layout class="QVBoxLayout" name="verticalLayout_13">
<string>Send to background</string> <item>
</property> <widget class="QRadioButton" name="rbExitOnClose">
<property name="text">
<string>Exit</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbCloseToTray">
<property name="text">
<string>Send to background</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="cbShowVersion">
<property name="text">
<string>Include version in the window title</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer_11"> <spacer name="verticalSpacer_11">
<property name="orientation"> <property name="orientation">

View File

@ -1081,10 +1081,6 @@ Al habilitar esta opción, se deshabilitará la interfaz gráfica de usuario (GU
<source>Check for updates on startup</source> <source>Check for updates on startup</source>
<translation type="unfinished">Buscar actualizaciones al iniciar</translation> <translation type="unfinished">Buscar actualizaciones al iniciar</translation>
</message> </message>
<message>
<source>Hide the window when the app starts</source>
<translation type="unfinished">Ocultar la ventana cuando se inicia la aplicación</translation>
</message>
<message> <message>
<source>Prevent this computer from going to sleep</source> <source>Prevent this computer from going to sleep</source>
<translation type="unfinished">Evitar que esta computadora entre en modo de suspensión</translation> <translation type="unfinished">Evitar que esta computadora entre en modo de suspensión</translation>
@ -1305,6 +1301,14 @@ Al habilitar esta opción, se deshabilitará la interfaz gráfica de usuario (GU
<source>Send to background</source> <source>Send to background</source>
<translation type="unfinished">Enviar a segundo plano</translation> <translation type="unfinished">Enviar a segundo plano</translation>
</message> </message>
<message>
<source>When the application starts</source>
<translation type="unfinished">Cuando se inicia la aplicación</translation>
</message>
<message>
<source>Show the main window</source>
<translation type="unfinished">Mostrar la ventana principal</translation>
</message>
</context> </context>
<context> <context>
<name>StatusBar</name> <name>StatusBar</name>

View File

@ -1081,10 +1081,6 @@ L&apos;abilitazione di questa impostazione disabiliterà l&apos;interfaccia graf
<source>Check for updates on startup</source> <source>Check for updates on startup</source>
<translation>Controlla aggiornamenti all&apos;avvio</translation> <translation>Controlla aggiornamenti all&apos;avvio</translation>
</message> </message>
<message>
<source>Hide the window when the app starts</source>
<translation>Nascondi la finestra all&apos;avvio dell&apos;app</translation>
</message>
<message> <message>
<source>Prevent this computer from going to sleep</source> <source>Prevent this computer from going to sleep</source>
<translation>Impedisci a questo computer di andare in sospensione</translation> <translation>Impedisci a questo computer di andare in sospensione</translation>
@ -1305,6 +1301,14 @@ L&apos;abilitazione di questa impostazione disabiliterà l&apos;interfaccia graf
<source>Send to background</source> <source>Send to background</source>
<translation type="unfinished">Invia in background</translation> <translation type="unfinished">Invia in background</translation>
</message> </message>
<message>
<source>When the application starts</source>
<translation type="unfinished">Quando l&apos;applicazione si avvia</translation>
</message>
<message>
<source>Show the main window</source>
<translation type="unfinished">Mostra la finestra principale</translation>
</message>
</context> </context>
<context> <context>
<name>StatusBar</name> <name>StatusBar</name>

View File

@ -1083,10 +1083,6 @@ Enabling this setting will disable the server config GUI.</source>
<source>Check for updates on startup</source> <source>Check for updates on startup</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Hide the window when the app starts</source>
<translation></translation>
</message>
<message> <message>
<source>Prevent this computer from going to sleep</source> <source>Prevent this computer from going to sleep</source>
<translation></translation> <translation></translation>
@ -1307,6 +1303,14 @@ Enabling this setting will disable the server config GUI.</source>
<source>Send to background</source> <source>Send to background</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>When the application starts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the main window</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StatusBar</name> <name>StatusBar</name>

View File

@ -1081,10 +1081,6 @@ Enabling this setting will disable the server config GUI.</source>
<source>Check for updates on startup</source> <source>Check for updates on startup</source>
<translation> </translation> <translation> </translation>
</message> </message>
<message>
<source>Hide the window when the app starts</source>
<translation> </translation>
</message>
<message> <message>
<source>Prevent this computer from going to sleep</source> <source>Prevent this computer from going to sleep</source>
<translation> </translation> <translation> </translation>
@ -1305,6 +1301,14 @@ Enabling this setting will disable the server config GUI.</source>
<source>Send to background</source> <source>Send to background</source>
<translation type="unfinished"> </translation> <translation type="unfinished"> </translation>
</message> </message>
<message>
<source>When the application starts</source>
<translation type="unfinished"> </translation>
</message>
<message>
<source>Show the main window</source>
<translation type="unfinished"> </translation>
</message>
</context> </context>
<context> <context>
<name>StatusBar</name> <name>StatusBar</name>

View File

@ -1079,10 +1079,6 @@ Enabling this setting will disable the server config GUI.</source>
<source>Check for updates on startup</source> <source>Check for updates on startup</source>
<translation>Проверять обновления при запуске</translation> <translation>Проверять обновления при запуске</translation>
</message> </message>
<message>
<source>Hide the window when the app starts</source>
<translation>Скрывать окно при запуске</translation>
</message>
<message> <message>
<source>Prevent this computer from going to sleep</source> <source>Prevent this computer from going to sleep</source>
<translation>Запретить компьютеру переходить в спящий режим</translation> <translation>Запретить компьютеру переходить в спящий режим</translation>
@ -1303,6 +1299,14 @@ Enabling this setting will disable the server config GUI.</source>
<source>Send to background</source> <source>Send to background</source>
<translation type="unfinished">Отправить в фоновый режим</translation> <translation type="unfinished">Отправить в фоновый режим</translation>
</message> </message>
<message>
<source>When the application starts</source>
<translation type="unfinished">Когда приложение запускается</translation>
</message>
<message>
<source>Show the main window</source>
<translation type="unfinished">Показать главное окно</translation>
</message>
</context> </context>
<context> <context>
<name>StatusBar</name> <name>StatusBar</name>

View File

@ -1083,10 +1083,6 @@ Enabling this setting will disable the server config GUI.</source>
<source>Check for updates on startup</source> <source>Check for updates on startup</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Hide the window when the app starts</source>
<translation></translation>
</message>
<message> <message>
<source>Prevent this computer from going to sleep</source> <source>Prevent this computer from going to sleep</source>
<translation></translation> <translation></translation>
@ -1307,6 +1303,14 @@ Enabling this setting will disable the server config GUI.</source>
<source>Send to background</source> <source>Send to background</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>When the application starts</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Show the main window</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>StatusBar</name> <name>StatusBar</name>