mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-07 13:41:26 -07:00
parent
d06f78dbbd
commit
e37661d53a
4 changed files with 162 additions and 41 deletions
|
@ -107,6 +107,19 @@ void AppController::preferencesAction()
|
|||
|
||||
QJsonObject data;
|
||||
|
||||
// Behavior
|
||||
// Language
|
||||
data[u"locale"_qs] = pref->getLocale();
|
||||
data[u"performance_warning"_qs] = session->isPerformanceWarningEnabled();
|
||||
// Log file
|
||||
data[u"file_log_enabled"_qs] = app()->isFileLoggerEnabled();
|
||||
data[u"file_log_path"_qs] = app()->fileLoggerPath().toString();
|
||||
data[u"file_log_backup_enabled"_qs] = app()->isFileLoggerBackup();
|
||||
data[u"file_log_max_size"_qs] = app()->fileLoggerMaxSize() / 1024;
|
||||
data[u"file_log_delete_old"_qs] = app()->isFileLoggerDeleteOld();
|
||||
data[u"file_log_age"_qs] = app()->fileLoggerAge();
|
||||
data[u"file_log_age_type"_qs] = app()->fileLoggerAgeType();
|
||||
|
||||
// Downloads
|
||||
// When adding a torrent
|
||||
data[u"torrent_content_layout"_qs] = Utils::String::fromEnum(session->torrentContentLayout());
|
||||
|
@ -247,9 +260,6 @@ void AppController::preferencesAction()
|
|||
data[u"add_trackers"_qs] = session->additionalTrackers();
|
||||
|
||||
// Web UI
|
||||
// Language
|
||||
data[u"locale"_qs] = pref->getLocale();
|
||||
data[u"performance_warning"_qs] = session->isPerformanceWarningEnabled();
|
||||
// HTTP Server
|
||||
data[u"web_ui_domain_list"_qs] = pref->getServerDomains();
|
||||
data[u"web_ui_address"_qs] = pref->getWebUiAddress();
|
||||
|
@ -411,6 +421,45 @@ void AppController::setPreferencesAction()
|
|||
return (it != m.constEnd());
|
||||
};
|
||||
|
||||
// Behavior
|
||||
// Language
|
||||
if (hasKey(u"locale"_qs))
|
||||
{
|
||||
QString locale = it.value().toString();
|
||||
if (pref->getLocale() != locale)
|
||||
{
|
||||
auto *translator = new QTranslator;
|
||||
if (translator->load(u":/lang/qbittorrent_"_qs + locale))
|
||||
{
|
||||
qDebug("%s locale recognized, using translation.", qUtf8Printable(locale));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("%s locale unrecognized, using default (en).", qUtf8Printable(locale));
|
||||
}
|
||||
qApp->installTranslator(translator);
|
||||
|
||||
pref->setLocale(locale);
|
||||
}
|
||||
}
|
||||
if (hasKey(u"performance_warning"_qs))
|
||||
session->setPerformanceWarningEnabled(it.value().toBool());
|
||||
// Log file
|
||||
if (hasKey(u"file_log_enabled"_qs))
|
||||
app()->setFileLoggerEnabled(it.value().toBool());
|
||||
if (hasKey(u"file_log_path"_qs))
|
||||
app()->setFileLoggerPath(Path(it.value().toString()));
|
||||
if (hasKey(u"file_log_backup_enabled"_qs))
|
||||
app()->setFileLoggerBackup(it.value().toBool());
|
||||
if (hasKey(u"file_log_max_size"_qs))
|
||||
app()->setFileLoggerMaxSize(it.value().toInt() * 1024);
|
||||
if (hasKey(u"file_log_delete_old"_qs))
|
||||
app()->setFileLoggerDeleteOld(it.value().toBool());
|
||||
if (hasKey(u"file_log_age"_qs))
|
||||
app()->setFileLoggerAge(it.value().toInt());
|
||||
if (hasKey(u"file_log_age_type"_qs))
|
||||
app()->setFileLoggerAgeType(it.value().toInt());
|
||||
|
||||
// Downloads
|
||||
// When adding a torrent
|
||||
if (hasKey(u"torrent_content_layout"_qs))
|
||||
|
@ -673,28 +722,6 @@ void AppController::setPreferencesAction()
|
|||
session->setAdditionalTrackers(it.value().toString());
|
||||
|
||||
// Web UI
|
||||
// Language
|
||||
if (hasKey(u"locale"_qs))
|
||||
{
|
||||
QString locale = it.value().toString();
|
||||
if (pref->getLocale() != locale)
|
||||
{
|
||||
auto *translator = new QTranslator;
|
||||
if (translator->load(u":/lang/qbittorrent_"_qs + locale))
|
||||
{
|
||||
qDebug("%s locale recognized, using translation.", qUtf8Printable(locale));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("%s locale unrecognized, using default (en).", qUtf8Printable(locale));
|
||||
}
|
||||
qApp->installTranslator(translator);
|
||||
|
||||
pref->setLocale(locale);
|
||||
}
|
||||
}
|
||||
if (hasKey(u"performance_warning"_qs))
|
||||
session->setPerformanceWarningEnabled(it.value().toBool());
|
||||
// HTTP Server
|
||||
if (hasKey(u"web_ui_domain_list"_qs))
|
||||
pref->setServerDomains(it.value().toString());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue