Browse Source

Merge pull request #3371 from ngosang/webuialterdl

[Web UI] Fix alternative global rate limits. Closes #3359
adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
647140c7c7
  1. 9
      src/webui/extra_translations.h
  2. 251
      src/webui/prefjson.cpp
  3. 913
      src/webui/www/public/preferences_content.html

9
src/webui/extra_translations.h

@ -42,8 +42,13 @@ static const char *__TRANSLATIONS__[] = {
QT_TRANSLATE_NOOP("HttpServer", "Download local torrent"), QT_TRANSLATE_NOOP("HttpServer", "Download local torrent"),
QT_TRANSLATE_NOOP("HttpServer", "Download"), QT_TRANSLATE_NOOP("HttpServer", "Download"),
QT_TRANSLATE_NOOP("HttpServer", "Are you sure you want to delete the selected torrents from the transfer list?"), QT_TRANSLATE_NOOP("HttpServer", "Are you sure you want to delete the selected torrents from the transfer list?"),
QT_TRANSLATE_NOOP("HttpServer", "Download rate limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Global upload rate limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Upload rate limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Global download rate limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Alternative upload rate limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Alternative download rate limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Maximum active downloads must be greater than -1."),
QT_TRANSLATE_NOOP("HttpServer", "Maximum active uploads must be greater than -1."),
QT_TRANSLATE_NOOP("HttpServer", "Maximum active torrents must be greater than -1."),
QT_TRANSLATE_NOOP("HttpServer", "Maximum number of connections limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Maximum number of connections limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Maximum number of connections per torrent limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Maximum number of connections per torrent limit must be greater than 0 or disabled."),
QT_TRANSLATE_NOOP("HttpServer", "Maximum number of upload slots per torrent limit must be greater than 0 or disabled."), QT_TRANSLATE_NOOP("HttpServer", "Maximum number of upload slots per torrent limit must be greater than 0 or disabled."),

251
src/webui/prefjson.cpp

@ -50,12 +50,14 @@ QByteArray prefjson::getPreferences()
{ {
const Preferences* const pref = Preferences::instance(); const Preferences* const pref = Preferences::instance();
QVariantMap data; QVariantMap data;
// UI
data["locale"] = pref->getLocale();
// Downloads // Downloads
// Hard Disk
data["save_path"] = Utils::Fs::toNativePath(pref->getSavePath()); data["save_path"] = Utils::Fs::toNativePath(pref->getSavePath());
data["temp_path_enabled"] = pref->isTempPathEnabled(); data["temp_path_enabled"] = pref->isTempPathEnabled();
data["temp_path"] = Utils::Fs::toNativePath(pref->getTempPath()); data["temp_path"] = Utils::Fs::toNativePath(pref->getTempPath());
data["preallocate_all"] = pref->preAllocateAllFiles();
data["incomplete_files_ext"] = pref->useIncompleteFilesExtension();
QVariantList l; QVariantList l;
foreach (const QString& s, pref->getScanDirs()) { foreach (const QString& s, pref->getScanDirs()) {
l << Utils::Fs::toNativePath(s); l << Utils::Fs::toNativePath(s);
@ -66,10 +68,9 @@ QByteArray prefjson::getPreferences()
var_list << b; var_list << b;
} }
data["download_in_scan_dirs"] = var_list; data["download_in_scan_dirs"] = var_list;
data["export_dir_enabled"] = pref->isTorrentExportEnabled();
data["export_dir"] = Utils::Fs::toNativePath(pref->getTorrentExportDir()); data["export_dir"] = Utils::Fs::toNativePath(pref->getTorrentExportDir());
data["export_dir_fin_enabled"] = pref->isFinishedTorrentExportEnabled();
data["export_dir_fin"] = Utils::Fs::toNativePath(pref->getFinishedTorrentExportDir()); data["export_dir_fin"] = Utils::Fs::toNativePath(pref->getFinishedTorrentExportDir());
// Email notification upon download completion
data["mail_notification_enabled"] = pref->isMailNotificationEnabled(); data["mail_notification_enabled"] = pref->isMailNotificationEnabled();
data["mail_notification_email"] = pref->getMailNotificationEmail(); data["mail_notification_email"] = pref->getMailNotificationEmail();
data["mail_notification_smtp"] = pref->getMailNotificationSMTP(); data["mail_notification_smtp"] = pref->getMailNotificationSMTP();
@ -77,33 +78,46 @@ QByteArray prefjson::getPreferences()
data["mail_notification_auth_enabled"] = pref->getMailNotificationSMTPAuth(); data["mail_notification_auth_enabled"] = pref->getMailNotificationSMTPAuth();
data["mail_notification_username"] = pref->getMailNotificationSMTPUsername(); data["mail_notification_username"] = pref->getMailNotificationSMTPUsername();
data["mail_notification_password"] = pref->getMailNotificationSMTPPassword(); data["mail_notification_password"] = pref->getMailNotificationSMTPPassword();
// Run an external program on torrent completion
data["autorun_enabled"] = pref->isAutoRunEnabled(); data["autorun_enabled"] = pref->isAutoRunEnabled();
data["autorun_program"] = Utils::Fs::toNativePath(pref->getAutoRunProgram()); data["autorun_program"] = Utils::Fs::toNativePath(pref->getAutoRunProgram());
data["preallocate_all"] = pref->preAllocateAllFiles();
data["queueing_enabled"] = pref->isQueueingSystemEnabled();
data["max_active_downloads"] = pref->getMaxActiveDownloads();
data["max_active_torrents"] = pref->getMaxActiveTorrents();
data["max_active_uploads"] = pref->getMaxActiveUploads();
data["max_ratio_enabled"] = (pref->getGlobalMaxRatio() >= 0.);
data["max_ratio"] = pref->getGlobalMaxRatio();
data["max_ratio_act"] = pref->getMaxRatioAction();
data["dont_count_slow_torrents"] = pref->ignoreSlowTorrentsForQueueing();
data["incomplete_files_ext"] = pref->useIncompleteFilesExtension();
// Connection // Connection
// Listening Port
data["listen_port"] = pref->getSessionPort(); data["listen_port"] = pref->getSessionPort();
data["upnp"] = pref->isUPnPEnabled(); data["upnp"] = pref->isUPnPEnabled();
data["random_port"] = pref->useRandomPort(); data["random_port"] = pref->useRandomPort();
data["dl_limit"] = pref->getGlobalDownloadLimit(); // Connections Limits
data["up_limit"] = pref->getGlobalUploadLimit();
data["max_connec"] = pref->getMaxConnecs(); data["max_connec"] = pref->getMaxConnecs();
data["max_connec_per_torrent"] = pref->getMaxConnecsPerTorrent(); data["max_connec_per_torrent"] = pref->getMaxConnecsPerTorrent();
data["max_uploads"] = pref->getMaxUploads(); data["max_uploads"] = pref->getMaxUploads();
data["max_uploads_per_torrent"] = pref->getMaxUploadsPerTorrent(); data["max_uploads_per_torrent"] = pref->getMaxUploadsPerTorrent();
// Proxy Server
data["proxy_type"] = pref->getProxyType();
data["proxy_ip"] = pref->getProxyIp();
data["proxy_port"] = pref->getProxyPort();
data["proxy_peer_connections"] = pref->proxyPeerConnections();
#if LIBTORRENT_VERSION_NUM >= 10000
data["force_proxy"] = pref->getForceProxy();
#endif
data["proxy_auth_enabled"] = pref->isProxyAuthEnabled();
data["proxy_username"] = pref->getProxyUsername();
data["proxy_password"] = pref->getProxyPassword();
// IP Filtering
data["ip_filter_enabled"] = pref->isFilteringEnabled();
data["ip_filter_path"] = Utils::Fs::toNativePath(pref->getFilter());
data["ip_filter_trackers"] = pref->isFilteringTrackerEnabled();
// Speed
// Global Rate Limits
data["dl_limit"] = pref->getGlobalDownloadLimit();
data["up_limit"] = pref->getGlobalUploadLimit();
data["enable_utp"] = pref->isuTPEnabled(); data["enable_utp"] = pref->isuTPEnabled();
data["limit_utp_rate"] = pref->isuTPRateLimited(); data["limit_utp_rate"] = pref->isuTPRateLimited();
data["limit_tcp_overhead"] = pref->includeOverheadInLimits(); data["limit_tcp_overhead"] = pref->includeOverheadInLimits();
data["alt_dl_limit"] = pref->getAltGlobalDownloadLimit(); data["alt_dl_limit"] = pref->getAltGlobalDownloadLimit();
data["alt_up_limit"] = pref->getAltGlobalUploadLimit(); data["alt_up_limit"] = pref->getAltGlobalUploadLimit();
// Scheduling
data["scheduler_enabled"] = pref->isSchedulerEnabled(); data["scheduler_enabled"] = pref->isSchedulerEnabled();
const QTime start_time = pref->getSchedulerStartTime(); const QTime start_time = pref->getSchedulerStartTime();
data["schedule_from_hour"] = start_time.hour(); data["schedule_from_hour"] = start_time.hour();
@ -112,36 +126,38 @@ QByteArray prefjson::getPreferences()
data["schedule_to_hour"] = end_time.hour(); data["schedule_to_hour"] = end_time.hour();
data["schedule_to_min"] = end_time.minute(); data["schedule_to_min"] = end_time.minute();
data["scheduler_days"] = pref->getSchedulerDays(); data["scheduler_days"] = pref->getSchedulerDays();
// Bittorrent // Bittorrent
// Privacy
data["dht"] = pref->isDHTEnabled(); data["dht"] = pref->isDHTEnabled();
data["pex"] = pref->isPeXEnabled(); data["pex"] = pref->isPeXEnabled();
data["lsd"] = pref->isLSDEnabled(); data["lsd"] = pref->isLSDEnabled();
data["encryption"] = pref->getEncryptionSetting(); data["encryption"] = pref->getEncryptionSetting();
data["anonymous_mode"] = pref->isAnonymousModeEnabled(); data["anonymous_mode"] = pref->isAnonymousModeEnabled();
// Proxy // Torrent Queueing
data["proxy_type"] = pref->getProxyType(); data["queueing_enabled"] = pref->isQueueingSystemEnabled();
data["proxy_ip"] = pref->getProxyIp(); data["max_active_downloads"] = pref->getMaxActiveDownloads();
data["proxy_port"] = pref->getProxyPort(); data["max_active_torrents"] = pref->getMaxActiveTorrents();
data["proxy_peer_connections"] = pref->proxyPeerConnections(); data["max_active_uploads"] = pref->getMaxActiveUploads();
#if LIBTORRENT_VERSION_NUM >= 10000 data["dont_count_slow_torrents"] = pref->ignoreSlowTorrentsForQueueing();
data["force_proxy"] = pref->getForceProxy(); // Share Ratio Limiting
#endif data["max_ratio_enabled"] = (pref->getGlobalMaxRatio() >= 0.);
data["proxy_auth_enabled"] = pref->isProxyAuthEnabled(); data["max_ratio"] = pref->getGlobalMaxRatio();
data["proxy_username"] = pref->getProxyUsername(); data["max_ratio_act"] = pref->getMaxRatioAction();
data["proxy_password"] = pref->getProxyPassword();
// IP Filter
data["ip_filter_enabled"] = pref->isFilteringEnabled();
data["ip_filter_path"] = Utils::Fs::toNativePath(pref->getFilter());
data["ip_filter_trackers"] = pref->isFilteringTrackerEnabled();
// Web UI // Web UI
// Language
data["locale"] = pref->getLocale();
// HTTP Server
data["web_ui_port"] = pref->getWebUiPort(); data["web_ui_port"] = pref->getWebUiPort();
data["web_ui_username"] = pref->getWebUiUsername();
data["web_ui_password"] = pref->getWebUiPassword();
data["bypass_local_auth"] = !pref->isWebUiLocalAuthEnabled();
data["use_https"] = pref->isWebUiHttpsEnabled(); data["use_https"] = pref->isWebUiHttpsEnabled();
data["ssl_key"] = QString::fromLatin1(pref->getWebUiHttpsKey()); data["ssl_key"] = QString::fromLatin1(pref->getWebUiHttpsKey());
data["ssl_cert"] = QString::fromLatin1(pref->getWebUiHttpsCertificate()); data["ssl_cert"] = QString::fromLatin1(pref->getWebUiHttpsCertificate());
// DynDns // Authentication
data["web_ui_username"] = pref->getWebUiUsername();
data["web_ui_password"] = pref->getWebUiPassword();
data["bypass_local_auth"] = !pref->isWebUiLocalAuthEnabled();
// Update my dynamic domain name
data["dyndns_enabled"] = pref->isDynDNSEnabled(); data["dyndns_enabled"] = pref->isDynDNSEnabled();
data["dyndns_service"] = pref->getDynDNSService(); data["dyndns_service"] = pref->getDynDNSService();
data["dyndns_username"] = pref->getDynDNSUsername(); data["dyndns_username"] = pref->getDynDNSUsername();
@ -153,31 +169,21 @@ QByteArray prefjson::getPreferences()
void prefjson::setPreferences(const QString& json) void prefjson::setPreferences(const QString& json)
{ {
const QVariantMap m = json::fromJson(json).toMap();
// UI
Preferences* const pref = Preferences::instance(); Preferences* const pref = Preferences::instance();
if (m.contains("locale")) { const QVariantMap m = json::fromJson(json).toMap();
QString locale = m["locale"].toString();
if (pref->getLocale() != locale) {
QTranslator *translator = new QTranslator;
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}else{
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
}
qApp->installTranslator(translator);
pref->setLocale(locale);
}
}
// Downloads // Downloads
// Hard Disk
if (m.contains("save_path")) if (m.contains("save_path"))
pref->setSavePath(m["save_path"].toString()); pref->setSavePath(m["save_path"].toString());
if (m.contains("temp_path_enabled")) if (m.contains("temp_path_enabled"))
pref->setTempPathEnabled(m["temp_path_enabled"].toBool()); pref->setTempPathEnabled(m["temp_path_enabled"].toBool());
if (m.contains("temp_path")) if (m.contains("temp_path"))
pref->setTempPath(m["temp_path"].toString()); pref->setTempPath(m["temp_path"].toString());
if (m.contains("preallocate_all"))
pref->preAllocateAllFiles(m["preallocate_all"].toBool());
if (m.contains("incomplete_files_ext"))
pref->useIncompleteFilesExtension(m["incomplete_files_ext"].toBool());
if (m.contains("scan_dirs") && m.contains("download_in_scan_dirs")) { if (m.contains("scan_dirs") && m.contains("download_in_scan_dirs")) {
QVariantList download_at_path_tmp = m["download_in_scan_dirs"].toList(); QVariantList download_at_path_tmp = m["download_in_scan_dirs"].toList();
QList<bool> download_at_path; QList<bool> download_at_path;
@ -210,6 +216,7 @@ void prefjson::setPreferences(const QString& json)
pref->setTorrentExportDir(m["export_dir"].toString()); pref->setTorrentExportDir(m["export_dir"].toString());
if (m.contains("export_dir_fin")) if (m.contains("export_dir_fin"))
pref->setFinishedTorrentExportDir(m["export_dir_fin"].toString()); pref->setFinishedTorrentExportDir(m["export_dir_fin"].toString());
// Email notification upon download completion
if (m.contains("mail_notification_enabled")) if (m.contains("mail_notification_enabled"))
pref->setMailNotificationEnabled(m["mail_notification_enabled"].toBool()); pref->setMailNotificationEnabled(m["mail_notification_enabled"].toBool());
if (m.contains("mail_notification_email")) if (m.contains("mail_notification_email"))
@ -224,41 +231,21 @@ void prefjson::setPreferences(const QString& json)
pref->setMailNotificationSMTPUsername(m["mail_notification_username"].toString()); pref->setMailNotificationSMTPUsername(m["mail_notification_username"].toString());
if (m.contains("mail_notification_password")) if (m.contains("mail_notification_password"))
pref->setMailNotificationSMTPPassword(m["mail_notification_password"].toString()); pref->setMailNotificationSMTPPassword(m["mail_notification_password"].toString());
// Run an external program on torrent completion
if (m.contains("autorun_enabled")) if (m.contains("autorun_enabled"))
pref->setAutoRunEnabled(m["autorun_enabled"].toBool()); pref->setAutoRunEnabled(m["autorun_enabled"].toBool());
if (m.contains("autorun_program")) if (m.contains("autorun_program"))
pref->setAutoRunProgram(m["autorun_program"].toString()); pref->setAutoRunProgram(m["autorun_program"].toString());
if (m.contains("preallocate_all"))
pref->preAllocateAllFiles(m["preallocate_all"].toBool());
if (m.contains("queueing_enabled"))
pref->setQueueingSystemEnabled(m["queueing_enabled"].toBool());
if (m.contains("max_active_downloads"))
pref->setMaxActiveDownloads(m["max_active_downloads"].toInt());
if (m.contains("max_active_torrents"))
pref->setMaxActiveTorrents(m["max_active_torrents"].toInt());
if (m.contains("max_active_uploads"))
pref->setMaxActiveUploads(m["max_active_uploads"].toInt());
if (m.contains("max_ratio_enabled"))
pref->setGlobalMaxRatio(m["max_ratio"].toInt());
else
pref->setGlobalMaxRatio(-1);
if (m.contains("max_ratio_act"))
pref->setMaxRatioAction(m["max_ratio_act"].toInt());
if (m.contains("dont_count_slow_torrents"))
pref->setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool());
if (m.contains("incomplete_files_ext"))
pref->useIncompleteFilesExtension(m["incomplete_files_ext"].toBool());
// Connection // Connection
// Listening Port
if (m.contains("listen_port")) if (m.contains("listen_port"))
pref->setSessionPort(m["listen_port"].toInt()); pref->setSessionPort(m["listen_port"].toInt());
if (m.contains("upnp")) if (m.contains("upnp"))
pref->setUPnPEnabled(m["upnp"].toBool()); pref->setUPnPEnabled(m["upnp"].toBool());
if (m.contains("random_port")) if (m.contains("random_port"))
pref->setRandomPort(m["random_port"].toBool()); pref->setRandomPort(m["random_port"].toBool());
if (m.contains("dl_limit")) // Connections Limits
pref->setGlobalDownloadLimit(m["dl_limit"].toInt());
if (m.contains("up_limit"))
pref->setGlobalUploadLimit(m["up_limit"].toInt());
if (m.contains("max_connec")) if (m.contains("max_connec"))
pref->setMaxConnecs(m["max_connec"].toInt()); pref->setMaxConnecs(m["max_connec"].toInt());
if (m.contains("max_connec_per_torrent")) if (m.contains("max_connec_per_torrent"))
@ -267,6 +254,39 @@ void prefjson::setPreferences(const QString& json)
pref->setMaxUploads(m["max_uploads"].toInt()); pref->setMaxUploads(m["max_uploads"].toInt());
if (m.contains("max_uploads_per_torrent")) if (m.contains("max_uploads_per_torrent"))
pref->setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt()); pref->setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt());
// Proxy Server
if (m.contains("proxy_type"))
pref->setProxyType(m["proxy_type"].toInt());
if (m.contains("proxy_ip"))
pref->setProxyIp(m["proxy_ip"].toString());
if (m.contains("proxy_port"))
pref->setProxyPort(m["proxy_port"].toUInt());
if (m.contains("proxy_peer_connections"))
pref->setProxyPeerConnections(m["proxy_peer_connections"].toBool());
#if LIBTORRENT_VERSION_NUM >= 10000
if (m.contains("force_proxy"))
pref->setForceProxy(m["force_proxy"].toBool());
#endif
if (m.contains("proxy_auth_enabled"))
pref->setProxyAuthEnabled(m["proxy_auth_enabled"].toBool());
if (m.contains("proxy_username"))
pref->setProxyUsername(m["proxy_username"].toString());
if (m.contains("proxy_password"))
pref->setProxyPassword(m["proxy_password"].toString());
// IP Filtering
if (m.contains("ip_filter_enabled"))
pref->setFilteringEnabled(m["ip_filter_enabled"].toBool());
if (m.contains("ip_filter_path"))
pref->setFilter(m["ip_filter_path"].toString());
if (m.contains("ip_filter_trackers"))
pref->setFilteringTrackerEnabled(m["ip_filter_trackers"].toBool());
// Speed
// Global Rate Limits
if (m.contains("dl_limit"))
pref->setGlobalDownloadLimit(m["dl_limit"].toInt());
if (m.contains("up_limit"))
pref->setGlobalUploadLimit(m["up_limit"].toInt());
if (m.contains("enable_utp")) if (m.contains("enable_utp"))
pref->setuTPEnabled(m["enable_utp"].toBool()); pref->setuTPEnabled(m["enable_utp"].toBool());
if (m.contains("limit_utp_rate")) if (m.contains("limit_utp_rate"))
@ -277,6 +297,7 @@ void prefjson::setPreferences(const QString& json)
pref->setAltGlobalDownloadLimit(m["alt_dl_limit"].toInt()); pref->setAltGlobalDownloadLimit(m["alt_dl_limit"].toInt());
if (m.contains("alt_up_limit")) if (m.contains("alt_up_limit"))
pref->setAltGlobalUploadLimit(m["alt_up_limit"].toInt()); pref->setAltGlobalUploadLimit(m["alt_up_limit"].toInt());
// Scheduling
if (m.contains("scheduler_enabled")) if (m.contains("scheduler_enabled"))
pref->setSchedulerEnabled(m["scheduler_enabled"].toBool()); pref->setSchedulerEnabled(m["scheduler_enabled"].toBool());
if (m.contains("schedule_from_hour") && m.contains("schedule_from_min")) { if (m.contains("schedule_from_hour") && m.contains("schedule_from_min")) {
@ -289,53 +310,57 @@ void prefjson::setPreferences(const QString& json)
} }
if (m.contains("scheduler_days")) if (m.contains("scheduler_days"))
pref->setSchedulerDays(scheduler_days(m["scheduler_days"].toInt())); pref->setSchedulerDays(scheduler_days(m["scheduler_days"].toInt()));
// Bittorrent // Bittorrent
// Privacy
if (m.contains("dht")) if (m.contains("dht"))
pref->setDHTEnabled(m["dht"].toBool()); pref->setDHTEnabled(m["dht"].toBool());
if (m.contains("pex")) if (m.contains("pex"))
pref->setPeXEnabled(m["pex"].toBool()); pref->setPeXEnabled(m["pex"].toBool());
qDebug("Pex support: %d", (int)m["pex"].toBool());
if (m.contains("lsd")) if (m.contains("lsd"))
pref->setLSDEnabled(m["lsd"].toBool()); pref->setLSDEnabled(m["lsd"].toBool());
if (m.contains("encryption")) if (m.contains("encryption"))
pref->setEncryptionSetting(m["encryption"].toInt()); pref->setEncryptionSetting(m["encryption"].toInt());
if (m.contains("anonymous_mode")) if (m.contains("anonymous_mode"))
pref->enableAnonymousMode(m["anonymous_mode"].toBool()); pref->enableAnonymousMode(m["anonymous_mode"].toBool());
// Proxy // Torrent Queueing
if (m.contains("proxy_type")) if (m.contains("queueing_enabled"))
pref->setProxyType(m["proxy_type"].toInt()); pref->setQueueingSystemEnabled(m["queueing_enabled"].toBool());
if (m.contains("proxy_ip")) if (m.contains("max_active_downloads"))
pref->setProxyIp(m["proxy_ip"].toString()); pref->setMaxActiveDownloads(m["max_active_downloads"].toInt());
if (m.contains("proxy_port")) if (m.contains("max_active_torrents"))
pref->setProxyPort(m["proxy_port"].toUInt()); pref->setMaxActiveTorrents(m["max_active_torrents"].toInt());
if (m.contains("proxy_peer_connections")) if (m.contains("max_active_uploads"))
pref->setProxyPeerConnections(m["proxy_peer_connections"].toBool()); pref->setMaxActiveUploads(m["max_active_uploads"].toInt());
#if LIBTORRENT_VERSION_NUM >= 10000 if (m.contains("dont_count_slow_torrents"))
if (m.contains("force_proxy")) pref->setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool());
pref->setForceProxy(m["force_proxy"].toBool()); // Share Ratio Limiting
#endif if (m.contains("max_ratio_enabled"))
if (m.contains("proxy_auth_enabled")) pref->setGlobalMaxRatio(m["max_ratio"].toInt());
pref->setProxyAuthEnabled(m["proxy_auth_enabled"].toBool()); else
if (m.contains("proxy_username")) pref->setGlobalMaxRatio(-1);
pref->setProxyUsername(m["proxy_username"].toString()); if (m.contains("max_ratio_act"))
if (m.contains("proxy_password")) pref->setMaxRatioAction(m["max_ratio_act"].toInt());
pref->setProxyPassword(m["proxy_password"].toString());
// IP Filter
if (m.contains("ip_filter_enabled"))
pref->setFilteringEnabled(m["ip_filter_enabled"].toBool());
if (m.contains("ip_filter_path"))
pref->setFilter(m["ip_filter_path"].toString());
if (m.contains("ip_filter_trackers"))
pref->setFilteringTrackerEnabled(m["ip_filter_trackers"].toBool());
// Web UI // Web UI
// Language
if (m.contains("locale")) {
QString locale = m["locale"].toString();
if (pref->getLocale() != locale) {
QTranslator *translator = new QTranslator;
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}else{
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
}
qApp->installTranslator(translator);
pref->setLocale(locale);
}
}
// HTTP Server
if (m.contains("web_ui_port")) if (m.contains("web_ui_port"))
pref->setWebUiPort(m["web_ui_port"].toUInt()); pref->setWebUiPort(m["web_ui_port"].toUInt());
if (m.contains("web_ui_username"))
pref->setWebUiUsername(m["web_ui_username"].toString());
if (m.contains("web_ui_password"))
pref->setWebUiPassword(m["web_ui_password"].toString());
if (m.contains("bypass_local_auth"))
pref->setWebUiLocalAuthEnabled(!m["bypass_local_auth"].toBool());
if (m.contains("use_https")) if (m.contains("use_https"))
pref->setWebUiHttpsEnabled(m["use_https"].toBool()); pref->setWebUiHttpsEnabled(m["use_https"].toBool());
#ifndef QT_NO_OPENSSL #ifndef QT_NO_OPENSSL
@ -350,7 +375,14 @@ void prefjson::setPreferences(const QString& json)
pref->setWebUiHttpsCertificate(raw_cert); pref->setWebUiHttpsCertificate(raw_cert);
} }
#endif #endif
// Dyndns // Authentication
if (m.contains("web_ui_username"))
pref->setWebUiUsername(m["web_ui_username"].toString());
if (m.contains("web_ui_password"))
pref->setWebUiPassword(m["web_ui_password"].toString());
if (m.contains("bypass_local_auth"))
pref->setWebUiLocalAuthEnabled(!m["bypass_local_auth"].toBool());
// Update my dynamic domain name
if (m.contains("dyndns_enabled")) if (m.contains("dyndns_enabled"))
pref->setDynDNSEnabled(m["dyndns_enabled"].toBool()); pref->setDynDNSEnabled(m["dyndns_enabled"].toBool());
if (m.contains("dyndns_service")) if (m.contains("dyndns_service"))
@ -361,6 +393,7 @@ void prefjson::setPreferences(const QString& json)
pref->setDynDNSPassword(m["dyndns_password"].toString()); pref->setDynDNSPassword(m["dyndns_password"].toString());
if (m.contains("dyndns_domain")) if (m.contains("dyndns_domain"))
pref->setDynDomainName(m["dyndns_domain"].toString()); pref->setDynDomainName(m["dyndns_domain"].toString());
// Save preferences // Save preferences
pref->apply(); pref->apply();
} }

913
src/webui/www/public/preferences_content.html

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save