Browse Source

Merge pull request #3279 from ngosang/webui_newoptions

[Web UI] Add new options
adaptive-webui-19844
sledgehammer999 10 years ago
parent
commit
216bf9b477
  1. 578
      src/webui/prefjson.cpp
  2. 2
      src/webui/webapplication.cpp
  3. 178
      src/webui/www/public/preferences_content.html

578
src/webui/prefjson.cpp

@ -48,293 +48,319 @@ prefjson::prefjson()
QByteArray prefjson::getPreferences() QByteArray prefjson::getPreferences()
{ {
const Preferences* const pref = Preferences::instance(); const Preferences* const pref = Preferences::instance();
QVariantMap data; QVariantMap data;
// UI // UI
data["locale"] = pref->getLocale(); data["locale"] = pref->getLocale();
// Downloads // Downloads
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());
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);
} }
data["scan_dirs"] = l; data["scan_dirs"] = l;
QVariantList var_list; QVariantList var_list;
foreach (bool b, pref->getDownloadInScanDirs()) { foreach (bool b, pref->getDownloadInScanDirs()) {
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_enabled"] = pref->isTorrentExportEnabled();
data["export_dir"] = Utils::Fs::toNativePath(pref->getTorrentExportDir()); data["export_dir"] = Utils::Fs::toNativePath(pref->getTorrentExportDir());
data["mail_notification_enabled"] = pref->isMailNotificationEnabled(); data["export_dir_fin_enabled"] = pref->isFinishedTorrentExportEnabled();
data["mail_notification_email"] = pref->getMailNotificationEmail(); data["export_dir_fin"] = Utils::Fs::toNativePath(pref->getFinishedTorrentExportDir());
data["mail_notification_smtp"] = pref->getMailNotificationSMTP(); data["mail_notification_enabled"] = pref->isMailNotificationEnabled();
data["mail_notification_ssl_enabled"] = pref->getMailNotificationSMTPSSL(); data["mail_notification_email"] = pref->getMailNotificationEmail();
data["mail_notification_auth_enabled"] = pref->getMailNotificationSMTPAuth(); data["mail_notification_smtp"] = pref->getMailNotificationSMTP();
data["mail_notification_username"] = pref->getMailNotificationSMTPUsername(); data["mail_notification_ssl_enabled"] = pref->getMailNotificationSMTPSSL();
data["mail_notification_password"] = pref->getMailNotificationSMTPPassword(); data["mail_notification_auth_enabled"] = pref->getMailNotificationSMTPAuth();
data["autorun_enabled"] = pref->isAutoRunEnabled(); data["mail_notification_username"] = pref->getMailNotificationSMTPUsername();
data["autorun_program"] = Utils::Fs::toNativePath(pref->getAutoRunProgram()); data["mail_notification_password"] = pref->getMailNotificationSMTPPassword();
data["preallocate_all"] = pref->preAllocateAllFiles(); data["autorun_enabled"] = pref->isAutoRunEnabled();
data["queueing_enabled"] = pref->isQueueingSystemEnabled(); data["autorun_program"] = Utils::Fs::toNativePath(pref->getAutoRunProgram());
data["max_active_downloads"] = pref->getMaxActiveDownloads(); data["preallocate_all"] = pref->preAllocateAllFiles();
data["max_active_torrents"] = pref->getMaxActiveTorrents(); data["queueing_enabled"] = pref->isQueueingSystemEnabled();
data["max_active_uploads"] = pref->getMaxActiveUploads(); data["max_active_downloads"] = pref->getMaxActiveDownloads();
data["dont_count_slow_torrents"] = pref->ignoreSlowTorrentsForQueueing(); data["max_active_torrents"] = pref->getMaxActiveTorrents();
data["incomplete_files_ext"] = pref->useIncompleteFilesExtension(); data["max_active_uploads"] = pref->getMaxActiveUploads();
// Connection data["max_ratio_enabled"] = (pref->getGlobalMaxRatio() >= 0.);
data["listen_port"] = pref->getSessionPort(); data["max_ratio"] = pref->getGlobalMaxRatio();
data["upnp"] = pref->isUPnPEnabled(); data["max_ratio_act"] = pref->getMaxRatioAction();
data["dl_limit"] = pref->getGlobalDownloadLimit(); data["dont_count_slow_torrents"] = pref->ignoreSlowTorrentsForQueueing();
data["up_limit"] = pref->getGlobalUploadLimit(); data["incomplete_files_ext"] = pref->useIncompleteFilesExtension();
data["max_connec"] = pref->getMaxConnecs(); // Connection
data["max_connec_per_torrent"] = pref->getMaxConnecsPerTorrent(); data["listen_port"] = pref->getSessionPort();
data["max_uploads"] = pref->getMaxUploads(); data["upnp"] = pref->isUPnPEnabled();
data["max_uploads_per_torrent"] = pref->getMaxUploadsPerTorrent(); data["random_port"] = pref->useRandomPort();
data["enable_utp"] = pref->isuTPEnabled(); data["dl_limit"] = pref->getGlobalDownloadLimit();
data["limit_utp_rate"] = pref->isuTPRateLimited(); data["up_limit"] = pref->getGlobalUploadLimit();
data["limit_tcp_overhead"] = pref->includeOverheadInLimits(); data["max_connec"] = pref->getMaxConnecs();
data["alt_dl_limit"] = pref->getAltGlobalDownloadLimit(); data["max_connec_per_torrent"] = pref->getMaxConnecsPerTorrent();
data["alt_up_limit"] = pref->getAltGlobalUploadLimit(); data["max_uploads"] = pref->getMaxUploads();
data["scheduler_enabled"] = pref->isSchedulerEnabled(); data["max_uploads_per_torrent"] = pref->getMaxUploadsPerTorrent();
const QTime start_time = pref->getSchedulerStartTime(); data["enable_utp"] = pref->isuTPEnabled();
data["schedule_from_hour"] = start_time.hour(); data["limit_utp_rate"] = pref->isuTPRateLimited();
data["schedule_from_min"] = start_time.minute(); data["limit_tcp_overhead"] = pref->includeOverheadInLimits();
const QTime end_time = pref->getSchedulerEndTime(); data["alt_dl_limit"] = pref->getAltGlobalDownloadLimit();
data["schedule_to_hour"] = end_time.hour(); data["alt_up_limit"] = pref->getAltGlobalUploadLimit();
data["schedule_to_min"] = end_time.minute(); data["scheduler_enabled"] = pref->isSchedulerEnabled();
data["scheduler_days"] = pref->getSchedulerDays(); const QTime start_time = pref->getSchedulerStartTime();
// Bittorrent data["schedule_from_hour"] = start_time.hour();
data["dht"] = pref->isDHTEnabled(); data["schedule_from_min"] = start_time.minute();
data["pex"] = pref->isPeXEnabled(); const QTime end_time = pref->getSchedulerEndTime();
data["lsd"] = pref->isLSDEnabled(); data["schedule_to_hour"] = end_time.hour();
data["encryption"] = pref->getEncryptionSetting(); data["schedule_to_min"] = end_time.minute();
data["anonymous_mode"] = pref->isAnonymousModeEnabled(); data["scheduler_days"] = pref->getSchedulerDays();
// Proxy // Bittorrent
data["proxy_type"] = pref->getProxyType(); data["dht"] = pref->isDHTEnabled();
data["proxy_ip"] = pref->getProxyIp(); data["pex"] = pref->isPeXEnabled();
data["proxy_port"] = pref->getProxyPort(); data["lsd"] = pref->isLSDEnabled();
data["proxy_peer_connections"] = pref->proxyPeerConnections(); data["encryption"] = pref->getEncryptionSetting();
data["proxy_auth_enabled"] = pref->isProxyAuthEnabled(); data["anonymous_mode"] = pref->isAnonymousModeEnabled();
data["proxy_username"] = pref->getProxyUsername(); // Proxy
data["proxy_password"] = pref->getProxyPassword(); data["proxy_type"] = pref->getProxyType();
// IP Filter data["proxy_ip"] = pref->getProxyIp();
data["ip_filter_enabled"] = pref->isFilteringEnabled(); data["proxy_port"] = pref->getProxyPort();
data["ip_filter_path"] = Utils::Fs::toNativePath(pref->getFilter()); data["proxy_peer_connections"] = pref->proxyPeerConnections();
// Web UI #if LIBTORRENT_VERSION_NUM >= 10000
data["web_ui_port"] = pref->getWebUiPort(); data["force_proxy"] = pref->getForceProxy();
data["web_ui_username"] = pref->getWebUiUsername(); #endif
data["web_ui_password"] = pref->getWebUiPassword(); data["proxy_auth_enabled"] = pref->isProxyAuthEnabled();
data["bypass_local_auth"] = !pref->isWebUiLocalAuthEnabled(); data["proxy_username"] = pref->getProxyUsername();
data["use_https"] = pref->isWebUiHttpsEnabled(); data["proxy_password"] = pref->getProxyPassword();
data["ssl_key"] = QString::fromLatin1(pref->getWebUiHttpsKey()); // IP Filter
data["ssl_cert"] = QString::fromLatin1(pref->getWebUiHttpsCertificate()); data["ip_filter_enabled"] = pref->isFilteringEnabled();
// DynDns data["ip_filter_path"] = Utils::Fs::toNativePath(pref->getFilter());
data["dyndns_enabled"] = pref->isDynDNSEnabled(); data["ip_filter_trackers"] = pref->isFilteringTrackerEnabled();
data["dyndns_service"] = pref->getDynDNSService(); // Web UI
data["dyndns_username"] = pref->getDynDNSUsername(); data["web_ui_port"] = pref->getWebUiPort();
data["dyndns_password"] = pref->getDynDNSPassword(); data["web_ui_username"] = pref->getWebUiUsername();
data["dyndns_domain"] = pref->getDynDomainName(); data["web_ui_password"] = pref->getWebUiPassword();
data["bypass_local_auth"] = !pref->isWebUiLocalAuthEnabled();
data["use_https"] = pref->isWebUiHttpsEnabled();
data["ssl_key"] = QString::fromLatin1(pref->getWebUiHttpsKey());
data["ssl_cert"] = QString::fromLatin1(pref->getWebUiHttpsCertificate());
// DynDns
data["dyndns_enabled"] = pref->isDynDNSEnabled();
data["dyndns_service"] = pref->getDynDNSService();
data["dyndns_username"] = pref->getDynDNSUsername();
data["dyndns_password"] = pref->getDynDNSPassword();
data["dyndns_domain"] = pref->getDynDomainName();
return json::toJson(data); return json::toJson(data);
} }
void prefjson::setPreferences(const QString& json) void prefjson::setPreferences(const QString& json)
{ {
const QVariantMap m = json::fromJson(json).toMap(); const QVariantMap m = json::fromJson(json).toMap();
// UI // UI
Preferences* const pref = Preferences::instance(); Preferences* const pref = Preferences::instance();
if (m.contains("locale")) { if (m.contains("locale")) {
QString locale = m["locale"].toString(); QString locale = m["locale"].toString();
if (pref->getLocale() != locale) { if (pref->getLocale() != locale) {
QTranslator *translator = new QTranslator; QTranslator *translator = new QTranslator;
if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) { if (translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale)); qDebug("%s locale recognized, using translation.", qPrintable(locale));
}else{ }else{
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale)); qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
} }
qApp->installTranslator(translator); qApp->installTranslator(translator);
pref->setLocale(locale); pref->setLocale(locale);
} }
}
// Downloads
if (m.contains("save_path"))
pref->setSavePath(m["save_path"].toString());
if (m.contains("temp_path_enabled"))
pref->setTempPathEnabled(m["temp_path_enabled"].toBool());
if (m.contains("temp_path"))
pref->setTempPath(m["temp_path"].toString());
if (m.contains("scan_dirs") && m.contains("download_in_scan_dirs")) {
QVariantList download_at_path_tmp = m["download_in_scan_dirs"].toList();
QList<bool> download_at_path;
foreach (QVariant var, download_at_path_tmp) {
download_at_path << var.toBool();
} }
QStringList old_folders = pref->getScanDirs(); // Downloads
QStringList new_folders = m["scan_dirs"].toStringList(); if (m.contains("save_path"))
if (download_at_path.size() == new_folders.size()) { pref->setSavePath(m["save_path"].toString());
pref->setScanDirs(new_folders); if (m.contains("temp_path_enabled"))
pref->setDownloadInScanDirs(download_at_path); pref->setTempPathEnabled(m["temp_path_enabled"].toBool());
foreach (const QString &old_folder, old_folders) { if (m.contains("temp_path"))
// Update deleted folders pref->setTempPath(m["temp_path"].toString());
if (!new_folders.contains(old_folder)) { if (m.contains("scan_dirs") && m.contains("download_in_scan_dirs")) {
ScanFoldersModel::instance()->removePath(old_folder); QVariantList download_at_path_tmp = m["download_in_scan_dirs"].toList();
QList<bool> download_at_path;
foreach (QVariant var, download_at_path_tmp) {
download_at_path << var.toBool();
} }
} QStringList old_folders = pref->getScanDirs();
int i = 0; QStringList new_folders = m["scan_dirs"].toStringList();
foreach (const QString &new_folder, new_folders) { if (download_at_path.size() == new_folders.size()) {
qDebug("New watched folder: %s", qPrintable(new_folder)); pref->setScanDirs(new_folders);
// Update new folders pref->setDownloadInScanDirs(download_at_path);
if (!old_folders.contains(Utils::Fs::fromNativePath(new_folder))) { foreach (const QString &old_folder, old_folders) {
ScanFoldersModel::instance()->addPath(new_folder, download_at_path.at(i)); // Update deleted folders
if (!new_folders.contains(old_folder)) {
ScanFoldersModel::instance()->removePath(old_folder);
}
}
int i = 0;
foreach (const QString &new_folder, new_folders) {
qDebug("New watched folder: %s", qPrintable(new_folder));
// Update new folders
if (!old_folders.contains(Utils::Fs::fromNativePath(new_folder))) {
ScanFoldersModel::instance()->addPath(new_folder, download_at_path.at(i));
}
++i;
}
} }
++i;
}
} }
} if (m.contains("export_dir"))
if (m.contains("export_dir")) pref->setTorrentExportDir(m["export_dir"].toString());
pref->setTorrentExportDir(m["export_dir"].toString()); if (m.contains("export_dir_fin"))
if (m.contains("mail_notification_enabled")) pref->setFinishedTorrentExportDir(m["export_dir_fin"].toString());
pref->setMailNotificationEnabled(m["mail_notification_enabled"].toBool()); if (m.contains("mail_notification_enabled"))
if (m.contains("mail_notification_email")) pref->setMailNotificationEnabled(m["mail_notification_enabled"].toBool());
pref->setMailNotificationEmail(m["mail_notification_email"].toString()); if (m.contains("mail_notification_email"))
if (m.contains("mail_notification_smtp")) pref->setMailNotificationEmail(m["mail_notification_email"].toString());
pref->setMailNotificationSMTP(m["mail_notification_smtp"].toString()); if (m.contains("mail_notification_smtp"))
if (m.contains("mail_notification_ssl_enabled")) pref->setMailNotificationSMTP(m["mail_notification_smtp"].toString());
pref->setMailNotificationSMTPSSL(m["mail_notification_ssl_enabled"].toBool()); if (m.contains("mail_notification_ssl_enabled"))
if (m.contains("mail_notification_auth_enabled")) pref->setMailNotificationSMTPSSL(m["mail_notification_ssl_enabled"].toBool());
pref->setMailNotificationSMTPAuth(m["mail_notification_auth_enabled"].toBool()); if (m.contains("mail_notification_auth_enabled"))
if (m.contains("mail_notification_username")) pref->setMailNotificationSMTPAuth(m["mail_notification_auth_enabled"].toBool());
pref->setMailNotificationSMTPUsername(m["mail_notification_username"].toString()); if (m.contains("mail_notification_username"))
if (m.contains("mail_notification_password")) pref->setMailNotificationSMTPUsername(m["mail_notification_username"].toString());
pref->setMailNotificationSMTPPassword(m["mail_notification_password"].toString()); if (m.contains("mail_notification_password"))
if (m.contains("autorun_enabled")) pref->setMailNotificationSMTPPassword(m["mail_notification_password"].toString());
pref->setAutoRunEnabled(m["autorun_enabled"].toBool()); if (m.contains("autorun_enabled"))
if (m.contains("autorun_program")) pref->setAutoRunEnabled(m["autorun_enabled"].toBool());
pref->setAutoRunProgram(m["autorun_program"].toString()); if (m.contains("autorun_program"))
if (m.contains("preallocate_all")) pref->setAutoRunProgram(m["autorun_program"].toString());
pref->preAllocateAllFiles(m["preallocate_all"].toBool()); if (m.contains("preallocate_all"))
if (m.contains("queueing_enabled")) pref->preAllocateAllFiles(m["preallocate_all"].toBool());
pref->setQueueingSystemEnabled(m["queueing_enabled"].toBool()); if (m.contains("queueing_enabled"))
if (m.contains("max_active_downloads")) pref->setQueueingSystemEnabled(m["queueing_enabled"].toBool());
pref->setMaxActiveDownloads(m["max_active_downloads"].toInt()); if (m.contains("max_active_downloads"))
if (m.contains("max_active_torrents")) pref->setMaxActiveDownloads(m["max_active_downloads"].toInt());
pref->setMaxActiveTorrents(m["max_active_torrents"].toInt()); if (m.contains("max_active_torrents"))
if (m.contains("max_active_uploads")) pref->setMaxActiveTorrents(m["max_active_torrents"].toInt());
pref->setMaxActiveUploads(m["max_active_uploads"].toInt()); if (m.contains("max_active_uploads"))
if (m.contains("dont_count_slow_torrents")) pref->setMaxActiveUploads(m["max_active_uploads"].toInt());
pref->setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool()); if (m.contains("max_ratio_enabled"))
if (m.contains("incomplete_files_ext")) pref->setGlobalMaxRatio(m["max_ratio"].toInt());
pref->useIncompleteFilesExtension(m["incomplete_files_ext"].toBool()); else
// Connection pref->setGlobalMaxRatio(-1);
if (m.contains("listen_port")) if (m.contains("max_ratio_act"))
pref->setSessionPort(m["listen_port"].toInt()); pref->setMaxRatioAction(m["max_ratio_act"].toInt());
if (m.contains("upnp")) if (m.contains("dont_count_slow_torrents"))
pref->setUPnPEnabled(m["upnp"].toBool()); pref->setIgnoreSlowTorrentsForQueueing(m["dont_count_slow_torrents"].toBool());
if (m.contains("dl_limit")) if (m.contains("incomplete_files_ext"))
pref->setGlobalDownloadLimit(m["dl_limit"].toInt()); pref->useIncompleteFilesExtension(m["incomplete_files_ext"].toBool());
if (m.contains("up_limit")) // Connection
pref->setGlobalUploadLimit(m["up_limit"].toInt()); if (m.contains("listen_port"))
if (m.contains("max_connec")) pref->setSessionPort(m["listen_port"].toInt());
pref->setMaxConnecs(m["max_connec"].toInt()); if (m.contains("upnp"))
if (m.contains("max_connec_per_torrent")) pref->setUPnPEnabled(m["upnp"].toBool());
pref->setMaxConnecsPerTorrent(m["max_connec_per_torrent"].toInt()); if (m.contains("random_port"))
if (m.contains("max_uploads")) pref->setRandomPort(m["random_port"].toBool());
pref->setMaxUploads(m["max_uploads"].toInt()); if (m.contains("dl_limit"))
if (m.contains("max_uploads_per_torrent")) pref->setGlobalDownloadLimit(m["dl_limit"].toInt());
pref->setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt()); if (m.contains("up_limit"))
if (m.contains("enable_utp")) pref->setGlobalUploadLimit(m["up_limit"].toInt());
pref->setuTPEnabled(m["enable_utp"].toBool()); if (m.contains("max_connec"))
if (m.contains("limit_utp_rate")) pref->setMaxConnecs(m["max_connec"].toInt());
pref->setuTPRateLimited(m["limit_utp_rate"].toBool()); if (m.contains("max_connec_per_torrent"))
if (m.contains("limit_tcp_overhead")) pref->setMaxConnecsPerTorrent(m["max_connec_per_torrent"].toInt());
pref->includeOverheadInLimits(m["limit_tcp_overhead"].toBool()); if (m.contains("max_uploads"))
if (m.contains("alt_dl_limit")) pref->setMaxUploads(m["max_uploads"].toInt());
pref->setAltGlobalDownloadLimit(m["alt_dl_limit"].toInt()); if (m.contains("max_uploads_per_torrent"))
if (m.contains("alt_up_limit")) pref->setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt());
pref->setAltGlobalUploadLimit(m["alt_up_limit"].toInt()); if (m.contains("enable_utp"))
if (m.contains("scheduler_enabled")) pref->setuTPEnabled(m["enable_utp"].toBool());
pref->setSchedulerEnabled(m["scheduler_enabled"].toBool()); if (m.contains("limit_utp_rate"))
if (m.contains("schedule_from_hour") && m.contains("schedule_from_min")) { pref->setuTPRateLimited(m["limit_utp_rate"].toBool());
pref->setSchedulerStartTime(QTime(m["schedule_from_hour"].toInt(), if (m.contains("limit_tcp_overhead"))
m["schedule_from_min"].toInt())); pref->includeOverheadInLimits(m["limit_tcp_overhead"].toBool());
} if (m.contains("alt_dl_limit"))
if (m.contains("schedule_to_hour") && m.contains("schedule_to_min")) { pref->setAltGlobalDownloadLimit(m["alt_dl_limit"].toInt());
pref->setSchedulerEndTime(QTime(m["schedule_to_hour"].toInt(), if (m.contains("alt_up_limit"))
m["schedule_to_min"].toInt())); pref->setAltGlobalUploadLimit(m["alt_up_limit"].toInt());
} if (m.contains("scheduler_enabled"))
if (m.contains("scheduler_days")) pref->setSchedulerEnabled(m["scheduler_enabled"].toBool());
pref->setSchedulerDays(scheduler_days(m["scheduler_days"].toInt())); if (m.contains("schedule_from_hour") && m.contains("schedule_from_min")) {
// Bittorrent pref->setSchedulerStartTime(QTime(m["schedule_from_hour"].toInt(),
if (m.contains("dht")) m["schedule_from_min"].toInt()));
pref->setDHTEnabled(m["dht"].toBool()); }
if (m.contains("pex")) if (m.contains("schedule_to_hour") && m.contains("schedule_to_min")) {
pref->setPeXEnabled(m["pex"].toBool()); pref->setSchedulerEndTime(QTime(m["schedule_to_hour"].toInt(),
qDebug("Pex support: %d", (int)m["pex"].toBool()); m["schedule_to_min"].toInt()));
if (m.contains("lsd")) }
pref->setLSDEnabled(m["lsd"].toBool()); if (m.contains("scheduler_days"))
if (m.contains("encryption")) pref->setSchedulerDays(scheduler_days(m["scheduler_days"].toInt()));
pref->setEncryptionSetting(m["encryption"].toInt()); // Bittorrent
if (m.contains("anonymous_mode")) if (m.contains("dht"))
pref->enableAnonymousMode(m["anonymous_mode"].toBool()); pref->setDHTEnabled(m["dht"].toBool());
// Proxy if (m.contains("pex"))
if (m.contains("proxy_type")) pref->setPeXEnabled(m["pex"].toBool());
pref->setProxyType(m["proxy_type"].toInt()); qDebug("Pex support: %d", (int)m["pex"].toBool());
if (m.contains("proxy_ip")) if (m.contains("lsd"))
pref->setProxyIp(m["proxy_ip"].toString()); pref->setLSDEnabled(m["lsd"].toBool());
if (m.contains("proxy_port")) if (m.contains("encryption"))
pref->setProxyPort(m["proxy_port"].toUInt()); pref->setEncryptionSetting(m["encryption"].toInt());
if (m.contains("proxy_peer_connections")) if (m.contains("anonymous_mode"))
pref->setProxyPeerConnections(m["proxy_peer_connections"].toBool()); pref->enableAnonymousMode(m["anonymous_mode"].toBool());
if (m.contains("proxy_auth_enabled")) // Proxy
pref->setProxyAuthEnabled(m["proxy_auth_enabled"].toBool()); if (m.contains("proxy_type"))
if (m.contains("proxy_username")) pref->setProxyType(m["proxy_type"].toInt());
pref->setProxyUsername(m["proxy_username"].toString()); if (m.contains("proxy_ip"))
if (m.contains("proxy_password")) pref->setProxyIp(m["proxy_ip"].toString());
pref->setProxyPassword(m["proxy_password"].toString()); if (m.contains("proxy_port"))
// IP Filter pref->setProxyPort(m["proxy_port"].toUInt());
if (m.contains("ip_filter_enabled")) if (m.contains("proxy_peer_connections"))
pref->setFilteringEnabled(m["ip_filter_enabled"].toBool()); pref->setProxyPeerConnections(m["proxy_peer_connections"].toBool());
if (m.contains("ip_filter_path")) #if LIBTORRENT_VERSION_NUM >= 10000
pref->setFilter(m["ip_filter_path"].toString()); if (m.contains("force_proxy"))
// Web UI pref->setForceProxy(m["force_proxy"].toBool());
if (m.contains("web_ui_port")) #endif
pref->setWebUiPort(m["web_ui_port"].toUInt()); if (m.contains("proxy_auth_enabled"))
if (m.contains("web_ui_username")) pref->setProxyAuthEnabled(m["proxy_auth_enabled"].toBool());
pref->setWebUiUsername(m["web_ui_username"].toString()); if (m.contains("proxy_username"))
if (m.contains("web_ui_password")) pref->setProxyUsername(m["proxy_username"].toString());
pref->setWebUiPassword(m["web_ui_password"].toString()); if (m.contains("proxy_password"))
if (m.contains("bypass_local_auth")) pref->setProxyPassword(m["proxy_password"].toString());
pref->setWebUiLocalAuthEnabled(!m["bypass_local_auth"].toBool()); // IP Filter
if (m.contains("use_https")) if (m.contains("ip_filter_enabled"))
pref->setWebUiHttpsEnabled(m["use_https"].toBool()); 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
if (m.contains("web_ui_port"))
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"))
pref->setWebUiHttpsEnabled(m["use_https"].toBool());
#ifndef QT_NO_OPENSSL #ifndef QT_NO_OPENSSL
if (m.contains("ssl_key")) { if (m.contains("ssl_key")) {
QByteArray raw_key = m["ssl_key"].toString().toLatin1(); QByteArray raw_key = m["ssl_key"].toString().toLatin1();
if (!QSslKey(raw_key, QSsl::Rsa).isNull()) if (!QSslKey(raw_key, QSsl::Rsa).isNull())
pref->setWebUiHttpsKey(raw_key); pref->setWebUiHttpsKey(raw_key);
} }
if (m.contains("ssl_cert")) { if (m.contains("ssl_cert")) {
QByteArray raw_cert = m["ssl_cert"].toString().toLatin1(); QByteArray raw_cert = m["ssl_cert"].toString().toLatin1();
if (!QSslCertificate(raw_cert).isNull()) if (!QSslCertificate(raw_cert).isNull())
pref->setWebUiHttpsCertificate(raw_cert); pref->setWebUiHttpsCertificate(raw_cert);
} }
#endif #endif
// Dyndns // Dyndns
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"))
pref->setDynDNSService(m["dyndns_service"].toInt()); pref->setDynDNSService(m["dyndns_service"].toInt());
if (m.contains("dyndns_username")) if (m.contains("dyndns_username"))
pref->setDynDNSUsername(m["dyndns_username"].toString()); pref->setDynDNSUsername(m["dyndns_username"].toString());
if (m.contains("dyndns_password")) if (m.contains("dyndns_password"))
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();
} }

2
src/webui/webapplication.cpp

@ -46,7 +46,7 @@
#include "websessiondata.h" #include "websessiondata.h"
#include "webapplication.h" #include "webapplication.h"
static const int API_VERSION = 2; static const int API_VERSION = 3;
static const int API_VERSION_MIN = 2; static const int API_VERSION_MIN = 2;
const QString WWW_FOLDER = ":/www/public/"; const QString WWW_FOLDER = ":/www/public/";

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

@ -2,7 +2,7 @@
<fieldset class="settings"> <fieldset class="settings">
<legend>QBT_TR(Hard Disk)QBT_TR</legend> <legend>QBT_TR(Hard Disk)QBT_TR</legend>
<div class="formRow"> <div class="formRow">
<label for="savepath_text" class="leftLabelLarge">QBT_TR(Save files to location:)QBT_TR</label> <label for="savepath_text">QBT_TR(Save files to location:)QBT_TR</label>
<input type="text" id="savepath_text"/> <input type="text" id="savepath_text"/>
</div> </div>
<div class="formRow"> <div class="formRow">
@ -10,30 +10,29 @@
<label for="temppath_checkbox">QBT_TR(Keep incomplete torrents in:)QBT_TR</label> <label for="temppath_checkbox">QBT_TR(Keep incomplete torrents in:)QBT_TR</label>
<input type="text" id="temppath_text"/> <input type="text" id="temppath_text"/>
</div> </div>
<br/> <input type="checkbox" id="preallocateall_checkbox"/>
<label for="preallocateall_checkbox">QBT_TR(Pre-allocate disk space for all files)QBT_TR</label><br/>
<span id="appendexttr">
<input type="checkbox" id="appendext_checkbox"/>
<label for="appendext_checkbox">QBT_TR(Append .!qB extension to incomplete files)QBT_TR</label>
</span><br/><br/>
QBT_TR(Automatically add torrents from:)QBT_TR<br/> QBT_TR(Automatically add torrents from:)QBT_TR<br/>
<table border="1" id="watched_folders_tab"> <table border="1" id="watched_folders_tab">
<thead><tr><th>QBT_TR(Watched Folder)QBT_TR</th><th>QBT_TR(Download here)QBT_TR</th></tr></thead> <thead><tr><th>QBT_TR(Watched Folder)QBT_TR</th><th>QBT_TR(Download here)QBT_TR</th></tr></thead>
<tbody></tbody> <tbody></tbody>
<tfoot><tr><td style="padding-top:4px;"><input type="text" id="new_watch_folder_txt"/></td><td style="padding-top:4px;"><input type="checkbox" id="new_watch_folder_dl" style="padding-left:18px;"/><img src="theme/list-add" alt="Add" style="padding-left:2px;width:16px;cursor:pointer;margin-right:-18px;" onclick="javascript:addWatchFolder();"/></td></tr></tfoot> <tfoot><tr><td style="padding-top:4px;"><input type="text" id="new_watch_folder_txt"/></td><td style="padding-top:4px;"><input type="checkbox" id="new_watch_folder_dl" style="padding-left:18px;"/><img src="theme/list-add" alt="Add" style="padding-left:2px;width:16px;cursor:pointer;margin-right:-18px;" onclick="javascript:addWatchFolder();"/></td></tr></tfoot>
</table><br/> </table><br/>
<input type="checkbox" id="exportdir_checkbox" onclick="updateExportDirEnabled();"/> <input type="checkbox" id="exportdir_checkbox" onclick="updateExportDirEnabled();"/>
<label for="exportdir_checkbox">QBT_TR(Copy .torrent files to:)QBT_TR</label>&nbsp;&nbsp; <label for="exportdir_checkbox">QBT_TR(Copy .torrent files to:)QBT_TR</label>&nbsp;&nbsp;
<input type="text" id="exportdir_text"/><br/> <input type="text" id="exportdir_text"/><br/>
<span id="appendexttr"> <input type="checkbox" id="exportdirfin_checkbox" onclick="updateExportDirFinEnabled();"/>
<input type="checkbox" id="appendext_checkbox"/> <label for="exportdirfin_checkbox">QBT_TR(Copy .torrent files for finished downloads to:)QBT_TR</label>&nbsp;&nbsp;
<label for="appendext_checkbox">QBT_TR(Append .!qB extension to incomplete files)QBT_TR</label><br/> <input type="text" id="exportdirfin_text"/><br/>
</span>
<input type="checkbox" id="preallocateall_checkbox"/>
<label for="preallocateall_checkbox">QBT_TR(Pre-allocate disk space for all files)QBT_TR</label><br/>
</fieldset> </fieldset>
<fieldset class="settings"> <fieldset class="settings">
<legend>QBT_TR(Email notification upon download completion)QBT_TR</legend> <legend><input type="checkbox" id="mail_notification_checkbox" onclick="updateMailNotification();"/>
<input type="checkbox" id="mail_notification_checkbox" onclick="updateMailNotification();"/> <label for="mail_notification_checkbox">QBT_TR(Email notification upon download completion)QBT_TR</label></legend>
<label for="mail_notification_checkbox">QBT_TR(Email notification upon download completion)QBT_TR</label><br/>
<div class="formRow"> <div class="formRow">
<label for="dest_email_txt" class="leftLabelLarge">QBT_TR(Destination email:)QBT_TR</label><input type="text" id="dest_email_txt"/> <label for="dest_email_txt" class="leftLabelLarge">QBT_TR(Destination email:)QBT_TR</label><input type="text" id="dest_email_txt"/>
</div> </div>
@ -43,25 +42,26 @@
<div class="formRow"> <div class="formRow">
<input type="checkbox" id="mail_ssl_checkbox"/><label for="mail_ssl_checkbox">QBT_TR(This server requires a secure connection (SSL))QBT_TR</label> <input type="checkbox" id="mail_ssl_checkbox"/><label for="mail_ssl_checkbox">QBT_TR(This server requires a secure connection (SSL))QBT_TR</label>
</div> </div>
<input type="checkbox" id="mail_auth_checkbox" onclick="updateMailAuthSettings();"/><label for="mail_auth_checkbox">QBT_TR(Authentication)QBT_TR</label><br/> <fieldset class="settings">
<legend><input type="checkbox" id="mail_auth_checkbox" onclick="updateMailAuthSettings();"/><label for="mail_auth_checkbox">QBT_TR(Authentication)QBT_TR</label></legend>
<div class="formRow"> <div class="formRow">
<label for="mail_username_text" class="leftLabelLarge">QBT_TR(Username:)QBT_TR</label><input type="text" id="mail_username_text"/> <label for="mail_username_text" class="leftLabelLarge">QBT_TR(Username:)QBT_TR</label><input type="text" id="mail_username_text"/>
</div> </div>
<div class="formRow"> <div class="formRow">
<label for="mail_password_text" class="leftLabelLarge">QBT_TR(Password:)QBT_TR</label><input type="password" id="mail_password_text"/> <label for="mail_password_text" class="leftLabelLarge">QBT_TR(Password:)QBT_TR</label><input type="password" id="mail_password_text"/>
</div> </div>
</fieldset>
</fieldset> </fieldset>
<fieldset class="settings"> <fieldset class="settings">
<legend>QBT_TR(Run an external program on torrent completion)QBT_TR</legend> <legend><input type="checkbox" id="autorun_checkbox" onclick="updateAutoRun();"/>
<input type="checkbox" id="autorun_checkbox" onclick="updateAutoRun();"/> <label for="autorun_checkbox">QBT_TR(Run an external program on torrent completion)QBT_TR</label></legend>
<label for="autorun_checkbox">QBT_TR(Run an external program on torrent completion)QBT_TR</label><br/> <input type="text" id="autorunProg_txt" style="width: 400px;"/><br/>
<input type="text" id="autorunProg_txt" style="width: 400px;"/><br/> <i>QBT_TR(The following parameters are supported:)QBT_TR
<i>QBT_TR(The following parameters are supported:)QBT_TR <ul>
<ul> <li>%f: QBT_TR(Torrent path)QBT_TR</li>
<li>%f: QBT_TR(Torrent path)QBT_TR</li> <li>%n: QBT_TR(Torrent name)QBT_TR</li>
<li>%n: QBT_TR(Torrent name)QBT_TR</li> </ul></i>
</ul></i>
</fieldset> </fieldset>
</div> </div>
@ -71,7 +71,9 @@
<label for="port_value">QBT_TR(Port used for incoming connections:)QBT_TR</label> <label for="port_value">QBT_TR(Port used for incoming connections:)QBT_TR</label>
<input type="text" id="port_value" style="width: 4em;"/><br/> <input type="text" id="port_value" style="width: 4em;"/><br/>
<input type="checkbox" id="upnp_checkbox"/> <input type="checkbox" id="upnp_checkbox"/>
<label for="upnp_checkbox">QBT_TR(Use UPnP / NAT-PMP port forwarding from my router)QBT_TR</label> <label for="upnp_checkbox">QBT_TR(Use UPnP / NAT-PMP port forwarding from my router)QBT_TR</label><br/>
<input type="checkbox" id="random_port_checkbox"/>
<label for="random_port_checkbox">QBT_TR(Use different port on each startup)QBT_TR</label>
</fieldset> </fieldset>
<fieldset class="settings"> <fieldset class="settings">
@ -131,8 +133,13 @@
<input type="checkbox" id="use_peer_proxy_checkbox"/> <input type="checkbox" id="use_peer_proxy_checkbox"/>
<label for="use_peer_proxy_checkbox">QBT_TR(Use proxy for peer connections)QBT_TR</label> <label for="use_peer_proxy_checkbox">QBT_TR(Use proxy for peer connections)QBT_TR</label>
</div> </div>
<input type="checkbox" id="peer_proxy_auth_checkbox" onclick="updatePeerProxyAuthSettings();"/> <div class="formRow">
<label for="peer_proxy_auth_checkbox">QBT_TR(Authentication)QBT_TR</label><br/> <input type="checkbox" id="force_proxy_checkbox"/>
<label for="force_proxy_checkbox">QBT_TR(Disable connections not supported by proxies)QBT_TR</label>
</div>
<fieldset class="settings">
<legend><input type="checkbox" id="peer_proxy_auth_checkbox" onclick="updatePeerProxyAuthSettings();"/>
<label for="peer_proxy_auth_checkbox">QBT_TR(Authentication)QBT_TR</label></legend>
<div class="formRow"> <div class="formRow">
<label for="peer_proxy_username_text" class="leftLabelLarge">QBT_TR(Username:)QBT_TR</label> <label for="peer_proxy_username_text" class="leftLabelLarge">QBT_TR(Username:)QBT_TR</label>
<input type="text" id="peer_proxy_username_text" /> <input type="text" id="peer_proxy_username_text" />
@ -141,14 +148,16 @@
<label for="peer_proxy_password_text" class="leftLabelLarge">QBT_TR(Password:)QBT_TR</label> <label for="peer_proxy_password_text" class="leftLabelLarge">QBT_TR(Password:)QBT_TR</label>
<input type="password" id="peer_proxy_password_text" /> <input type="password" id="peer_proxy_password_text" />
</div> </div>
</fieldset>
</fieldset> </fieldset>
<fieldset class="settings"> <fieldset class="settings">
<legend>QBT_TR(IP Filtering)QBT_TR</legend> <legend><input type="checkbox" id="ipfilter_enabled_checkbox" onclick="updateFilterSettings();"/>
<input type="checkbox" id="ipfilter_enabled_checkbox" onclick="updateFilterSettings();"/> <label for="ipfilter_enabled_checkbox">QBT_TR(IP Filtering)QBT_TR</label></legend>
<label for="ipfilter_enabled_checkbox">QBT_TR(IP Filtering)QBT_TR</label><br/> <label for="ipfilter_text">QBT_TR(Filter path (.dat, .p2p, .p2b):)QBT_TR</label>
<label for="ipfilter_text" style="margin-left: 20px;">QBT_TR(Filter path (.dat, .p2p, .p2b):)QBT_TR</label> <input type="text" id="ipfilter_text"/><br/>
<input type="text" id="ipfilter_text"/> <input type="checkbox" id="ipfilter_trackers_checkbox"/>
<label for="ipfilter_trackers_checkbox">QBT_TR(Apply to trackers)QBT_TR</label>
</fieldset> </fieldset>
</div> </div>
@ -240,14 +249,13 @@
<option value="1">QBT_TR(Require encryption)QBT_TR</option> <option value="1">QBT_TR(Require encryption)QBT_TR</option>
<option value="2">QBT_TR(Disable encryption)QBT_TR</option> <option value="2">QBT_TR(Disable encryption)QBT_TR</option>
</select><br/> </select><br/>
<input type="checkbox" id="anonymous_mode_checkbox" onClick="toggleAnonymousMode()"/> <input type="checkbox" id="anonymous_mode_checkbox"/>
<label for="anonymous_mode_checkbox">QBT_TR(Enable anonymous mode)QBT_TR (<a href="https://github.com/qbittorrent/qBittorrent/wiki/Anonymous-Mode">More information</a>)</label><br/> <label for="anonymous_mode_checkbox">QBT_TR(Enable anonymous mode)QBT_TR (<a href="https://github.com/qbittorrent/qBittorrent/wiki/Anonymous-Mode">More information</a>)</label><br/>
</fieldset> </fieldset>
<fieldset class="settings"> <fieldset class="settings">
<legend>QBT_TR(Torrent Queueing)QBT_TR</legend> <legend><input type="checkbox" id="queueing_checkbox" onclick="updateQueueingSystem();"/>
<input type="checkbox" id="queueing_checkbox" onclick="updateQueueingSystem();"/> <label for="queueing_checkbox">QBT_TR(Torrent Queueing)QBT_TR</label></legend>
<label for="queueing_checkbox">QBT_TR(Torrent Queueing)QBT_TR</label><br/>
<div class="formRow"> <div class="formRow">
<label for="max_active_dl_value" style="margin-left: 20px;" class="leftLabelLarge">QBT_TR(Maximum active downloads:)QBT_TR</label> <label for="max_active_dl_value" style="margin-left: 20px;" class="leftLabelLarge">QBT_TR(Maximum active downloads:)QBT_TR</label>
<input type="text" id="max_active_dl_value" style="width: 4em;"/> <input type="text" id="max_active_dl_value" style="width: 4em;"/>
@ -265,6 +273,18 @@
<label for="dont_count_slow_torrents_checkbox">QBT_TR(Do not count slow torrents in these limits)QBT_TR</label> <label for="dont_count_slow_torrents_checkbox">QBT_TR(Do not count slow torrents in these limits)QBT_TR</label>
</div> </div>
</fieldset> </fieldset>
<fieldset class="settings">
<legend>QBT_TR(Share Ratio Limiting)QBT_TR</legend>
<input type="checkbox" id="max_ratio_checkbox" onClick="updateMaxRatioEnabled();"/>
<label for="max_ratio_checkbox">QBT_TR(Seed torrents until their ratio reaches)QBT_TR</label>
<input type="text" id="max_ratio_value" style="width: 4em;"/>
QBT_TR(then)QBT_TR
<select id="max_ratio_act">
<option value="0">QBT_TR(Pause them)QBT_TR</option>
<option value="1">QBT_TR(Remove them)QBT_TR</option>
</select>
</fieldset>
</div> </div>
<div id="WebUITab" class="PrefTab invisible"> <div id="WebUITab" class="PrefTab invisible">
@ -371,22 +391,7 @@
<center><input type="button" value="QBT_TR(Save)QBT_TR" onclick="applyPreferences();"/></center> <center><input type="button" value="QBT_TR(Save)QBT_TR" onclick="applyPreferences();"/></center>
<script type="text/javascript"> <script type="text/javascript">
var WatchedFoldersTable = new HtmlTable($("watched_folders_tab")); var WatchedFoldersTable = new HtmlTable($("watched_folders_tab"));
toggleAnonymousMode = function() {
if($('anonymous_mode_checkbox').getProperty('checked')) {
$('dht_checkbox').setProperty('disabled', true);
$('dht_checkbox').setProperty('checked', false);
$('lsd_checkbox').setProperty('disabled', true);
$('lsd_checkbox').setProperty('checked', false);
$('upnp_checkbox').setProperty('disabled', true);
$('upnp_checkbox').setProperty('checked', false);
} else {
$('dht_checkbox').setProperty('disabled', false);
$('lsd_checkbox').setProperty('disabled', false);
$('upnp_checkbox').setProperty('disabled', false);
}
}
updateDlLimitEnabled = function() { updateDlLimitEnabled = function() {
if($('dl_limit_checkbox').getProperty('checked')) { if($('dl_limit_checkbox').getProperty('checked')) {
@ -488,15 +493,35 @@ updateExportDirEnabled = function() {
} }
} }
updateExportDirFinEnabled = function() {
if($('exportdirfin_checkbox').getProperty('checked')) {
$('exportdirfin_text').setProperty('disabled', false);
} else {
$('exportdirfin_text').setProperty('disabled', true);
}
}
updateQueueingSystem = function() { updateQueueingSystem = function() {
if($('queueing_checkbox').getProperty('checked')) { if($('queueing_checkbox').getProperty('checked')) {
$('max_active_dl_value').setProperty('disabled', false); $('max_active_dl_value').setProperty('disabled', false);
$('max_active_up_value').setProperty('disabled', false); $('max_active_up_value').setProperty('disabled', false);
$('max_active_to_value').setProperty('disabled', false); $('max_active_to_value').setProperty('disabled', false);
$('dont_count_slow_torrents_checkbox').setProperty('disabled', false);
} else { } else {
$('max_active_dl_value').setProperty('disabled', true); $('max_active_dl_value').setProperty('disabled', true);
$('max_active_up_value').setProperty('disabled', true); $('max_active_up_value').setProperty('disabled', true);
$('max_active_to_value').setProperty('disabled', true); $('max_active_to_value').setProperty('disabled', true);
$('dont_count_slow_torrents_checkbox').setProperty('disabled', true);
}
}
updateMaxRatioEnabled = function() {
if($('max_ratio_checkbox').getProperty('checked')) {
$('max_ratio_value').setProperty('disabled', false);
$('max_ratio_act').setProperty('disabled', false);
} else {
$('max_ratio_value').setProperty('disabled', true);
$('max_ratio_act').setProperty('disabled', true);
} }
} }
@ -537,8 +562,10 @@ updateAutoRun = function() {
updateFilterSettings = function() { updateFilterSettings = function() {
if($('ipfilter_enabled_checkbox').getProperty('checked')) { if($('ipfilter_enabled_checkbox').getProperty('checked')) {
$('ipfilter_text').setProperty('disabled', false); $('ipfilter_text').setProperty('disabled', false);
$('ipfilter_trackers_checkbox').setProperty('disabled', false);
} else { } else {
$('ipfilter_text').setProperty('disabled', true); $('ipfilter_text').setProperty('disabled', true);
$('ipfilter_trackers_checkbox').setProperty('disabled', true);
} }
} }
@ -547,6 +574,7 @@ updatePeerProxySettings = function() {
$('peer_proxy_host_text').setProperty('disabled', false); $('peer_proxy_host_text').setProperty('disabled', false);
$('peer_proxy_port_value').setProperty('disabled', false); $('peer_proxy_port_value').setProperty('disabled', false);
$('use_peer_proxy_checkbox').setProperty('disabled', false); $('use_peer_proxy_checkbox').setProperty('disabled', false);
$('force_proxy_checkbox').setProperty('disabled', false);
if($('peer_proxy_type_select').getProperty('value') != "socks5") { if($('peer_proxy_type_select').getProperty('value') != "socks5") {
$('peer_proxy_auth_checkbox').setProperty('checked', false); $('peer_proxy_auth_checkbox').setProperty('checked', false);
$('peer_proxy_auth_checkbox').setProperty('disabled', true); $('peer_proxy_auth_checkbox').setProperty('disabled', true);
@ -558,6 +586,7 @@ updatePeerProxySettings = function() {
$('peer_proxy_host_text').setProperty('disabled', true); $('peer_proxy_host_text').setProperty('disabled', true);
$('peer_proxy_port_value').setProperty('disabled', true); $('peer_proxy_port_value').setProperty('disabled', true);
$('use_peer_proxy_checkbox').setProperty('disabled', true); $('use_peer_proxy_checkbox').setProperty('disabled', true);
$('force_proxy_checkbox').setProperty('disabled', true);
$('peer_proxy_auth_checkbox').setProperty('disabled', true); $('peer_proxy_auth_checkbox').setProperty('disabled', true);
$('peer_proxy_auth_checkbox').setProperty('checked', false); $('peer_proxy_auth_checkbox').setProperty('checked', false);
updatePeerProxyAuthSettings(); updatePeerProxyAuthSettings();
@ -653,6 +682,7 @@ loadPreferences = function() {
// Connection // Connection
$('port_value').setProperty('value', pref.listen_port.toInt()); $('port_value').setProperty('value', pref.listen_port.toInt());
$('upnp_checkbox').setProperty('checked', pref.upnp); $('upnp_checkbox').setProperty('checked', pref.upnp);
$('random_port_checkbox').setProperty('checked', pref.random_port);
var dl_limit = pref.dl_limit.toInt(); var dl_limit = pref.dl_limit.toInt();
if(dl_limit <= 0) { if(dl_limit <= 0) {
@ -751,15 +781,18 @@ loadPreferences = function() {
var mycb = "<input id='cb_watch_"+ i +"' type='checkbox' " + checked + ">"; var mycb = "<input id='cb_watch_"+ i +"' type='checkbox' " + checked + ">";
WatchedFoldersTable.push([myinput, mycb]); WatchedFoldersTable.push([myinput, mycb]);
} }
$('exportdir_checkbox').setProperty('checked', pref.export_dir_enabled);
if(pref.export_dir_enabled) { if(pref.export_dir_enabled)
$('exportdir_text').setProperty('value', pref.export_dir); $('exportdir_text').setProperty('value', pref.export_dir);
$('exportdir_checkbox').setProperty('checked', true); else
} else {
$('exportdir_text').setProperty('value', ''); $('exportdir_text').setProperty('value', '');
$('exportdir_checkbox').setProperty('checked', false);
}
updateExportDirEnabled(); updateExportDirEnabled();
$('exportdirfin_checkbox').setProperty('checked', pref.export_dir_fin_enabled);
if(pref.export_dir_fin_enabled)
$('exportdirfin_text').setProperty('value', pref.export_dir_fin);
else
$('exportdirfin_text').setProperty('value', '');
updateExportDirFinEnabled();
$('mail_notification_checkbox').setProperty('checked', pref.mail_notification_enabled); $('mail_notification_checkbox').setProperty('checked', pref.mail_notification_enabled);
$('dest_email_txt').setProperty('value', pref.mail_notification_email); $('dest_email_txt').setProperty('value', pref.mail_notification_email);
$('smtp_server_txt').setProperty('value', pref.mail_notification_smtp); $('smtp_server_txt').setProperty('value', pref.mail_notification_smtp);
@ -785,9 +818,18 @@ loadPreferences = function() {
$('max_active_to_value').setProperty('value', pref.max_active_torrents.toInt()); $('max_active_to_value').setProperty('value', pref.max_active_torrents.toInt());
$('dont_count_slow_torrents_checkbox').setProperty('checked', pref.dont_count_slow_torrents); $('dont_count_slow_torrents_checkbox').setProperty('checked', pref.dont_count_slow_torrents);
updateQueueingSystem(); updateQueueingSystem();
$('max_ratio_checkbox').setProperty('checked', pref.max_ratio_enabled);
if (pref.max_ratio_enabled)
$('max_ratio_value').setProperty('value', pref.max_ratio.toInt());
else
$('max_ratio_value').setProperty('value', 1);
var max_ratio_act = pref.max_ratio_act.toInt();
$('max_ratio_act').getChildren('option')[max_ratio_act].setAttribute('selected', '');
updateMaxRatioEnabled();
// IP Filter // IP Filter
$('ipfilter_enabled_checkbox').setProperty('checked', pref.ip_filter_enabled); $('ipfilter_enabled_checkbox').setProperty('checked', pref.ip_filter_enabled);
$('ipfilter_text').setProperty('value', pref.ip_filter_path); $('ipfilter_text').setProperty('value', pref.ip_filter_path);
$('ipfilter_trackers_checkbox').setProperty('checked', pref.ip_filter_trackers);
updateFilterSettings(); updateFilterSettings();
// PEER Proxy // PEER Proxy
switch(pref.proxy_type.toInt()) { switch(pref.proxy_type.toInt()) {
@ -809,6 +851,7 @@ loadPreferences = function() {
$('peer_proxy_host_text').setProperty('value', pref.proxy_ip); $('peer_proxy_host_text').setProperty('value', pref.proxy_ip);
$('peer_proxy_port_value').setProperty('value', pref.proxy_port); $('peer_proxy_port_value').setProperty('value', pref.proxy_port);
$('use_peer_proxy_checkbox').setProperty('checked', pref.proxy_peer_connections); $('use_peer_proxy_checkbox').setProperty('checked', pref.proxy_peer_connections);
$('force_proxy_checkbox').setProperty('checked', pref.force_proxy);
$('peer_proxy_auth_checkbox').setProperty('checked', pref.proxy_auth_enabled); $('peer_proxy_auth_checkbox').setProperty('checked', pref.proxy_auth_enabled);
updatePeerProxyAuthSettings(); updatePeerProxyAuthSettings();
$('peer_proxy_username_text').setProperty('value', pref.proxy_username); $('peer_proxy_username_text').setProperty('value', pref.proxy_username);
@ -845,8 +888,8 @@ applyPreferences = function() {
return; return;
} }
settings.set('listen_port', listen_port); settings.set('listen_port', listen_port);
settings.set('upnp', $('upnp_checkbox').getProperty('checked')); settings.set('upnp', $('upnp_checkbox').getProperty('checked'));
settings.set('random_port', $('random_port_checkbox').getProperty('checked'));
var dl_limit = -1; var dl_limit = -1;
if($('dl_limit_checkbox').getProperty('checked')) { if($('dl_limit_checkbox').getProperty('checked')) {
@ -962,6 +1005,11 @@ applyPreferences = function() {
settings.set('export_dir', $('exportdir_text').getProperty('value')); settings.set('export_dir', $('exportdir_text').getProperty('value'));
else else
settings.set('export_dir', ''); settings.set('export_dir', '');
if($('exportdirfin_checkbox').getProperty('checked'))
settings.set('export_dir_fin', $('exportdirfin_text').getProperty('value'));
else
settings.set('export_dir_fin', '');
settings.set('preallocate_all', $('preallocateall_checkbox').getProperty('checked')); settings.set('preallocate_all', $('preallocateall_checkbox').getProperty('checked'));
if(!$('appendexttr').hasClass('invisible')) { if(!$('appendexttr').hasClass('invisible')) {
settings.set('incomplete_files_ext', $('appendext_checkbox').getProperty('checked')); settings.set('incomplete_files_ext', $('appendext_checkbox').getProperty('checked'));
@ -972,6 +1020,18 @@ applyPreferences = function() {
settings.set('max_active_torrents', $('max_active_to_value').getProperty('value').toInt()); settings.set('max_active_torrents', $('max_active_to_value').getProperty('value').toInt());
settings.set('dont_count_slow_torrents', $('dont_count_slow_torrents_checkbox').getProperty('checked')); settings.set('dont_count_slow_torrents', $('dont_count_slow_torrents_checkbox').getProperty('checked'));
var max_ratio = -1;
if($('max_ratio_checkbox').getProperty('checked')) {
max_ratio = $('max_ratio_value').getProperty('value').toInt();
if(max_ratio < 0 || max_ratio > 9998) {
alert("QBT_TR(Share ratio limit must be between 0 and 9998.)QBT_TR");
return;
}
}
settings.set('max_ratio_enabled', $('max_ratio_checkbox').getProperty('checked'));
settings.set('max_ratio', max_ratio);
settings.set('max_ratio_act', $('max_ratio_act').getProperty('value').toInt());
settings.set('mail_notification_enabled', $('mail_notification_checkbox').getProperty('checked')); settings.set('mail_notification_enabled', $('mail_notification_checkbox').getProperty('checked'));
settings.set('mail_notification_email', $('dest_email_txt').getProperty('value')); settings.set('mail_notification_email', $('dest_email_txt').getProperty('value'));
settings.set('mail_notification_smtp', $('smtp_server_txt').getProperty('value')); settings.set('mail_notification_smtp', $('smtp_server_txt').getProperty('value'));
@ -986,6 +1046,7 @@ applyPreferences = function() {
// IP Filter // IP Filter
settings.set('ip_filter_enabled', $('ipfilter_enabled_checkbox').getProperty('checked')); settings.set('ip_filter_enabled', $('ipfilter_enabled_checkbox').getProperty('checked'));
settings.set('ip_filter_path', $('ipfilter_text').getProperty('value')); settings.set('ip_filter_path', $('ipfilter_text').getProperty('value'));
settings.set('ip_filter_trackers', $('ipfilter_trackers_checkbox').getProperty('checked'));
// Peer Proxy // Peer Proxy
var proxy_type_str = $('peer_proxy_type_select').getProperty('value'); var proxy_type_str = $('peer_proxy_type_select').getProperty('value');
@ -1017,6 +1078,7 @@ applyPreferences = function() {
settings.set('proxy_ip', $('peer_proxy_host_text').getProperty('value')); settings.set('proxy_ip', $('peer_proxy_host_text').getProperty('value'));
settings.set('proxy_port', $('peer_proxy_port_value').getProperty('value').toInt()); settings.set('proxy_port', $('peer_proxy_port_value').getProperty('value').toInt());
settings.set('proxy_peer_connections', $('use_peer_proxy_checkbox').getProperty('checked')); settings.set('proxy_peer_connections', $('use_peer_proxy_checkbox').getProperty('checked'));
settings.set('force_proxy', $('force_proxy_checkbox').getProperty('checked'));
settings.set('proxy_username', $('peer_proxy_username_text').getProperty('value')); settings.set('proxy_username', $('peer_proxy_username_text').getProperty('value'));
settings.set('proxy_password', $('peer_proxy_password_text').getProperty('value')); settings.set('proxy_password', $('peer_proxy_password_text').getProperty('value'));

Loading…
Cancel
Save