diff --git a/src/preferences/options.ui b/src/preferences/options.ui
index 124e7e4d5..791052de6 100644
--- a/src/preferences/options.ui
+++ b/src/preferences/options.ui
@@ -970,7 +970,7 @@
0
0
474
- 577
+ 498
@@ -1073,7 +1073,7 @@
- -
+
-
Maximum number of connections per torrent:
@@ -1083,7 +1083,7 @@
- -
+
-
2
@@ -1096,7 +1096,7 @@
- -
+
-
Maximum number of upload slots per torrent:
@@ -1106,7 +1106,7 @@
- -
+
-
500
@@ -1129,7 +1129,7 @@
- -
+
-
Qt::Horizontal
@@ -1142,7 +1142,7 @@
- -
+
-
Qt::Horizontal
@@ -1155,6 +1155,39 @@
+ -
+
+
+ Global maximum number of upload slots:
+
+
+ true
+
+
+
+ -
+
+
+ 2000
+
+
+ 8
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
@@ -2810,5 +2843,21 @@
+
+ checkMaxUploads
+ toggled(bool)
+ spinMaxUploads
+ setEnabled(bool)
+
+
+ 423
+ 224
+
+
+ 571
+ 224
+
+
+
diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp
index 6064b5b26..d8ec11908 100644
--- a/src/preferences/options_imp.cpp
+++ b/src/preferences/options_imp.cpp
@@ -195,9 +195,11 @@ options_imp::options_imp(QWidget *parent):
// Bittorrent tab
connect(checkMaxConnecs, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkMaxConnecsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
+ connect(checkMaxUploads, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkMaxUploadsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(spinMaxConnec, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinMaxConnecPerTorrent, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
+ connect(spinMaxUploads, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinMaxUploadsPerTorrent, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkDHT, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
#if LIBTORRENT_VERSION_MINOR > 15
@@ -438,6 +440,7 @@ void options_imp::saveOptions() {
// Bittorrent preferences
pref.setMaxConnecs(getMaxConnecs());
pref.setMaxConnecsPerTorrent(getMaxConnecsPerTorrent());
+ pref.setMaxUploads(getMaxUploads());
pref.setMaxUploadsPerTorrent(getMaxUploadsPerTorrent());
pref.setDHTEnabled(isDHTEnabled());
pref.setPeXEnabled(checkPeX->isChecked());
@@ -686,6 +689,17 @@ void options_imp::loadOptions() {
checkMaxConnecsPerTorrent->setChecked(false);
spinMaxConnecPerTorrent->setEnabled(false);
}
+ intValue = pref.getMaxUploads();
+ if (intValue > 0) {
+ // enable
+ checkMaxUploads->setChecked(true);
+ spinMaxUploads->setEnabled(true);
+ spinMaxUploads->setValue(intValue);
+ } else {
+ // disable
+ checkMaxUploads->setChecked(false);
+ spinMaxUploads->setEnabled(false);
+ }
intValue = pref.getMaxUploadsPerTorrent();
if (intValue > 0) {
// enable
@@ -882,6 +896,14 @@ int options_imp::getMaxConnecsPerTorrent() const {
}
}
+int options_imp::getMaxUploads() const {
+ if (!checkMaxUploads->isChecked()) {
+ return -1;
+ }else{
+ return spinMaxUploads->value();
+ }
+}
+
int options_imp::getMaxUploadsPerTorrent() const {
if (!checkMaxUploadsPerTorrent->isChecked()) {
return -1;
diff --git a/src/preferences/options_imp.h b/src/preferences/options_imp.h
index 112bf1b97..9ebdd0268 100644
--- a/src/preferences/options_imp.h
+++ b/src/preferences/options_imp.h
@@ -117,6 +117,7 @@ private:
// Bittorrent options
int getMaxConnecs() const;
int getMaxConnecsPerTorrent() const;
+ int getMaxUploads() const;
int getMaxUploadsPerTorrent() const;
bool isDHTEnabled() const;
bool isDHTPortSameAsBT() const;
diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h
index 8697334a5..b8066587a 100644
--- a/src/preferences/preferences.h
+++ b/src/preferences/preferences.h
@@ -541,6 +541,15 @@ public:
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxConnecsPerTorrent"), val);
}
+ int getMaxUploads() const {
+ return value(QString::fromUtf8("Preferences/Bittorrent/MaxUploads"), 8).toInt();
+ }
+
+ void setMaxUploads(int val) {
+ if (val <= 0) val = -1;
+ setValue(QString::fromUtf8("Preferences/Bittorrent/MaxUploads"), val);
+ }
+
int getMaxUploadsPerTorrent() const {
return value(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), 4).toInt();
}
diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp
index 73aa8426e..2e079fa46 100644
--- a/src/qtlibtorrent/qbtsession.cpp
+++ b/src/qtlibtorrent/qbtsession.cpp
@@ -453,11 +453,15 @@ void QBtSession::configureSession() {
sessionSettings.half_open_limit = pref.getMaxHalfOpenConnections();
// * Max connections limit
sessionSettings.connections_limit = pref.getMaxConnecs();
+ // * Global max upload slots
+ sessionSettings.unchoke_slots_limit = pref.getMaxUploads();
#else
// * Max Half-open connections
s->set_max_half_open_connections(pref.getMaxHalfOpenConnections());
// * Max connections limit
setMaxConnections(pref.getMaxConnecs());
+ // * Global max upload slots
+ s->set_max_uploads(pref.getMaxUploads());
#endif
#if LIBTORRENT_VERSION_MINOR > 15
// uTP