Browse Source

* Replace priority combo boxes by check boxes in Web UI as in Regular UI

* Prepare http server and preferences classes to add new settings to Web UI
  * Tabified Program preferences in Web UI since there will be a lot of settings soon
  * Started to add new settings to Web UI (PeX, LSD, Encryption, save path, temp path, scan dir, preallocateall, queueing, listen_port, upnp, nat-pmp, language, ip filter) -> Proxy is missing
  * Added a command line parameter to change the web ui port
  * Fix PeerGuardian .p2b binary filter support
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
1128b3ea83
  1. 6
      doc/qbittorrent.1
  2. 133
      src/eventmanager.cpp
  3. 1
      src/eventmanager.h
  4. 2
      src/filterparserthread.h
  5. 42
      src/httpconnection.cpp
  6. 6
      src/httpserver.cpp
  7. 30
      src/json.h
  8. BIN
      src/lang/qbittorrent_bg.qm
  9. 1034
      src/lang/qbittorrent_bg.ts
  10. BIN
      src/lang/qbittorrent_ca.qm
  11. 1036
      src/lang/qbittorrent_ca.ts
  12. BIN
      src/lang/qbittorrent_cs.qm
  13. 1034
      src/lang/qbittorrent_cs.ts
  14. BIN
      src/lang/qbittorrent_da.qm
  15. 1056
      src/lang/qbittorrent_da.ts
  16. BIN
      src/lang/qbittorrent_de.qm
  17. 1034
      src/lang/qbittorrent_de.ts
  18. BIN
      src/lang/qbittorrent_el.qm
  19. 1034
      src/lang/qbittorrent_el.ts
  20. 1349
      src/lang/qbittorrent_en.ts
  21. BIN
      src/lang/qbittorrent_es.qm
  22. 1036
      src/lang/qbittorrent_es.ts
  23. BIN
      src/lang/qbittorrent_fi.qm
  24. 1034
      src/lang/qbittorrent_fi.ts
  25. BIN
      src/lang/qbittorrent_fr.qm
  26. 1044
      src/lang/qbittorrent_fr.ts
  27. BIN
      src/lang/qbittorrent_hu.qm
  28. 1034
      src/lang/qbittorrent_hu.ts
  29. BIN
      src/lang/qbittorrent_it.qm
  30. 1034
      src/lang/qbittorrent_it.ts
  31. BIN
      src/lang/qbittorrent_ja.qm
  32. 1160
      src/lang/qbittorrent_ja.ts
  33. BIN
      src/lang/qbittorrent_ko.qm
  34. 1042
      src/lang/qbittorrent_ko.ts
  35. BIN
      src/lang/qbittorrent_nb.qm
  36. 2478
      src/lang/qbittorrent_nb.ts
  37. BIN
      src/lang/qbittorrent_nl.qm
  38. 772
      src/lang/qbittorrent_nl.ts
  39. BIN
      src/lang/qbittorrent_pl.qm
  40. 754
      src/lang/qbittorrent_pl.ts
  41. BIN
      src/lang/qbittorrent_pt.qm
  42. 754
      src/lang/qbittorrent_pt.ts
  43. BIN
      src/lang/qbittorrent_pt_BR.qm
  44. 754
      src/lang/qbittorrent_pt_BR.ts
  45. BIN
      src/lang/qbittorrent_ro.qm
  46. 754
      src/lang/qbittorrent_ro.ts
  47. BIN
      src/lang/qbittorrent_ru.qm
  48. 754
      src/lang/qbittorrent_ru.ts
  49. BIN
      src/lang/qbittorrent_sk.qm
  50. 756
      src/lang/qbittorrent_sk.ts
  51. BIN
      src/lang/qbittorrent_sr.qm
  52. 1034
      src/lang/qbittorrent_sr.ts
  53. BIN
      src/lang/qbittorrent_sv.qm
  54. 754
      src/lang/qbittorrent_sv.ts
  55. BIN
      src/lang/qbittorrent_tr.qm
  56. 754
      src/lang/qbittorrent_tr.ts
  57. BIN
      src/lang/qbittorrent_uk.qm
  58. 812
      src/lang/qbittorrent_uk.ts
  59. BIN
      src/lang/qbittorrent_zh.qm
  60. 754
      src/lang/qbittorrent_zh.ts
  61. BIN
      src/lang/qbittorrent_zh_TW.qm
  62. 754
      src/lang/qbittorrent_zh_TW.ts
  63. 63
      src/main.cpp
  64. 2
      src/options_imp.h
  65. 160
      src/preferences.h
  66. 14
      src/ui/options.ui
  67. 1
      src/webui.qrc
  68. 255
      src/webui/preferences.html
  69. 614
      src/webui/preferences_content.html
  70. 60
      src/webui/prop-files.html
  71. 4
      src/webui/properties.html
  72. 14
      src/webui/scripts/mocha-init.js

6
doc/qbittorrent.1

@ -8,7 +8,7 @@ qBittorrent \- a Bittorrent client written in C++ / Qt4 @@ -8,7 +8,7 @@ qBittorrent \- a Bittorrent client written in C++ / Qt4
.SH "SYNOPSIS"
\fBqbittorrent\fR [\-\-no-splash] [TORRENT_FILE | URL]...
\fBqbittorrent\fR [\-\-no-splash] [\-\-webui-port=x] [TORRENT_FILE | URL]...
\fBqbittorrent\fR \-\-help
@ -21,7 +21,7 @@ qBittorrent \- a Bittorrent client written in C++ / Qt4 @@ -21,7 +21,7 @@ qBittorrent \- a Bittorrent client written in C++ / Qt4
using the \fBrblibtorrent\fR library by Arvid Norberg. qBittorrent aims
to be a good alternative to all other bittorrent clients out there. qBittorrent
is fast, stable, light, it supports unicode and it provides a good integrated search engine.
It also comes with UPnP port forwarding / NAT-PMP, encryption (Azureus compatible),
It also comes with UPnP port forwarding / NAT-PMP, encryption (Vuze compatible),
FAST extension (mainline) and PeX support (utorrent compatible).
.SH "OPTIONS"
@ -32,6 +32,8 @@ FAST extension (mainline) and PeX support (utorrent compatible). @@ -32,6 +32,8 @@ FAST extension (mainline) and PeX support (utorrent compatible).
\fB--no-splash\fR Disables splash screen on startup.
\fB--webui-port=x\fR Changes Web UI port to x (default: 8080).
.SH "BUGS"
If you find a bug, please report it at http://bugs.qbittorrent.org

133
src/eventmanager.cpp

@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
#include <QDebug>
EventManager::EventManager(QObject *parent, Bittorrent *BTSession)
: QObject(parent), BTSession(BTSession)
: QObject(parent), BTSession(BTSession)
{
}
@ -122,14 +122,135 @@ QList<QVariantMap> EventManager::getPropFilesInfo(QString hash) const { @@ -122,14 +122,135 @@ QList<QVariantMap> EventManager::getPropFilesInfo(QString hash) const {
return files;
}
void EventManager::setGlobalPreferences(QVariantMap m) const {
// UI
if(m.contains("locale"))
Preferences::setLocale(m["locale"].toString());
// Downloads
if(m.contains("save_path"))
Preferences::setSavePath(m["save_path"].toString());
if(m.contains("temp_path_enabled"))
Preferences::setTempPathEnabled(m["temp_path_enabled"].toBool());
if(m.contains("temp_path"))
Preferences::setTempPath(m["temp_path"].toString());
if(m.contains("scan_dir"))
Preferences::setScanDir(m["scan_dir"].toString());
if(m.contains("preallocate_all"))
Preferences::preAllocateAllFiles(m["preallocate_all"].toBool());
if(m.contains("queueing_enabled"))
Preferences::setQueueingSystemEnabled(m["queueing_enabled"].toBool());
if(m.contains("max_active_downloads"))
Preferences::setMaxActiveDownloads(m["max_active_downloads"].toInt());
if(m.contains("max_active_torrents"))
Preferences::setMaxActiveTorrents(m["max_active_torrents"].toInt());
if(m.contains("max_active_uploads"))
Preferences::setMaxActiveUploads(m["max_active_uploads"].toInt());
#ifdef LIBTORRENT_0_15
if(m.contains("incomplete_files_ext"))
Preferences::useIncompleteFilesExtension(m["incomplete_files_ext"].toBool());
#endif
// Connection
if(m.contains("listen_port"))
Preferences::setSessionPort(m["listen_port"].toInt());
if(m.contains("upnp"))
Preferences::setUPnPEnabled(m["upnp"].toBool());
if(m.contains("natpmp"))
Preferences::setNATPMPEnabled(m["natpmp"].toBool());
if(m.contains("dl_limit"))
Preferences::setGlobalDownloadLimit(m["dl_limit"].toInt());
if(m.contains("up_limit"))
Preferences::setGlobalUploadLimit(m["up_limit"].toInt());
if(m.contains("max_connec"))
Preferences::setMaxConnecs(m["max_connec"].toInt());
if(m.contains("max_connec_per_torrent"))
Preferences::setMaxConnecsPerTorrent(m["max_connec_per_torrent"].toInt());
if(m.contains("max_uploads_per_torrent"))
Preferences::setMaxUploadsPerTorrent(m["max_uploads_per_torrent"].toInt());
// Bittorrent
if(m.contains("dht"))
Preferences::setDHTEnabled(m["dht"].toBool());
if(m.contains("pex"))
Preferences::setPeXEnabled(m["pex"].toBool());
qDebug("Pex support: %d", (int)m["pex"].toBool());
if(m.contains("lsd"))
Preferences::setLSDEnabled(m["lsd"].toBool());
if(m.contains("encryption"))
Preferences::setEncryptionSetting(m["encryption"].toInt());
// Proxy
if(m.contains("proxy_type"))
Preferences::setProxyType(m["proxy_type"].toInt());
if(m.contains("proxy_ip"))
Preferences::setProxyIp(m["proxy_ip"].toString());
if(m.contains("proxy_port"))
Preferences::setProxyPort(m["proxy_port"].toUInt());
if(m.contains("proxy_auth_enabled"))
Preferences::setProxyAuthEnabled(m["proxy_auth_enabled"].toBool());
if(m.contains("proxy_username"))
Preferences::setProxyUsername(m["proxy_username"].toString());
if(m.contains("proxy_password"))
Preferences::setProxyPassword(m["proxy_password"].toString());
// IP Filter
if(m.contains("ip_filter_enabled"))
Preferences::setFilteringEnabled(m["ip_filter_enabled"].toBool());
if(m.contains("ip_filter_path"))
Preferences::setFilter(m["ip_filter_path"].toString());
// Web UI
if(m.contains("web_ui_port"))
Preferences::setWebUiPort(m["web_ui_port"].toUInt());
if(m.contains("web_ui_username"))
Preferences::setWebUiUsername(m["web_ui_username"].toString());
if(m.contains("web_ui_password"))
Preferences::setWebUiPassword(m["web_ui_password"].toString());
// Reload preferences
BTSession->configureSession();
}
QVariantMap EventManager::getGlobalPreferences() const {
QVariantMap data;
// UI
data["locale"] = Preferences::getLocale();
// Downloads
data["save_path"] = Preferences::getSavePath();
data["temp_path_enabled"] = Preferences::isTempPathEnabled();
data["temp_path"] = Preferences::getTempPath();
data["scan_dir_enabled"] = Preferences::isDirScanEnabled();
data["scan_dir"] = Preferences::getScanDir();
data["preallocate_all"] = Preferences::preAllocateAllFiles();
data["queueing_enabled"] = Preferences::isQueueingSystemEnabled();
data["max_active_downloads"] = Preferences::getMaxActiveDownloads();
data["max_active_torrents"] = Preferences::getMaxActiveTorrents();
data["max_active_uploads"] = Preferences::getMaxActiveUploads();
#ifdef LIBTORRENT_0_15
data["incomplete_files_ext"] = Preferences::useIncompleteFilesExtension();
#endif
// Connection
data["listen_port"] = Preferences::getSessionPort();
data["upnp"] = Preferences::isUPnPEnabled();
data["natpmp"] = Preferences::isNATPMPEnabled();
data["dl_limit"] = Preferences::getGlobalDownloadLimit();
data["up_limit"] = Preferences::getGlobalUploadLimit();
data["dht"] = Preferences::isDHTEnabled();
data["max_connec"] = Preferences::getMaxConnecs();
data["max_connec_per_torrent"] = Preferences::getMaxConnecsPerTorrent();
data["max_uploads_per_torrent"] = Preferences::getMaxUploadsPerTorrent();
// Bittorrent
data["dht"] = Preferences::isDHTEnabled();
data["pex"] = Preferences::isPeXEnabled();
data["lsd"] = Preferences::isLSDEnabled();
data["encryption"] = Preferences::getEncryptionSetting();
// Proxy
data["proxy_type"] = Preferences::getProxyType();
data["proxy_ip"] = Preferences::getProxyIp();
data["proxy_port"] = Preferences::getProxyPort();
data["proxy_auth_enabled"] = Preferences::isProxyAuthEnabled();
data["proxy_username"] = Preferences::getProxyUsername();
data["proxy_password"] = Preferences::getProxyPassword();
// IP Filter
data["ip_filter_enabled"] = Preferences::isFilteringEnabled();
data["ip_filter_path"] = Preferences::getFilter();
// Web UI
data["web_ui_port"] = Preferences::getWebUiPort();
data["web_ui_username"] = Preferences::getWebUiUsername();
data["web_ui_password"] = Preferences::getWebUiPassword();
return data;
}
@ -162,10 +283,10 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const { @@ -162,10 +283,10 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const {
data["nb_connections"] = QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")";
// Update ratio info
double ratio = BTSession->getRealRatio(h.hash());
if(ratio > 100.)
data["share_ratio"] = QString::fromUtf8("");
else
data["share_ratio"] = QString(QByteArray::number(ratio, 'f', 1));
if(ratio > 100.)
data["share_ratio"] = QString::fromUtf8("");
else
data["share_ratio"] = QString(QByteArray::number(ratio, 'f', 1));
}
return data;
}

1
src/eventmanager.h

@ -55,6 +55,7 @@ class EventManager : public QObject @@ -55,6 +55,7 @@ class EventManager : public QObject
QList<QVariantMap> getPropTrackersInfo(QString hash) const;
QList<QVariantMap> getPropFilesInfo(QString hash) const;
QVariantMap getGlobalPreferences() const;
void setGlobalPreferences(QVariantMap m) const;
public slots:
void addedTorrent(QTorrentHandle& h);

2
src/filterparserthread.h

@ -71,7 +71,7 @@ class FilterParserThread : public QThread { @@ -71,7 +71,7 @@ class FilterParserThread : public QThread {
// PeerGuardian p2p file
parseP2PFilterFile(filePath);
} else {
if(filePath.endsWith(".p2p", Qt::CaseInsensitive)) {
if(filePath.endsWith(".p2b", Qt::CaseInsensitive)) {
// PeerGuardian p2b file
parseP2BFilterFile(filePath);
} else {

42
src/httpconnection.cpp

@ -103,12 +103,12 @@ void HttpConnection::write() @@ -103,12 +103,12 @@ void HttpConnection::write()
}
QString HttpConnection::translateDocument(QString data) {
std::string contexts[] = {"TransferListFiltersWidget", "TransferListWidget", "PropertiesWidget", "GUI", "MainWindow", "HttpServer", "confirmDeletionDlg", "TrackerList", "TorrentFilesModel", "options_imp"};
std::string contexts[] = {"TransferListFiltersWidget", "TransferListWidget", "PropertiesWidget", "GUI", "MainWindow", "HttpServer", "confirmDeletionDlg", "TrackerList", "TorrentFilesModel", "options_imp", "Preferences"};
int i=0;
bool found = false;
do {
found = false;
QRegExp regex("_\\(([\\w\\s?!:\\/\\(\\)\\.]+)\\)");
QRegExp regex("_\\(([\\w\\s?!:\\/\\(\\),\\-\\.]+)\\)");
i = regex.indexIn(data, i);
if(i >= 0) {
//qDebug("Found translatable string: %s", regex.cap(1).toUtf8().data());
@ -118,7 +118,7 @@ QString HttpConnection::translateDocument(QString data) { @@ -118,7 +118,7 @@ QString HttpConnection::translateDocument(QString data) {
do {
translation = qApp->translate(contexts[context_index].c_str(), word.toLocal8Bit().data(), 0, QCoreApplication::UnicodeUTF8, 1);
++context_index;
}while(translation == word && context_index < 10);
}while(translation == word && context_index < 11);
//qDebug("Translation is %s", translation.toUtf8().data());
data = data.replace(i, regex.matchedLength(), translation);
i += translation.length();
@ -193,6 +193,7 @@ void HttpConnection::respond() @@ -193,6 +193,7 @@ void HttpConnection::respond()
else
list.prepend("webui");
url = ":/" + list.join("/");
qDebug("Resource URL: %s", url.toLocal8Bit().data());
QFile file(url);
if(!file.open(QIODevice::ReadOnly))
{
@ -329,37 +330,10 @@ void HttpConnection::respondCommand(QString command) @@ -329,37 +330,10 @@ void HttpConnection::respondCommand(QString command)
return;
}
if(command == "setPreferences") {
bool ok = false;
int dl_limit = parser.post("dl_limit").toInt(&ok);
if(ok) {
BTSession->setDownloadRateLimit(dl_limit*1024);
Preferences::setGlobalDownloadLimit(dl_limit);
}
int up_limit = parser.post("up_limit").toInt(&ok);
if(ok) {
BTSession->setUploadRateLimit(up_limit*1024);
Preferences::setGlobalUploadLimit(up_limit);
}
int dht_state = parser.post("dht").toInt(&ok);
if(ok) {
BTSession->enableDHT(dht_state == 1);
Preferences::setDHTEnabled(dht_state == 1);
}
int max_connec = parser.post("max_connec").toInt(&ok);
if(ok) {
BTSession->setMaxConnections(max_connec);
Preferences::setMaxConnecs(max_connec);
}
int max_connec_per_torrent = parser.post("max_connec_per_torrent").toInt(&ok);
if(ok) {
BTSession->setMaxConnectionsPerTorrent(max_connec_per_torrent);
Preferences::setMaxConnecsPerTorrent(max_connec_per_torrent);
}
int max_uploads_per_torrent = parser.post("max_uploads_per_torrent").toInt(&ok);
if(ok) {
BTSession->setMaxUploadsPerTorrent(max_uploads_per_torrent);
Preferences::setMaxUploadsPerTorrent(max_uploads_per_torrent);
}
QString json_str = parser.post("json");
//qDebug("setPreferences, json: %s", json_str.toLocal8Bit().data());
EventManager* manager = parent->eventManager();
manager->setGlobalPreferences(json::fromJson(json_str));
}
if(command == "setFilePrio") {
QString hash = parser.post("hash");

6
src/httpserver.cpp

@ -76,6 +76,12 @@ HttpServer::HttpServer(Bittorrent *_BTSession, int msec, QObject* parent) : QTcp @@ -76,6 +76,12 @@ HttpServer::HttpServer(Bittorrent *_BTSession, int msec, QObject* parent) : QTcp
a = tr("Maximum number of connections per torrent limit must be greater than 0 or disabled.");
a = tr("Maximum number of upload slots per torrent limit must be greater than 0 or disabled.");
a = tr("Unable to save program preferences, qBittorrent is probably unreachable.");
a = tr("Language");
a = tr("Downloaded", "Is the file downloaded or not?");
a = tr("The port used for incoming connections must be greater than 1024 and less than 65535.");
a = tr("The port used for the Web UI must be greater than 1024 and less than 65535.");
a = tr("The Web UI username must be at least 3 characters long.");
a = tr("The Web UI password must be at least 3 characters long.");
}
HttpServer::~HttpServer()

30
src/json.h

@ -98,6 +98,36 @@ namespace json { @@ -98,6 +98,36 @@ namespace json {
return "{"+vlist.join(",")+"}";
}
QVariantMap fromJson(QString json) {
QVariantMap m;
if(json.startsWith("{") && json.endsWith("}")) {
json.chop(1);
json = json.replace(0, 1, "");
QStringList couples = json.split(",");
foreach(QString couple, couples) {
QStringList parts = couple.split(":");
if(parts.size() != 2) continue;
QString key = parts.first();
if(key.startsWith("\"") && key.endsWith("\"")) {
key.chop(1);
key = key.replace(0, 1, "");
}
QString value_str = parts.last();
QVariant value;
if(value_str.startsWith("\"") && value_str.endsWith("\"")) {
value_str.chop(1);
value_str = value_str.replace(0, 1, "");
value = value_str;
} else {
value = value_str.toInt();
}
m.insert(key,value);
qDebug("%s:%s", key.toLocal8Bit().data(), value_str.toLocal8Bit().data());
}
}
return m;
}
QString toJson(QList<QVariantMap> v) {
QStringList res;
foreach(QVariantMap m, v) {

BIN
src/lang/qbittorrent_bg.qm

Binary file not shown.

1034
src/lang/qbittorrent_bg.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_ca.qm

Binary file not shown.

1036
src/lang/qbittorrent_ca.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_cs.qm

Binary file not shown.

1034
src/lang/qbittorrent_cs.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_da.qm

Binary file not shown.

1056
src/lang/qbittorrent_da.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_de.qm

Binary file not shown.

1034
src/lang/qbittorrent_de.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_el.qm

Binary file not shown.

1034
src/lang/qbittorrent_el.ts

File diff suppressed because it is too large Load Diff

1349
src/lang/qbittorrent_en.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_es.qm

Binary file not shown.

1036
src/lang/qbittorrent_es.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_fi.qm

Binary file not shown.

1034
src/lang/qbittorrent_fi.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_fr.qm

Binary file not shown.

1044
src/lang/qbittorrent_fr.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_hu.qm

Binary file not shown.

1034
src/lang/qbittorrent_hu.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_it.qm

Binary file not shown.

1034
src/lang/qbittorrent_it.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_ja.qm

Binary file not shown.

1160
src/lang/qbittorrent_ja.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_ko.qm

Binary file not shown.

1042
src/lang/qbittorrent_ko.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_nb.qm

Binary file not shown.

2478
src/lang/qbittorrent_nb.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_nl.qm

Binary file not shown.

772
src/lang/qbittorrent_nl.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_pl.qm

Binary file not shown.

754
src/lang/qbittorrent_pl.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_pt.qm

Binary file not shown.

754
src/lang/qbittorrent_pt.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_pt_BR.qm

Binary file not shown.

754
src/lang/qbittorrent_pt_BR.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_ro.qm

Binary file not shown.

754
src/lang/qbittorrent_ro.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_ru.qm

Binary file not shown.

754
src/lang/qbittorrent_ru.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_sk.qm

Binary file not shown.

756
src/lang/qbittorrent_sk.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_sr.qm

Binary file not shown.

1034
src/lang/qbittorrent_sr.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_sv.qm

Binary file not shown.

754
src/lang/qbittorrent_sv.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_tr.qm

Binary file not shown.

754
src/lang/qbittorrent_tr.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_uk.qm

Binary file not shown.

812
src/lang/qbittorrent_uk.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_zh.qm

Binary file not shown.

754
src/lang/qbittorrent_zh.ts

File diff suppressed because it is too large Load Diff

BIN
src/lang/qbittorrent_zh_TW.qm

Binary file not shown.

754
src/lang/qbittorrent_zh_TW.ts

File diff suppressed because it is too large Load Diff

63
src/main.cpp

@ -56,6 +56,7 @@ @@ -56,6 +56,7 @@
#include <stdlib.h>
#include "GUI.h"
#include "misc.h"
#include "preferences.h"
#include "ico.h"
QApplication *app;
@ -130,11 +131,25 @@ int main(int argc, char *argv[]){ @@ -130,11 +131,25 @@ int main(int argc, char *argv[]){
std::cout << '\t' << argv[0] << " --version : displays program version\n";
std::cout << '\t' << argv[0] << " --no-splash : disable splash screen\n";
std::cout << '\t' << argv[0] << " --help : displays this help message\n";
std::cout << '\t' << argv[0] << " --webui-port=x : changes the webui port (default: 8080)\n";
std::cout << '\t' << argv[0] << " [files or urls] : starts program and download given parameters (optional)\n";
return 0;
}
if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--no-splash")){
no_splash = true;
for(int i=1; i<argc; ++i) {
if(QString::fromUtf8(argv[i]) == QString::fromUtf8("--no-splash")) {
no_splash = true;
} else {
if(QString::fromUtf8(argv[i]).startsWith("--webui-port=")) {
QStringList parts = QString::fromUtf8(argv[i]).split("=");
if(parts.size() == 2) {
bool ok = false;
int new_port = parts.last().toInt(&ok);
if(ok && new_port > 1024 && new_port <= 65535) {
Preferences::setWebUiPort(new_port);
}
}
}
}
}
}
if(settings.value(QString::fromUtf8("Preferences/General/NoSplashScreen"), false).toBool()) {
@ -148,30 +163,30 @@ int main(int argc, char *argv[]){ @@ -148,30 +163,30 @@ int main(int argc, char *argv[]){
QLocalSocket localSocket;
QString uid = QString::number(getuid());
localSocket.connectToServer("qBittorrent-"+uid, QIODevice::WriteOnly);
if (localSocket.waitForConnected(1000)){
std::cout << "Another qBittorrent instance is already running...\n";
// Send parameters
if(argc > 1){
QStringList params;
for(int i=1;i<argc;++i){
params << QString::fromLocal8Bit(argv[i]);
std::cout << argv[i] << '\n';
}
QByteArray block = params.join("\n").toLocal8Bit();
std::cout << "writting: " << block.data() << '\n';
std::cout << "size: " << block.size() << '\n';
uint val = localSocket.write(block);
if(localSocket.waitForBytesWritten(5000)){
std::cout << "written(" <<val<<"): " << block.data() << '\n';
}else{
std::cerr << "Writing to the socket timed out\n";
}
localSocket.disconnectFromServer();
std::cout << "disconnected\n";
if (localSocket.waitForConnected(1000)){
std::cout << "Another qBittorrent instance is already running...\n";
// Send parameters
if(argc > 1){
QStringList params;
for(int i=1;i<argc;++i){
params << QString::fromLocal8Bit(argv[i]);
std::cout << argv[i] << '\n';
}
localSocket.close();
return 0;
QByteArray block = params.join("\n").toLocal8Bit();
std::cout << "writting: " << block.data() << '\n';
std::cout << "size: " << block.size() << '\n';
uint val = localSocket.write(block);
if(localSocket.waitForBytesWritten(5000)){
std::cout << "written(" <<val<<"): " << block.data() << '\n';
}else{
std::cerr << "Writing to the socket timed out\n";
}
localSocket.disconnectFromServer();
std::cout << "disconnected\n";
}
localSocket.close();
return 0;
}
app = new QApplication(argc, argv);
useStyle(app, settings.value("Preferences/General/Style", 0).toInt());
app->setStyleSheet("QStatusBar::item { border-width: 0; }");

2
src/options_imp.h

@ -43,7 +43,7 @@ using namespace libtorrent; @@ -43,7 +43,7 @@ using namespace libtorrent;
class QCloseEvent;
class options_imp : public QDialog, private Ui::Dialog {
class options_imp : public QDialog, private Ui_Preferences {
Q_OBJECT
private:

160
src/preferences.h

@ -44,6 +44,11 @@ public: @@ -44,6 +44,11 @@ public:
return settings.value(QString::fromUtf8("Preferences/General/Locale"), "en_GB").toString();
}
static void setLocale(QString locale) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale);
}
static int getStyle() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/General/Style"), 0).toInt();
@ -112,37 +117,49 @@ public: @@ -112,37 +117,49 @@ public:
// Downloads
static QString getSavePath() {
QSettings settings("qBittorrent", "qBittorrent");
#ifdef Q_WS_WIN
QString home = QDir::rootPath();
#else
QString home = QDir::homePath();
#endif
if(home[home.length()-1] != QDir::separator()){
home += QDir::separator();
}
return settings.value(QString::fromUtf8("Preferences/Downloads/SavePath"), home+"qBT_dir").toString();
}
static void setSavePath(QString save_path) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Downloads/SavePath"), save_path);
}
static bool isTempPathEnabled() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Downloads/TempPathEnabled"), false).toBool();
}
static void setTempPathEnabled(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Downloads/TempPathEnabled"), enabled);
}
static QString getTempPath() {
QSettings settings("qBittorrent", "qBittorrent");
#ifdef Q_WS_WIN
QString home = QDir::rootPath();
#else
QString home = QDir::homePath();
#endif
return settings.value(QString::fromUtf8("Preferences/Downloads/TempPath"), home+"qBT_dir"+QDir::separator()+"temp").toString();
}
static void setTempPath(QString path) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Downloads/TempPath"), path);
}
#ifdef LIBTORRENT_0_15
static bool useIncompleteFilesExtension() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), false).toBool();
}
static void useIncompleteFilesExtension(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Downloads/UseIncompleteExtension"), enabled);
}
#endif
static bool appendTorrentLabel() {
@ -155,6 +172,11 @@ public: @@ -155,6 +172,11 @@ public:
return settings.value(QString::fromUtf8("Preferences/Downloads/PreAllocation"), false).toBool();
}
static void preAllocateAllFiles(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
return settings.setValue(QString::fromUtf8("Preferences/Downloads/PreAllocation"), enabled);
}
static int diskCacheSize() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Downloads/DiskCache"), 16).toInt();
@ -180,6 +202,14 @@ public: @@ -180,6 +202,14 @@ public:
return settings.value(QString::fromUtf8("Preferences/Downloads/ScanDir"), QString()).toString();
}
static void setScanDir(QString path) {
path = path.trimmed();
if(path.isEmpty())
path = QString();
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Downloads/ScanDir"), path);
}
static int getActionOnDblClOnTorrentDl() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Downloads/DblClOnTorDl"), 0).toInt();
@ -196,16 +226,31 @@ public: @@ -196,16 +226,31 @@ public:
return settings.value(QString::fromUtf8("Preferences/Connection/PortRangeMin"), 6881).toInt();
}
static void setSessionPort(int port) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Connection/PortRangeMin"), port);
}
static bool isUPnPEnabled() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/UPnP"), true).toBool();
}
static void setUPnPEnabled(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Connection/UPnP"), enabled);
}
static bool isNATPMPEnabled() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/NAT-PMP"), true).toBool();
}
static void setNATPMPEnabled(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Connection/NAT-PMP"), enabled);
}
static int getGlobalDownloadLimit() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/GlobalDLLimit"), -1).toInt();
@ -213,7 +258,7 @@ public: @@ -213,7 +258,7 @@ public:
static void setGlobalDownloadLimit(int limit) {
QSettings settings("qBittorrent", "qBittorrent");
if(limit == 0) limit = -1;
if(limit <= 0) limit = -1;
settings.setValue("Preferences/Connection/GlobalDLLimit", limit);
}
@ -224,7 +269,7 @@ public: @@ -224,7 +269,7 @@ public:
static void setGlobalUploadLimit(int limit) {
QSettings settings("qBittorrent", "qBittorrent");
if(limit == 0) limit = -1;
if(limit <= 0) limit = -1;
settings.setValue("Preferences/Connection/GlobalUPLimit", limit);
}
@ -284,31 +329,61 @@ public: @@ -284,31 +329,61 @@ public:
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), false).toBool();
}
static void setProxyAuthEnabled(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Connection/Proxy/Authentication"), enabled);
}
static QString getProxyIp() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/IP"), "0.0.0.0").toString();
}
static void setProxyIp(QString ip) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Connection/Proxy/IP"), ip);
}
static unsigned short getProxyPort() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Port"), 8080).toInt();
}
static void setProxyPort(unsigned short port) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Connection/Proxy/Port"), port);
}
static QString getProxyUsername() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Username"), QString()).toString();
}
static void setProxyUsername(QString username) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Connection/Proxy/Username"), username);
}
static QString getProxyPassword() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/Password"), QString()).toString();
}
static void setProxyPassword(QString password) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Connection/Proxy/Password"), password);
}
static int getProxyType() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/ProxyType"), 0).toInt();
}
static void setProxyType(int type) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Connection/ProxyType"), type);
}
static bool useProxyForTrackers() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/Proxy/AffectTrackers"), true).toBool();
@ -337,6 +412,7 @@ public: @@ -337,6 +412,7 @@ public:
static void setMaxConnecs(int val) {
QSettings settings("qBittorrent", "qBittorrent");
if(val <= 0) val = -1;
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/MaxConnecs"), val);
}
@ -347,6 +423,7 @@ public: @@ -347,6 +423,7 @@ public:
static void setMaxConnecsPerTorrent(int val) {
QSettings settings("qBittorrent", "qBittorrent");
if(val <= 0) val = -1;
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/MaxConnecsPerTorrent"), val);
}
@ -357,6 +434,7 @@ public: @@ -357,6 +434,7 @@ public:
static void setMaxUploadsPerTorrent(int val) {
QSettings settings("qBittorrent", "qBittorrent");
if(val <= 0) val = -1;
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), val);
}
@ -365,14 +443,19 @@ public: @@ -365,14 +443,19 @@ public:
return settings.value(QString::fromUtf8("Preferences/Bittorrent/DHT"), true).toBool();
}
static void setDHTEnabled(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/DHT"), enabled);
}
static bool isPeXEnabled() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Bittorrent/PeX"), true).toBool();
}
static void setDHTEnabled(bool enabled) {
static void setPeXEnabled(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/DHT"), enabled);
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/PeX"), enabled);
}
static bool isDHTPortSameAsBT() {
@ -390,6 +473,11 @@ public: @@ -390,6 +473,11 @@ public:
return settings.value(QString::fromUtf8("Preferences/Bittorrent/LSD"), true).toBool();
}
static void setLSDEnabled(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/LSD"), enabled);
}
static bool isUtorrentSpoofingEnabled() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Bittorrent/utorrentSpoof"), false).toBool();
@ -400,6 +488,11 @@ public: @@ -400,6 +488,11 @@ public:
return settings.value(QString::fromUtf8("Preferences/Bittorrent/Encryption"), 0).toInt();
}
static void setEncryptionSetting(int val) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/Encryption"), val);
}
static float getDesiredRatio() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Bittorrent/DesiredRatio"), -1).toDouble();
@ -416,11 +509,21 @@ public: @@ -416,11 +509,21 @@ public:
return settings.value(QString::fromUtf8("Preferences/IPFilter/Enabled"), false).toBool();
}
static void setFilteringEnabled(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/IPFilter/Enabled"), enabled);
}
static QString getFilter() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/IPFilter/File"), QString()).toString();
}
static void setFilter(QString path) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/IPFilter/File"), path);
}
static void banIP(QString ip) {
QSettings settings("qBittorrent", "qBittorrent");
QStringList banned_ips = settings.value(QString::fromUtf8("Preferences/IPFilter/BannedIPs"), QStringList()).toStringList();
@ -457,21 +560,44 @@ public: @@ -457,21 +560,44 @@ public:
return settings.value("Preferences/Queueing/QueueingEnabled", false).toBool();
}
static void setQueueingSystemEnabled(bool enabled) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue("Preferences/Queueing/QueueingEnabled", enabled);
}
static int getMaxActiveDownloads() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Queueing/MaxActiveDownloads"), 3).toInt();
}
static void setMaxActiveDownloads(int val) {
QSettings settings("qBittorrent", "qBittorrent");
if(val < 0) val = -1;
settings.setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveDownloads"), val);
}
static int getMaxActiveUploads() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Queueing/MaxActiveUploads"), 3).toInt();
}
static void setMaxActiveUploads(int val) {
QSettings settings("qBittorrent", "qBittorrent");
if(val < 0) val = -1;
settings.setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveUploads"), val);
}
static int getMaxActiveTorrents() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Queueing/MaxActiveTorrents"), 5).toInt();
}
static void setMaxActiveTorrents(int val) {
QSettings settings("qBittorrent", "qBittorrent");
if(val < 0) val = -1;
settings.setValue(QString::fromUtf8("Preferences/Queueing/MaxActiveTorrents"), val);
}
static bool isWebUiEnabled() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value("Preferences/WebUI/Enabled", false).toBool();
@ -482,11 +608,21 @@ public: @@ -482,11 +608,21 @@ public:
return settings.value("Preferences/WebUI/Port", 8080).toInt();
}
static void setWebUiPort(quint16 port) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue("Preferences/WebUI/Port", port);
}
static QString getWebUiUsername() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value("Preferences/WebUI/Username", "admin").toString();
}
static void setWebUiUsername(QString username) {
QSettings settings("qBittorrent", "qBittorrent");
settings.setValue("Preferences/WebUI/Username", username);
}
static void setWebUiPassword(QString new_password) {
// Get current password md5
QString current_pass_md5 = getWebUiPassword();

14
src/ui/options.ui

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<class>Preferences</class>
<widget class="QDialog" name="Preferences">
<property name="geometry">
<rect>
<x>0</x>
@ -2345,8 +2345,8 @@ QGroupBox { @@ -2345,8 +2345,8 @@ QGroupBox {
<rect>
<x>0</x>
<y>0</y>
<width>228</width>
<height>124</height>
<width>620</width>
<height>495</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
@ -2378,7 +2378,7 @@ QGroupBox { @@ -2378,7 +2378,7 @@ QGroupBox {
<bool>false</bool>
</property>
<property name="text">
<string>Filter file path:</string>
<string>Filter path (.dat, .p2p, .p2b):</string>
</property>
</widget>
</item>
@ -2442,8 +2442,8 @@ QGroupBox { @@ -2442,8 +2442,8 @@ QGroupBox {
<rect>
<x>0</x>
<y>0</y>
<width>219</width>
<height>221</height>
<width>620</width>
<height>495</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">

1
src/webui.qrc

@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
<file>webui/uploadlimit.html</file>
<file>webui/downloadlimit.html</file>
<file>webui/preferences.html</file>
<file>webui/preferences_content.html</file>
<file>webui/css/Core.css</file>
<file>webui/css/Layout.css</file>
<file>webui/css/Window.css</file>

255
src/webui/preferences.html

@ -4,226 +4,53 @@ @@ -4,226 +4,53 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>_(Download from URL)</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/Tabs.css" type="text/css" />
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
<script type="text/javascript" src="scripts/mootools-1.2-more.js" charset="utf-8"></script>
<script type="text/javascript" src="scripts/mocha-yc.js" charset="utf-8"></script>
</head>
<body style="padding: 5px;">
<!-- preferences -->
<fieldset>
<legend><b>_(Global bandwidth limiting)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="up_limit_checkbox" onClick="updateUpLimitEnabled();"/></td><td style="padding-right: 3px;">_(Upload:)</td><td><input type="text" id="up_limit_value" style="width: 4em;"/>&nbsp;&nbsp;_(KiB/s)</td>
</tr>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="dl_limit_checkbox" onClick="updateDlLimitEnabled();"/></td><td style="padding-right: 3px;">_(Download:)</td><td><input type="text" id="dl_limit_value" style="width: 4em;"/>&nbsp;&nbsp;_(KiB/s)</td>
</tr>
</table>
</div>
</fieldset>
<br/>
<fieldset>
<legend><b>_(Connections limit)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="max_connec_checkbox" onClick="updateMaxConnecEnabled();"/></td><td style="padding-right: 3px;">_(Global maximum number of connections:)</td><td><input type="text" id="max_connec_value" style="width: 4em;"/></td>
</tr>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="max_connec_per_torrent_checkbox" onClick="updateMaxConnecPerTorrentEnabled();" style="margin-bottom: -2px;"/></td><td style="padding-right: 3px;">_(Maximum number of connections per torrent:)</td><td><input type="text" id="max_connec_per_torrent_value" style="width: 4em;"/></td>
</tr>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="max_uploads_per_torrent_checkbox" onClick="updateMaxUploadsPerTorrentEnabled();" style="margin-bottom: -2px;"/></td><td style="padding-right: 3px;">_(Maximum number of upload slots per torrent:)</td><td><input type="text" id="max_uploads_per_torrent_value" style="width: 4em;"/></td>
</tr>
</table>
</div>
</fieldset>
<br/>
<fieldset>
<legend><b>_(Bittorrent features)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="dht_checkbox"/></td><td>_(Enable DHT network (decentralized))</td>
</tr>
</table>
</div>
</fieldset>
<br/>
<center><input type="button" value="_(Apply)" onclick="applyPreferences();"/></center>
<script type="text/javascript">
applyPreferences = function() {
// Validate form data
var dl_limit = -1;
if($defined($('dl_limit_checkbox').get('checked')) && $('dl_limit_checkbox').get('checked')) {
dl_limit = $('dl_limit_value').get('value');
if(dl_limit <= 0) {
alert("_(Download rate limit must be greater than 0 or disabled.)");
return;
}
}
var up_limit = -1;
if($defined($('up_limit_checkbox').get('checked')) && $('up_limit_checkbox').get('checked')) {
up_limit = $('up_limit_value').get('value');
if(up_limit <= 0) {
alert("_(Upload rate limit must be greater than 0 or disabled.)");
return;
}
}
var max_connec = -1;
if($defined($('max_connec_checkbox').get('checked')) && $('max_connec_checkbox').get('checked')) {
max_connec = $('max_connec_value').get('value');
if(max_connec <= 0) {
alert("_(Maximum number of connections limit must be greater than 0 or disabled.)");
return;
}
}
var max_connec_per_torrent = -1;
if($defined($('max_connec_per_torrent_checkbox').get('checked')) && $('max_connec_per_torrent_checkbox').get('checked')) {
max_connec_per_torrent = $('max_connec_per_torrent_value').get('value');
if(max_connec_per_torrent <= 0) {
alert("_(Maximum number of connections per torrent limit must be greater than 0 or disabled.)");
return;
}
}
var max_uploads_per_torrent = -1;
if($defined($('max_uploads_per_torrent_checkbox').get('checked')) && $('max_uploads_per_torrent_checkbox').get('checked')) {
max_uploads_per_torrent = $('max_uploads_per_torrent_value').get('value');
if(max_uploads_per_torrent <= 0) {
alert("_(Maximum number of upload slots per torrent limit must be greater than 0 or disabled.)");
return;
}
}
// Send it to qBT
var dht = 0;
if($defined($('dht_checkbox').get('checked')) && $('dht_checkbox').get('checked'))
dht = 1;
new Request({url: '/command/setPreferences',
method: 'post',
data: {'up_limit': up_limit,
'dl_limit': dl_limit,
'dht': dht,
'max_connec': max_connec,
'max_connec_per_torrent': max_connec_per_torrent,
'max_uploads_per_torrent': max_uploads_per_torrent
},
onFailure: function() {
alert("_(Unable to save program preferences, qBittorrent is probably unreachable.)");
window.parent.closeWindows();
},
onSuccess: function() {
// Close window
window.parent.closeWindows();
}
}).send();
};
updateDlLimitEnabled = function() {
if($defined($('dl_limit_checkbox').get('checked')) && $('dl_limit_checkbox').get('checked')) {
$('dl_limit_value').set('disabled', 'false');
} else {
$('dl_limit_value').set('disabled', 'true');
}
}
updateUpLimitEnabled = function() {
if($defined($('up_limit_checkbox').get('checked')) && $('up_limit_checkbox').get('checked')) {
$('up_limit_value').removeProperty('disabled');
} else {
$('up_limit_value').set('disabled', 'true');
}
}
updateMaxConnecEnabled = function() {
if($defined($('max_connec_checkbox').get('checked')) && $('max_connec_checkbox').get('checked')) {
$('max_connec_value').removeProperty('disabled');
} else {
$('max_connec_value').set('disabled', 'true');
}
}
<div class="toolbarTabs">
<ul id="preferencesTabs" class="tab-menu">
<li id="PrefConnectionLink" class="selected"><a>_(Connection)</a></li>
<li id="PrefBittorrentLink"><a>_(Bittorrent)</a></li>
<li id="PrefDownloadsLink"><a>_(Downloads)</a></li>
<li id="PrefProxyLink"><a>_(Proxy)</a></li>
<li id="PrefFilterLink"><a>_(IP Filter)</a></li>
<li id="PrefWebUILink"><a>_(Web UI)</a></li>
</ul>
<div class="clear"></div>
</div>
updateMaxConnecPerTorrentEnabled = function() {
if($defined($('max_connec_per_torrent_checkbox').get('checked')) && $('max_connec_per_torrent_checkbox').get('checked')) {
$('max_connec_per_torrent_value').removeProperty('disabled');
} else {
$('max_connec_per_torrent_value').set('disabled', 'true');
}
}
updateMaxUploadsPerTorrentEnabled = function() {
if($defined($('max_uploads_per_torrent_checkbox').get('checked')) && $('max_uploads_per_torrent_checkbox').get('checked')) {
$('max_uploads_per_torrent_value').removeProperty('disabled');
} else {
$('max_uploads_per_torrent_value').set('disabled', 'true');
}
}
loadPreferences = function() {
var url = 'json/preferences';
var request = new Request.JSON({
url: url,
method: 'get',
noCache: true,
onFailure: function() {
alert("Could not contact qBittorrent");
},
onSuccess: function(pref) {
if(pref){
var dl_limit = pref.dl_limit.toInt();
if(dl_limit <= 0) {
$('dl_limit_checkbox').removeProperty('checked');
} else {
$('dl_limit_checkbox').set('checked', 'checked');
('dl_limit_value').set('value', dl_limit);
}
updateDlLimitEnabled();
var up_limit = pref.up_limit.toInt();
if(up_limit <= 0) {
$('up_limit_checkbox').removeProperty('checked');
} else {
$('up_limit_checkbox').set('checked', 'checked');
$('up_limit_value').set('value', up_limit);
}
updateUpLimitEnabled();
var dht = pref.dht; //bool
if(dht) {
$('dht_checkbox').set('checked', 'checked');
} else {
$('dht_checkbox').removeProperty('checked');
}
var max_connec = pref.max_connec.toInt();
if(max_connec <= 0) {
$('max_connec_checkbox').removeProperty('checked');
$('max_connec_value').set('value', 500);
} else {
$('max_connec_checkbox').set('checked', 'checked');
$('max_connec_value').set('value', max_connec);
}
updateMaxConnecEnabled();
var max_connec_per_torrent = pref.max_connec_per_torrent.toInt();
if(max_connec_per_torrent <= 0) {
$('max_connec_per_torrent_checkbox').removeProperty('checked');
$('max_connec_per_torrent_value').set('value', 100);
} else {
$('max_connec_per_torrent_checkbox').set('checked', 'checked');
$('max_connec_per_torrent_value').set('value', max_connec_per_torrent);
}
updateMaxConnecPerTorrentEnabled();
var max_uploads_per_torrent = pref.max_uploads_per_torrent.toInt();
if(max_uploads_per_torrent <= 0) {
$('max_uploads_per_torrent_checkbox').removeProperty('checked');
$('max_uploads_per_torrent_value').set('value', 4);
} else {
$('max_uploads_per_torrent_checkbox').set('checked', 'checked');
$('max_uploads_per_torrent_value').set('value', max_uploads_per_torrent);
}
updateMaxUploadsPerTorrentEnabled();
}
}
}).send();
}
<script type="text/javascript">
// Tabs
MochaUI.initializeTabs('preferencesTabs');
loadPreferences();
$('PrefConnectionLink').addEvent('click', function(e){
$$('.PrefTab').addClass('invisible');
$('ConnectionTab').removeClass('invisible');
});
$('PrefBittorrentLink').addEvent('click', function(e) {
$$('.PrefTab').addClass('invisible');
$('BittorrentTab').removeClass('invisible');
});
$('PrefDownloadsLink').addEvent('click', function(e) {
$$('.PrefTab').addClass('invisible');
$('DownloadsTab').removeClass('invisible');
});
$('PrefProxyLink').addEvent('click', function(e) {
$$('.PrefTab').addClass('invisible');
$('ProxyTab').removeClass('invisible');
});
$('PrefFilterLink').addEvent('click', function(e) {
$$('.PrefTab').addClass('invisible');
$('FilterTab').removeClass('invisible');
});
$('PrefWebUILink').addEvent('click', function(e) {
$$('.PrefTab').addClass('invisible');
$('WebUITab').removeClass('invisible');
});
</script>
</body>
</html>

614
src/webui/preferences_content.html

@ -0,0 +1,614 @@ @@ -0,0 +1,614 @@
<div id="ConnectionTab" class="PrefTab">
<fieldset>
<legend><b>_(Listening port)</b></legend>
<div style="padding-left: 30px;">
_(Port used for incoming connections:)
<input type="text" id="port_value" style="width: 4em;"/>
<br/>
<table>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="upnp_checkbox" style="margin-bottom: -2px;"/></td><td>_(Enable UPnP port mapping)</td>
</tr>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="natpmp_checkbox" style="margin-bottom: -2px;"/></td><td>_(Enable NAT-PMP port mapping)</td>
</tr>
</table>
</div>
</fieldset>
<fieldset>
<legend><b>_(Connections limit)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="max_connec_checkbox" onClick="updateMaxConnecEnabled();"/></td><td style="padding-right: 3px;">_(Global maximum number of connections:)</td><td><input type="text" id="max_connec_value" style="width: 4em;"/></td>
</tr>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="max_connec_per_torrent_checkbox" onClick="updateMaxConnecPerTorrentEnabled();" style="margin-bottom: -2px;"/></td><td style="padding-right: 3px;">_(Maximum number of connections per torrent:)</td><td><input type="text" id="max_connec_per_torrent_value" style="width: 4em;"/></td>
</tr>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="max_uploads_per_torrent_checkbox" onClick="updateMaxUploadsPerTorrentEnabled();" style="margin-bottom: -2px;"/></td><td style="padding-right: 3px;">_(Maximum number of upload slots per torrent:)</td><td><input type="text" id="max_uploads_per_torrent_value" style="width: 4em;"/></td>
</tr>
</table>
</div>
</fieldset>
<fieldset>
<legend><b>_(Global bandwidth limiting)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="up_limit_checkbox" onClick="updateUpLimitEnabled();"/></td><td style="padding-right: 3px;">_(Upload:)</td><td><input type="text" id="up_limit_value" style="width: 4em;"/>&nbsp;&nbsp;_(KiB/s)</td>
</tr>
<tr>
<td style="vertical-align: bottom;"><input type="checkbox" id="dl_limit_checkbox" onClick="updateDlLimitEnabled();"/></td><td style="padding-right: 3px;">_(Download:)</td><td><input type="text" id="dl_limit_value" style="width: 4em;"/>&nbsp;&nbsp;_(KiB/s)</td>
</tr>
</table>
</div>
</fieldset>
</div>
<div id="BittorrentTab" class="PrefTab invisible">
<fieldset>
<legend><b>_(Bittorrent features)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="dht_checkbox"/></td><td>_(Enable DHT network (decentralized))</td>
</tr>
<tr>
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="pex_checkbox"/></td><td>_(Enable Peer Exchange / PeX (requires restart))</td>
</tr>
<tr>
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="lsd_checkbox"/></td><td>_(Enable Local Peer Discovery)</td>
</tr>
</table>
_(Encryption:)
<select id="encryption_select">
<option value="0">_(Enabled)</option>
<option value="1">_(Forced)</option>
<option value="2">_(Disabled)</option>
</select><br/>
</div>
</fieldset>
</div>
<div id="DownloadsTab" class="PrefTab invisible">
<fieldset>
<legend><b>_(File system)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom; text-align: right;">_(Destination Folder:)</td><td><input type="text" id="savepath_text"/></td>
</tr>
<tr>
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="temppath_checkbox" onclick="updateTempDirEnabled();"/></td><td>_(Use a different folder for incomplete downloads:)</td>
</tr>
<tr>
<td style="vertical-align: bottom; text-align: right;"></td><td><input type="text" id="temppath_text"/></td>
</tr>
<tr>
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="scandir_checkbox" onclick="updateScanDirEnabled();"/></td><td>_(Automatically load .torrent files from:)</td>
</tr>
<tr>
<td style="vertical-align: bottom; text-align: right;"></td><td><input type="text" id="scandir_text"/></td>
</tr>
<tr id="appendexttr">
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="appendext_checkbox"/></td><td>_(Append .!qB extension to incomplete files)</td>
</tr>
<tr>
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="preallocateall_checkbox"/></td><td>_(Pre-allocate all files)</td>
</tr>
</table>
</div>
</fieldset>
<fieldset>
<legend><b>_(Torrent queueing)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom; text-align: right;"><input type="checkbox" id="queueing_checkbox" onclick="updateQueuingSystem();"/></td><td>_(Enable queueing system)</td>
</tr>
<tr>
<td style="vertical-align: bottom; text-align: right;">_(Maximum active downloads:)</td><td><input type="text" id="max_active_dl_value" style="width: 4em;"/></td>
</tr>
<tr>
<td style="vertical-align: bottom; text-align: right;">_(Maximum active uploads:)</td><td><input type="text" id="max_active_up_value" style="width: 4em;"/></td>
</tr>
<tr>
<td style="vertical-align: bottom; text-align: right;">_(Maximum active torrents:)</td><td><input type="text" id="max_active_to_value" style="width: 4em;"/></td>
</tr>
</table>
</div>
</fieldset>
</div>
<div id="FilterTab" class="PrefTab invisible">
<legend><b>_(Filter Settings)</b></legend>
<div style="padding-left: 30px;">
<input type="checkbox" id="ipfilter_enabled_checkbox" onclick="updateFilterSettings();"/> _(Activate IP Filtering)
<table>
<tr>
<td style="vertical-align: bottom;">_(Filter path (.dat, .p2p, .p2b):)</td><td><input type="text" id="ipfilter_text"/></td>
</tr>
</table>
</div>
</fieldset>
</div>
<div id="ProxyTab" class="PrefTab invisible">
Not implemented yet.
<!-- TODO -->
</div>
<div id="WebUITab" class="PrefTab invisible">
<fieldset>
<legend><b>_(User interface)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom;">_(Language:)</td>
<td style="padding-right: 3px;">
<select id="locale_select">
<option value="en_GB" style="background-image: url(Icons/flags/united_kingdom.png) no-repeat;">English</option>
<option value="fr_FR" style="background-image: url(Icons/flags/france.png) no-repeat;">Français</option>
<option value="de_DE" style="background-image: url(Icons/flags/germany.png) no-repeat;">Deutsch</option>
<option value="hu_HU" style="background-image: url(Icons/flags/hungary.png) no-repeat;">Magyar</option>
<option value="it_IT" style="background-image: url(Icons/flags/italy.png) no-repeat;">Italiano</option>
<option value="nl_NL" style="background-image: url(Icons/flags/netherlands.png) no-repeat;">Nederlands</option>
<option value="es_ES" style="background-image: url(Icons/flags/spain.png) no-repeat;">Español</option>
<option value="ca_ES" style="background-image: url(Icons/flags/spain_catalunya.png) no-repeat;">Català</option>
<option value="pt_PT" style="background-image: url(Icons/flags/portugal.png) no-repeat;">Português</option>
<option value="pt_BR" style="background-image: url(Icons/flags/brazil.png) no-repeat;">Português brasileiro</option>
<option value="pl_PL" style="background-image: url(Icons/flags/poland.png) no-repeat;">Polski</option>
<option value="cs_CZ" style="background-image: url(Icons/flags/czech.png) no-repeat;">Čeština</option>
<option value="sk_SK" style="background-image: url(Icons/flags/slovakia.png) no-repeat;">Slovenčina</option>
<option value="sr_CS" style="background-image: url(Icons/flags/serbia.png) no-repeat;">Српски</option>
<option value="ro_RO" style="background-image: url(Icons/flags/romania.png) no-repeat;">Română</option>
<option value="tr_TR" style="background-image: url(Icons/flags/turkey.png) no-repeat;">Türkçe</option>
<option value="el_GR" style="background-image: url(Icons/flags/greece.png) no-repeat;">Ελληνικά</option>
<option value="sv_SE" style="background-image: url(Icons/flags/sweden.png) no-repeat;">Svenska</option>
<option value="fi_FI" style="background-image: url(Icons/flags/finland.png) no-repeat;">Suomi</option>
<option value="nb_NO" style="background-image: url(Icons/flags/norway.png) no-repeat;">Norsk</option>
<option value="da_DK" style="background-image: url(Icons/flags/denmark.png) no-repeat;">Dansk</option>
<option value="bg_BG" style="background-image: url(Icons/flags/bulgaria.png) no-repeat;">Български</option>
<option value="uk_UA" style="background-image: url(Icons/flags/ukraine.png) no-repeat;">Українська</option>
<option value="ru_RU" style="background-image: url(Icons/flags/russia.png) no-repeat;">Русский</option>
<option value="ja_JP" style="background-image: url(Icons/flags/japan.png) no-repeat;">日本語</option>
<option value="zh_CN" style="background-image: url(Icons/flags/china.png) no-repeat;">中文 (简体)</option>
<option value="zh_TW" style="background-image: url(Icons/flags/taiwan.png) no-repeat;">中文 (繁體)</option>
<option value="ko_KR" style="background-image: url(Icons/flags/south_korea.png) no-repeat;">한글"</option>
</select>
</td>
</tr>
</table>
</div>
</fieldset>
<fieldset>
<legend><b>_(HTTP Server)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom;">_(Port:)</td><td style="padding-right: 3px;"><input type="text" id="webui_port_value" style="width: 4em;"/></td>
</tr>
</table>
</div>
</fieldset>
<fieldset>
<legend><b>_(Authentication)</b></legend>
<div style="padding-left: 30px;">
<table>
<tr>
<td style="vertical-align: bottom;">_(Username:)</td><td style="padding-right: 3px;"><input type="text" id="webui_username_text" /></td>
</tr>
<tr>
<td style="vertical-align: bottom;">_(Password:)</td><td style="padding-right: 3px;"><input type="password" id="webui_password_text" /></td>
</tr>
</table>
</div>
</fieldset>
</div>
<br/>
<center><input type="button" value="_(Apply)" onclick="applyPreferences();"/></center>
<script type="text/javascript">
applyPreferences = function() {
// Validate form data
// Connection
var listen_port = $('port_value').get('value').toInt();
if(listen_port <= 1024 || listen_port > 65535) {
alert("_(The port used for incoming connections must be greater than 1024 and less than 65535.)");
return;
}
var upnp = 0;
if($defined($('upnp_checkbox').get('checked')) && $('upnp_checkbox').get('checked'))
upnp = 1;
var natpmp = 0;
if($defined($('natpmp_checkbox').get('checked')) && $('natpmp_checkbox').get('checked'))
natpmp = 1;
var dl_limit = -1;
if($defined($('dl_limit_checkbox').get('checked')) && $('dl_limit_checkbox').get('checked')) {
dl_limit = $('dl_limit_value').get('value');
if(dl_limit <= 0) {
alert("_(Download rate limit must be greater than 0 or disabled.)");
return;
}
}
var up_limit = -1;
if($defined($('up_limit_checkbox').get('checked')) && $('up_limit_checkbox').get('checked')) {
up_limit = $('up_limit_value').get('value');
if(up_limit <= 0) {
alert("_(Upload rate limit must be greater than 0 or disabled.)");
return;
}
}
var max_connec = -1;
if($defined($('max_connec_checkbox').get('checked')) && $('max_connec_checkbox').get('checked')) {
max_connec = $('max_connec_value').get('value');
if(max_connec <= 0) {
alert("_(Maximum number of connections limit must be greater than 0 or disabled.)");
return;
}
}
var max_connec_per_torrent = -1;
if($defined($('max_connec_per_torrent_checkbox').get('checked')) && $('max_connec_per_torrent_checkbox').get('checked')) {
max_connec_per_torrent = $('max_connec_per_torrent_value').get('value');
if(max_connec_per_torrent <= 0) {
alert("_(Maximum number of connections per torrent limit must be greater than 0 or disabled.)");
return;
}
}
var max_uploads_per_torrent = -1;
if($defined($('max_uploads_per_torrent_checkbox').get('checked')) && $('max_uploads_per_torrent_checkbox').get('checked')) {
max_uploads_per_torrent = $('max_uploads_per_torrent_value').get('value');
if(max_uploads_per_torrent <= 0) {
alert("_(Maximum number of upload slots per torrent limit must be greater than 0 or disabled.)");
return;
}
}
// Bittorrent
var dht = 0;
if($defined($('dht_checkbox').get('checked')) && $('dht_checkbox').get('checked'))
dht = 1;
var pex = 0;
if($defined($('pex_checkbox').get('checked')) && $('pex_checkbox').get('checked'))
pex = 1;
var lsd = 0;
if($defined($('lsd_checkbox').get('checked')) && $('lsd_checkbox').get('checked'))
lsd = 1;
// Downloads
var save_path = $("savepath_text").get('value');
var temp_path_enabled = 0
if($defined($('temppath_checkbox').get('checked')) && $('temppath_checkbox').get('checked'))
temp_path_enabled = 1;
var temp_path = $('temppath_text').get('value');
var scandir_enabled = 0;
if($defined($('scandir_checkbox').get('checked')) && $('scandir_checkbox').get('checked'))
scandir_enabled = 1;
var scandir_path = '';
if(scandir_enabled)
scandir_path = $('scandir_text').get('value');
var preallocate_all = 0;
if($defined($('preallocateall_checkbox').get('checked')) && $('preallocateall_checkbox').get('checked'))
preallocate_all = 1;
if(!$('appendexttr').hasClass('invisible')) {
var incomplete_files_ext = 0;
if($defined($('appendext_checkbox').get('checked')) && $('appendext_checkbox').get('checked'))
incomplete_files_ext = 1;
}
var queueing_enabled = 0;
if($defined($('queueing_checkbox').get('checked')) && $('queueing_checkbox').get('checked'))
queueing_enabled = 1;
var max_active_downloads = $('max_active_dl_value').get('value');
var max_active_uploads = $('max_active_up_value').get('value');
var max_active_torrents = $('max_active_to_value').get('value');
// IP Filter
var ip_filter_enabled = 0;
if($defined($('ipfilter_enabled_checkbox').get('checked')) && $('ipfilter_enabled_checkbox').get('checked'))
ip_filter_enabled = 1;
var ip_filter_path = $('ipfilter_text').get('value');
// Web UI
var webui_port = $('webui_port_value').get('value').toInt();
if(webui_port <= 1024 || webui_port > 65535) {
alert("_(The port used for the Web UI must be greater than 1024 and less than 65535.)");
return;
}
var webui_username = $('webui_username_text').get('value');
var webui_password = $('webui_password_text').get('value');
// Add some username/password length checking
if(webui_username.length < 3) {
alert("_(The Web UI username must be at least 3 characters long.)");
return;
}
if(webui_password.length < 3) {
alert("_(The Web UI password must be at least 3 characters long.)");
return;
}
var locale = $('locale_select').get('value');
// Send it to qBT
var dict = new Hash();
// Connection
dict.set('listen_port', listen_port);
dict.set('upnp', upnp);
dict.set('natpmp', natpmp);
dict.set('up_limit', up_limit);
dict.set('dl_limit', dl_limit);
dict.set('max_connec', max_connec);
dict.set('max_connec_per_torrent', max_connec_per_torrent);
dict.set('max_uploads_per_torrent', max_uploads_per_torrent);
// Bittorrent
dict.set('dht', dht);
dict.set('pex', pex);
dict.set('lsd', lsd);
dict.set('encryption', $('encryption_select').get('value'));
// Downloads
dict.set('save_path', save_path);
dict.set('temp_path_enabled', temp_path_enabled);
dict.set('temp_path', temp_path);
dict.set('scan_dir', scandir_path);
dict.set('preallocate_all', preallocate_all);
if(!$('appendexttr').hasClass('invisible')) {
dict.set('incomplete_files_ext', incomplete_files_ext);
}
dict.set('queueing_enabled', queueing_enabled);
dict.set('max_active_uploads', max_active_uploads);
dict.set('max_active_downloads', max_active_downloads);
dict.set('max_active_torrents', max_active_torrents);
// IP Filter
dict.set('ip_filter_enabled', ip_filter_enabled);
dict.set('ip_filter_path', ip_filter_path);
// Web UI
dict.set('web_ui_port', webui_port);
dict.set('web_ui_username', webui_username);
dict.set('web_ui_password', webui_password);
dict.set('locale', locale);
var json_str = JSON.encode(dict);
new Request({url: '/command/setPreferences',
method: 'post',
data: {'json': json_str,
},
onFailure: function() {
alert("_(Unable to save program preferences, qBittorrent is probably unreachable.)");
window.parent.closeWindows();
},
onSuccess: function() {
// Close window
window.parent.closeWindows();
}
}).send();
};
updateDlLimitEnabled = function() {
if($defined($('dl_limit_checkbox').get('checked')) && $('dl_limit_checkbox').get('checked')) {
$('dl_limit_value').set('disabled', 'false');
} else {
$('dl_limit_value').set('disabled', 'true');
}
}
updateUpLimitEnabled = function() {
if($defined($('up_limit_checkbox').get('checked')) && $('up_limit_checkbox').get('checked')) {
$('up_limit_value').removeProperty('disabled');
} else {
$('up_limit_value').set('disabled', 'true');
}
}
updateMaxConnecEnabled = function() {
if($defined($('max_connec_checkbox').get('checked')) && $('max_connec_checkbox').get('checked')) {
$('max_connec_value').removeProperty('disabled');
} else {
$('max_connec_value').set('disabled', 'true');
}
}
updateMaxConnecPerTorrentEnabled = function() {
if($defined($('max_connec_per_torrent_checkbox').get('checked')) && $('max_connec_per_torrent_checkbox').get('checked')) {
$('max_connec_per_torrent_value').removeProperty('disabled');
} else {
$('max_connec_per_torrent_value').set('disabled', 'true');
}
}
updateMaxUploadsPerTorrentEnabled = function() {
if($defined($('max_uploads_per_torrent_checkbox').get('checked')) && $('max_uploads_per_torrent_checkbox').get('checked')) {
$('max_uploads_per_torrent_value').removeProperty('disabled');
} else {
$('max_uploads_per_torrent_value').set('disabled', 'true');
}
}
updateTempDirEnabled = function() {
if($defined($('temppath_checkbox').get('checked')) && $('temppath_checkbox').get('checked')) {
$('temppath_text').removeProperty('disabled');
} else {
$('temppath_text').set('disabled', 'true');
}
}
updateScanDirEnabled = function() {
if($defined($('scandir_checkbox').get('checked')) && $('scandir_checkbox').get('checked')) {
$('scandir_text').removeProperty('disabled');
} else {
$('scandir_text').set('disabled', 'true');
}
}
updateQueueingSystem = function() {
if($defined($('queueing_checkbox').get('checked')) && $('queueing_checkbox').get('checked')) {
$('max_active_dl_value').removeProperty('disabled');
$('max_active_up_value').removeProperty('disabled');
$('max_active_to_value').removeProperty('disabled');
} else {
$('max_active_dl_value').set('disabled', 'true');
$('max_active_up_value').set('disabled', 'true');
$('max_active_to_value').set('disabled', 'true');
}
}
updateFilterSettings = function() {
if($defined($('ipfilter_enabled_checkbox').get('checked')) && $('ipfilter_enabled_checkbox').get('checked')) {
$('ipfilter_text').removeProperty('disabled');
} else {
$('ipfilter_text').set('disabled', 'true');
}
}
loadPreferences = function() {
var url = 'json/preferences';
var request = new Request.JSON({
url: url,
method: 'get',
noCache: true,
onFailure: function() {
alert("Could not contact qBittorrent");
},
onSuccess: function(pref) {
if(pref){
// Connection
var listen_port = pref.listen_port.toInt();
$('port_value').set('value', listen_port);
if(pref.upnp) {
$('upnp_checkbox').set('checked', 'checked');
} else {
$('upnp_checkbox').removeProperty('checked');
}
if(pref.natpmp) {
$('natpmp_checkbox').set('checked', 'checked');
} else {
$('natpmp_checkbox').removeProperty('checked');
}
var dl_limit = pref.dl_limit.toInt();
if(dl_limit <= 0) {
$('dl_limit_checkbox').removeProperty('checked');
} else {
$('dl_limit_checkbox').set('checked', 'checked');
('dl_limit_value').set('value', dl_limit);
}
updateDlLimitEnabled();
var up_limit = pref.up_limit.toInt();
if(up_limit <= 0) {
$('up_limit_checkbox').removeProperty('checked');
} else {
$('up_limit_checkbox').set('checked', 'checked');
$('up_limit_value').set('value', up_limit);
}
updateUpLimitEnabled();
var max_connec = pref.max_connec.toInt();
if(max_connec <= 0) {
$('max_connec_checkbox').removeProperty('checked');
$('max_connec_value').set('value', 500);
} else {
$('max_connec_checkbox').set('checked', 'checked');
$('max_connec_value').set('value', max_connec);
}
updateMaxConnecEnabled();
var max_connec_per_torrent = pref.max_connec_per_torrent.toInt();
if(max_connec_per_torrent <= 0) {
$('max_connec_per_torrent_checkbox').removeProperty('checked');
$('max_connec_per_torrent_value').set('value', 100);
} else {
$('max_connec_per_torrent_checkbox').set('checked', 'checked');
$('max_connec_per_torrent_value').set('value', max_connec_per_torrent);
}
updateMaxConnecPerTorrentEnabled();
var max_uploads_per_torrent = pref.max_uploads_per_torrent.toInt();
if(max_uploads_per_torrent <= 0) {
$('max_uploads_per_torrent_checkbox').removeProperty('checked');
$('max_uploads_per_torrent_value').set('value', 4);
} else {
$('max_uploads_per_torrent_checkbox').set('checked', 'checked');
$('max_uploads_per_torrent_value').set('value', max_uploads_per_torrent);
}
updateMaxUploadsPerTorrentEnabled();
// Bittorrent
var dht = pref.dht; //bool
if(dht) {
$('dht_checkbox').set('checked', 'checked');
} else {
$('dht_checkbox').removeProperty('checked');
}
var pex = pref.pex; //bool
if(pex) {
$('pex_checkbox').set('checked', 'checked');
} else {
$('pex_checkbox').removeProperty('checked');
}
var lsd = pref.lsd; //bool
if(lsd) {
$('lsd_checkbox').set('checked', 'checked');
} else {
$('lsd_checkbox').removeProperty('checked');
}
var encryption = pref.encryption.toInt();
$('encryption_select').getChildren('option')[encryption].setAttribute('selected', '');
// Downloads
var save_path = pref.save_path;
$("savepath_text").set('value', save_path);
var temp_path_enabled = pref.temp_path_enabled;
if(temp_path_enabled) {
$('temppath_checkbox').set('checked', 'checked');
} else {
$('temppath_checkbox').removeProperty('checked');
}
var temp_path = pref.temp_path;
$('temppath_text').set('value', temp_path);
updateTempDirEnabled();
var scan_dir_enabled = pref.scan_dir_enabled;
if(scan_dir_enabled) {
$('scandir_text').set('value', pref.scan_dir);
} else {
$('scandir_text').set('value', '');
}
updateScanDirEnabled();
if(pref.preallocate_all) {
$('preallocateall_checkbox').set('checked', 'checked');
} else {
$('preallocateall_checkbox').removeProperty('checked');
}
if($defined(pref.incomplete_files_ext)) {
$('appendexttr').removeClass('invisible');
if(pref.incomplete_files_ext) {
$('appendext_checkbox').set('checked', 'checked');
} else {
$('appendext_checkbox').removeProperty('checked');
}
} else {
$('appendexttr').addClass('invisible');
}
if(pref.queueing_enabled) {
$('queueing_checkbox').set('checked', 'checked');
} else {
$('queueing_checkbox').removeProperty('checked');
}
$('max_active_dl_value').set('value', pref.max_active_downloads.toInt());
$('max_active_up_value').set('value', pref.max_active_uploads.toInt());
$('max_active_to_value').set('value', pref.max_active_torrents.toInt());
updateQueueingSystem();
// IP Filter
if(pref.ip_filter_enabled) {
$('ipfilter_enabled_checkbox').set('checked', 'checked');
} else {
$('ipfilter_enabled_checkbox').removeProperty('checked');
}
$('ipfilter_text').set('value', pref.ip_filter_path);
updateFilterSettings();
// Web UI
$('webui_port_value').set('value', pref.web_ui_port);
$('webui_username_text').set('value', pref.web_ui_username);
$('webui_password_text').set('value', pref.web_ui_password);
$('locale_select').set('value', pref.locale);
}
}
}).send();
}
loadPreferences();
</script>

60
src/webui/prop-files.html

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
<th>_(Name)</th>
<th>_(Size)</th>
<th style="width: 90px;">_(Progress)</th>
<th>_(Priority)</th>
<th>_(Downloaded)</th>
</tr>
</thead>
<tbody id="filesTable"></tbody>
@ -21,38 +21,19 @@ var setFilePriority = function(id, priority) { @@ -21,38 +21,19 @@ var setFilePriority = function(id, priority) {
new Request({url: '/command/setFilePrio', method: 'post', data: {'hash': current_hash, 'id': id, 'priority': priority}}).send();
}
var createPriorityCombo = function(id, selected_prio) {
var select = new Element('select');
select.set('id', 'comboPrio'+id);
var createDownloadedCB = function(id, downloaded) {
var CB = new Element('input');
CB.set('type', 'checkbox');
if(downloaded)
CB.set('checked', 'checked');
CB.set('id', 'cbPrio'+id);
select.addEvent('change', function(e){
var new_prio = $('comboPrio'+id).get('value');
setFilePriority(id, new_prio);
var checked = 0;
if($defined($('cbPrio'+id).get('checked')) && $('cbPrio'+id).get('checked'))
checked = 1;
setFilePriority(id, checked);
});
var opt = new Element("option");
opt.set('value', '0')
opt.set('html', "_(Ignored)");
if(selected_prio == 0)
opt.setAttribute('selected', '');
opt.injectInside(select);
opt = new Element("option");
opt.set('value', '1')
opt.set('html', "_(Normal)");
if(selected_prio == 1)
opt.setAttribute('selected', '');
opt.injectInside(select);
opt = new Element("option");
opt.set('value', '2')
opt.set('html', "_(High)");
if(selected_prio == 2)
opt.setAttribute('selected', '');
opt.injectInside(select);
opt = new Element("option");
opt.set('value', '7')
opt.set('html', "_(Maximum)");
if(selected_prio == 7)
opt.setAttribute('selected', '');
opt.injectInside(select);
return select;
return CB;
}
var filesDynTable = new Class ({
@ -81,17 +62,18 @@ var createPriorityCombo = function(id, selected_prio) { @@ -81,17 +62,18 @@ var createPriorityCombo = function(id, selected_prio) {
}.bind(this));
},
updateRow: function(tr, row){
updateRow: function(tr, row, id){
var tds = tr.getElements('td');
for(var i=0; i<row.length; i++) {
if(i==2) {
tds[i].set('html', '');
tds[i].adopt(new ProgressBar(row[i].toFloat(), {width:80}));
$('pbf_'+id).setValue(row[i].toFloat());
} else {
if(i==3) {
tds[i].getChildren('select').set('value', row[i]);
//tds[i].set('html', '');
//tds[i].adopt(createPriorityCombo(id,row[i]));
if(row[i] > 0)
tds[i].getChildren('input')[0].set('checked', 'checked');
else
tds[i].removeProperty('checked')
} else {
tds[i].set('html', row[i]);
}
@ -103,7 +85,7 @@ var createPriorityCombo = function(id, selected_prio) { @@ -103,7 +85,7 @@ var createPriorityCombo = function(id, selected_prio) {
insertRow: function(id, row) {
if(this.rows.has(id)) {
var tr = this.rows.get(id);
this.updateRow(tr, row);
this.updateRow(tr, row, id);
return;
}
//this.removeRow(id);
@ -113,10 +95,10 @@ var createPriorityCombo = function(id, selected_prio) { @@ -113,10 +95,10 @@ var createPriorityCombo = function(id, selected_prio) {
{
var td = new Element('td');
if(i==2) {
td.adopt(new ProgressBar(row[i].toFloat(), {width:80}));
td.adopt(new ProgressBar(row[i].toFloat(), {'id', 'pbf_'+id, 'width':80}));
} else {
if(i == 3) {
td.adopt(createPriorityCombo(id,row[i]));
td.adopt(createDownloadedCB(id,row[i]));
} else {
td.set('html', row[i]);
}

4
src/webui/properties.html

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
<script type="text/javascript">
MochaUI.initializeTabs('propertiesTabs');
MochaUI.updateContent({
/*MochaUI.updateContent({
'element': $('properties'),
'url': 'prop-general.html'
});
});*/
$('PropGeneralLink').addEvent('click', function(e){
MochaUI.updateContent({

14
src/webui/scripts/mocha-init.js

@ -42,15 +42,19 @@ initializeWindows = function(){ @@ -42,15 +42,19 @@ initializeWindows = function(){
new MochaUI.Window({
id: 'preferencesPage',
title: "_(Preferences)",
loadMethod: 'iframe',
contentURL:'preferences.html',
scrollbars: false,
resizable: false,
loadMethod: 'xhr',
toolbar: true,
contentURL: 'preferences_content.html',
require: {
css: ['css/Tabs.css']
},
toolbarURL: 'preferences.html',
resizable: true,
maximizable: false,
closable: true,
paddingVertical: 0,
paddingHorizontal: 0,
width: 500,
width: 700,
height: 300
});
});

Loading…
Cancel
Save