refactor: SettingsDialog, support LanguageChange Event
This commit is contained in:
committed by
Chris Rizzitello
parent
84d2c56b54
commit
73e44916e7
@ -38,15 +38,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, const IServerConfig &serverConfi
|
||||
ui->comboLanguage->addItems(I18N::detectedLanguages());
|
||||
ui->comboLanguage->setCurrentText(I18N::currentLanguage());
|
||||
|
||||
// Set Tooltip for the logLevel Items
|
||||
ui->comboLogLevel->setItemData(0, tr("Required messages"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(1, tr("Non-fatal errors"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(2, tr("General warnings"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(3, tr("Notable events"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(4, tr("General events [Default]"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(5, tr("Debug entries"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(6, tr("More debug output"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(7, tr("Verbose debug output"), Qt::ToolTipRole);
|
||||
updateText();
|
||||
|
||||
ui->comboTlsKeyLength->setItemIcon(0, QIcon::fromTheme(QStringLiteral("security-medium")));
|
||||
ui->comboTlsKeyLength->setItemIcon(1, QIcon::fromTheme(QIcon::ThemeIcon::SecurityHigh));
|
||||
@ -69,6 +61,15 @@ SettingsDialog::SettingsDialog(QWidget *parent, const IServerConfig &serverConfi
|
||||
initConnections();
|
||||
}
|
||||
|
||||
void SettingsDialog::changeEvent(QEvent *e)
|
||||
{
|
||||
QDialog::changeEvent(e);
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
updateText();
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::initConnections() const
|
||||
{
|
||||
connect(this, &SettingsDialog::shown, this, &SettingsDialog::showReadOnlyMessage, Qt::QueuedConnection);
|
||||
@ -142,6 +143,19 @@ void SettingsDialog::showReadOnlyMessage()
|
||||
messages::showReadOnlySettings(this, Settings::settingsFile());
|
||||
}
|
||||
|
||||
void SettingsDialog::updateText()
|
||||
{
|
||||
// Set Tooltip for the logLevel Items
|
||||
ui->comboLogLevel->setItemData(0, tr("Required messages"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(1, tr("Non-fatal errors"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(2, tr("General warnings"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(3, tr("Notable events"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(4, tr("General events [Default]"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(5, tr("Debug entries"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(6, tr("More debug output"), Qt::ToolTipRole);
|
||||
ui->comboLogLevel->setItemData(7, tr("Verbose debug output"), Qt::ToolTipRole);
|
||||
}
|
||||
|
||||
void SettingsDialog::accept()
|
||||
{
|
||||
Settings::setValue(Settings::Core::Port, ui->sbPort->value());
|
||||
|
||||
@ -33,6 +33,9 @@ public:
|
||||
Q_SIGNALS:
|
||||
void shown();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
private:
|
||||
void initConnections() const;
|
||||
void regenCertificates();
|
||||
@ -45,6 +48,7 @@ private:
|
||||
void updateTlsControls();
|
||||
void updateTlsControlsEnabled();
|
||||
void showReadOnlyMessage();
|
||||
void updateText();
|
||||
|
||||
/// @brief Load all settings.
|
||||
void loadFromConfig();
|
||||
|
||||
Reference in New Issue
Block a user