refactor(settingsDialog): populate log level combo using known levels and option data
This commit is contained in:
parent
81262ac9f0
commit
7c7aea47c7
8 changed files with 25 additions and 188 deletions
|
|
@ -200,13 +200,22 @@ void SettingsDialog::showReadOnlyMessage()
|
||||||
|
|
||||||
void SettingsDialog::updateText()
|
void SettingsDialog::updateText()
|
||||||
{
|
{
|
||||||
// Set Tooltip for the logLevel Items
|
const auto logLevelNames = LogLevel::logLevelNames();
|
||||||
ui->comboLogLevel->setItemData(0, tr("Required messages"), Qt::ToolTipRole);
|
const QStringList toolTips = {tr("Required messages"), tr("Non-fatal errors"), tr("General warnings"),
|
||||||
ui->comboLogLevel->setItemData(1, tr("Non-fatal errors"), Qt::ToolTipRole);
|
tr("General events [Default]"), tr("Debug entries"), tr("Verbose debug output")};
|
||||||
ui->comboLogLevel->setItemData(2, tr("General warnings"), Qt::ToolTipRole);
|
if (ui->comboLogLevel->count() == 0) {
|
||||||
ui->comboLogLevel->setItemData(3, tr("General events [Default]"), Qt::ToolTipRole);
|
const auto logLevelOptions = LogLevel::logLevelOptions();
|
||||||
ui->comboLogLevel->setItemData(4, tr("Debug entries"), Qt::ToolTipRole);
|
for (int i = 0; i < logLevelNames.count(); i++) {
|
||||||
ui->comboLogLevel->setItemData(5, tr("Verbose debug output"), Qt::ToolTipRole);
|
ui->comboLogLevel->addItem(logLevelNames.at(i));
|
||||||
|
ui->comboLogLevel->setItemData(i, logLevelOptions.at(i), Qt::UserRole);
|
||||||
|
ui->comboLogLevel->setItemData(i, toolTips.at(i), Qt::ToolTipRole);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < logLevelNames.count(); i++) {
|
||||||
|
ui->comboLogLevel->setItemData(i, logLevelNames.at(i), Qt::DisplayRole);
|
||||||
|
ui->comboLogLevel->setItemData(i, toolTips.at(i), Qt::ToolTipRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
ui->buttonBox->button(QDialogButtonBox::Save)->setToolTip(tr("Close and save changes"));
|
ui->buttonBox->button(QDialogButtonBox::Save)->setToolTip(tr("Close and save changes"));
|
||||||
ui->buttonBox->button(QDialogButtonBox::Cancel)->setToolTip(tr("Close and forget changes"));
|
ui->buttonBox->button(QDialogButtonBox::Cancel)->setToolTip(tr("Close and forget changes"));
|
||||||
ui->buttonBox->button(QDialogButtonBox::Reset)->setToolTip(tr("Reset to stored values"));
|
ui->buttonBox->button(QDialogButtonBox::Reset)->setToolTip(tr("Reset to stored values"));
|
||||||
|
|
@ -217,9 +226,7 @@ void SettingsDialog::accept()
|
||||||
{
|
{
|
||||||
Settings::setValue(Settings::Core::Port, ui->sbPort->value());
|
Settings::setValue(Settings::Core::Port, ui->sbPort->value());
|
||||||
Settings::setValue(Settings::Core::Interface, ui->comboInterface->currentData());
|
Settings::setValue(Settings::Core::Interface, ui->comboInterface->currentData());
|
||||||
Settings::setValue(
|
Settings::setValue(Settings::Log::Level, ui->comboLogLevel->currentData());
|
||||||
Settings::Log::Level, LogLevel::toOption(static_cast<LogLevel::Level>(ui->comboLogLevel->currentIndex()))
|
|
||||||
);
|
|
||||||
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());
|
||||||
|
|
@ -254,7 +261,9 @@ void SettingsDialog::accept()
|
||||||
void SettingsDialog::loadFromConfig()
|
void SettingsDialog::loadFromConfig()
|
||||||
{
|
{
|
||||||
ui->sbPort->setValue(Settings::value(Settings::Core::Port).toInt());
|
ui->sbPort->setValue(Settings::value(Settings::Core::Port).toInt());
|
||||||
ui->comboLogLevel->setCurrentIndex(static_cast<int>(LogLevel::fromOption(Settings::logLevelText())));
|
ui->comboLogLevel->setCurrentIndex(
|
||||||
|
ui->comboLogLevel->findData(Settings::logLevelText(), Qt::UserRole, Qt::MatchFixedString)
|
||||||
|
);
|
||||||
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->cbPreventSleep->setChecked(Settings::value(Settings::Core::PreventSleep).toBool());
|
ui->cbPreventSleep->setChecked(Settings::value(Settings::Core::PreventSleep).toBool());
|
||||||
|
|
@ -424,7 +433,7 @@ bool SettingsDialog::isModified() const
|
||||||
|
|
||||||
bool modified =
|
bool modified =
|
||||||
(ui->sbPort->value() != Settings::value(Settings::Core::Port).toInt()) ||
|
(ui->sbPort->value() != Settings::value(Settings::Core::Port).toInt()) ||
|
||||||
(ui->comboLogLevel->currentIndex() != static_cast<int>(LogLevel::fromOption(Settings::logLevelText()))) ||
|
(ui->comboLogLevel->currentData() != Settings::logLevelText()) ||
|
||||||
(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->rbAutoHide->isChecked() != Settings::value(Settings::Gui::Autohide).toBool()) ||
|
(ui->rbAutoHide->isChecked() != Settings::value(Settings::Gui::Autohide).toBool()) ||
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
<widget class="QWidget" name="tabGeneral">
|
<widget class="QWidget" name="tabGeneral">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>&General</string>
|
<string>&General</string>
|
||||||
|
|
@ -300,38 +303,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="comboLogLevel">
|
<widget class="QComboBox" name="comboLogLevel"/>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Fatal</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Error</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Warning</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Info</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Debug</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Trace</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
|
|
@ -1176,26 +1176,6 @@ Al habilitar esta opción, se deshabilitará la interfaz gráfica de usuario (GU
|
||||||
<source>Log path</source>
|
<source>Log path</source>
|
||||||
<translation type="unfinished">Ruta de registro</translation>
|
<translation type="unfinished">Ruta de registro</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Fatal</source>
|
|
||||||
<translation type="unfinished">Fatal</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Error</source>
|
|
||||||
<translation type="unfinished">Error</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Warning</source>
|
|
||||||
<translation type="unfinished">Advertencia</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Info</source>
|
|
||||||
<translation type="unfinished">Información</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Debug</source>
|
|
||||||
<translation type="unfinished">Depurar</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Level</source>
|
<source>Level</source>
|
||||||
<translation type="unfinished">Nivel</translation>
|
<translation type="unfinished">Nivel</translation>
|
||||||
|
|
@ -1336,10 +1316,6 @@ Al habilitar esta opción, se deshabilitará la interfaz gráfica de usuario (GU
|
||||||
<source>Run command on exit</source>
|
<source>Run command on exit</source>
|
||||||
<translation type="unfinished">Ejecutar comando al salir</translation>
|
<translation type="unfinished">Ejecutar comando al salir</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Trace</source>
|
|
||||||
<translation type="unfinished">Rastro</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Using a log level higher than Info may affect performance.</source>
|
<source>Using a log level higher than Info may affect performance.</source>
|
||||||
<translation type="unfinished">Utilizar un nivel de registro superior a Info puede afectar el rendimiento.</translation>
|
<translation type="unfinished">Utilizar un nivel de registro superior a Info puede afectar el rendimiento.</translation>
|
||||||
|
|
|
||||||
|
|
@ -1176,26 +1176,6 @@ L'abilitazione di questa impostazione disabiliterà l'interfaccia graf
|
||||||
<source>Log path</source>
|
<source>Log path</source>
|
||||||
<translation>Percorso log</translation>
|
<translation>Percorso log</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Fatal</source>
|
|
||||||
<translation>Fatale</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Error</source>
|
|
||||||
<translation>Errore</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Warning</source>
|
|
||||||
<translation>Avviso</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Info</source>
|
|
||||||
<translation>Informazioni</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Debug</source>
|
|
||||||
<translation>Debug</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Level</source>
|
<source>Level</source>
|
||||||
<translation>Livello</translation>
|
<translation>Livello</translation>
|
||||||
|
|
@ -1336,10 +1316,6 @@ L'abilitazione di questa impostazione disabiliterà l'interfaccia graf
|
||||||
<source>Run command on exit</source>
|
<source>Run command on exit</source>
|
||||||
<translation type="unfinished">Esegui comando all'uscita</translation>
|
<translation type="unfinished">Esegui comando all'uscita</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Trace</source>
|
|
||||||
<translation type="unfinished">Traccia</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Using a log level higher than Info may affect performance.</source>
|
<source>Using a log level higher than Info may affect performance.</source>
|
||||||
<translation type="unfinished">L'utilizzo di un livello di log superiore a Info potrebbe influire sulle prestazioni.</translation>
|
<translation type="unfinished">L'utilizzo di un livello di log superiore a Info potrebbe influire sulle prestazioni.</translation>
|
||||||
|
|
|
||||||
|
|
@ -1178,26 +1178,6 @@ Enabling this setting will disable the server config GUI.</source>
|
||||||
<source>Level</source>
|
<source>Level</source>
|
||||||
<translation>レベル</translation>
|
<translation>レベル</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Fatal</source>
|
|
||||||
<translation>重大</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Error</source>
|
|
||||||
<translation>エラー</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Warning</source>
|
|
||||||
<translation>警告</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Info</source>
|
|
||||||
<translation>情報</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Debug</source>
|
|
||||||
<translation>デバッグ</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Log path</source>
|
<source>Log path</source>
|
||||||
<translation>ログファイルのパス</translation>
|
<translation>ログファイルのパス</translation>
|
||||||
|
|
@ -1338,10 +1318,6 @@ Enabling this setting will disable the server config GUI.</source>
|
||||||
<source>Run command on exit</source>
|
<source>Run command on exit</source>
|
||||||
<translation type="unfinished">終了時にコマンドを実行</translation>
|
<translation type="unfinished">終了時にコマンドを実行</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Trace</source>
|
|
||||||
<translation type="unfinished">トレース</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Using a log level higher than Info may affect performance.</source>
|
<source>Using a log level higher than Info may affect performance.</source>
|
||||||
<translation type="unfinished">Infoよりも高いログレベルを使用すると、パフォーマンスに影響を及ぼす可能性があります。</translation>
|
<translation type="unfinished">Infoよりも高いログレベルを使用すると、パフォーマンスに影響を及ぼす可能性があります。</translation>
|
||||||
|
|
|
||||||
|
|
@ -1176,26 +1176,6 @@ Enabling this setting will disable the server config GUI.</source>
|
||||||
<source>Level</source>
|
<source>Level</source>
|
||||||
<translation>레벨</translation>
|
<translation>레벨</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Fatal</source>
|
|
||||||
<translation>치명적 오류</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Error</source>
|
|
||||||
<translation>오류</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Warning</source>
|
|
||||||
<translation>경고</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Info</source>
|
|
||||||
<translation>정보</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Debug</source>
|
|
||||||
<translation>디버그</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Log path</source>
|
<source>Log path</source>
|
||||||
<translation>로그 경로</translation>
|
<translation>로그 경로</translation>
|
||||||
|
|
@ -1336,10 +1316,6 @@ Enabling this setting will disable the server config GUI.</source>
|
||||||
<source>Run command on exit</source>
|
<source>Run command on exit</source>
|
||||||
<translation type="unfinished">종료 시 명령 실행</translation>
|
<translation type="unfinished">종료 시 명령 실행</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Trace</source>
|
|
||||||
<translation type="unfinished">추적하다</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Using a log level higher than Info may affect performance.</source>
|
<source>Using a log level higher than Info may affect performance.</source>
|
||||||
<translation type="unfinished">Info보다 높은 로그 레벨을 사용하면 성능에 영향을 미칠 수 있습니다.</translation>
|
<translation type="unfinished">Info보다 높은 로그 레벨을 사용하면 성능에 영향을 미칠 수 있습니다.</translation>
|
||||||
|
|
|
||||||
|
|
@ -1174,26 +1174,6 @@ Enabling this setting will disable the server config GUI.</source>
|
||||||
<source>Level</source>
|
<source>Level</source>
|
||||||
<translation>Уровень</translation>
|
<translation>Уровень</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Fatal</source>
|
|
||||||
<translation>Критический</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Error</source>
|
|
||||||
<translation>Ошибка</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Warning</source>
|
|
||||||
<translation>Предупреждение</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Info</source>
|
|
||||||
<translation>Инфо</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Debug</source>
|
|
||||||
<translation>Отладка</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Log path</source>
|
<source>Log path</source>
|
||||||
<translation>Путь к журналам</translation>
|
<translation>Путь к журналам</translation>
|
||||||
|
|
@ -1334,10 +1314,6 @@ Enabling this setting will disable the server config GUI.</source>
|
||||||
<source>Run command on exit</source>
|
<source>Run command on exit</source>
|
||||||
<translation type="unfinished">Выполнить команду при выходе</translation>
|
<translation type="unfinished">Выполнить команду при выходе</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Trace</source>
|
|
||||||
<translation type="unfinished">След</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Using a log level higher than Info may affect performance.</source>
|
<source>Using a log level higher than Info may affect performance.</source>
|
||||||
<translation type="unfinished">Использование уровня логирования выше Info может повлиять на производительность.</translation>
|
<translation type="unfinished">Использование уровня логирования выше Info может повлиять на производительность.</translation>
|
||||||
|
|
|
||||||
|
|
@ -1178,26 +1178,6 @@ Enabling this setting will disable the server config GUI.</source>
|
||||||
<source>Level</source>
|
<source>Level</source>
|
||||||
<translation>级别</translation>
|
<translation>级别</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Fatal</source>
|
|
||||||
<translation>致命</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Error</source>
|
|
||||||
<translation>错误</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Warning</source>
|
|
||||||
<translation>警告</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Info</source>
|
|
||||||
<translation>信息</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Debug</source>
|
|
||||||
<translation>调试</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Log path</source>
|
<source>Log path</source>
|
||||||
<translation>日志路径</translation>
|
<translation>日志路径</translation>
|
||||||
|
|
@ -1338,10 +1318,6 @@ Enabling this setting will disable the server config GUI.</source>
|
||||||
<source>Run command on exit</source>
|
<source>Run command on exit</source>
|
||||||
<translation type="unfinished">退出时运行命令</translation>
|
<translation type="unfinished">退出时运行命令</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Trace</source>
|
|
||||||
<translation type="unfinished">痕迹</translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Using a log level higher than Info may affect performance.</source>
|
<source>Using a log level higher than Info may affect performance.</source>
|
||||||
<translation type="unfinished">使用高于 Info 级别的日志级别可能会影响性能。</translation>
|
<translation type="unfinished">使用高于 Info 级别的日志级别可能会影响性能。</translation>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue