Allow more fine tuning of uploads. Closes #684.

This commit is contained in:
sledgehammer999 2013-07-22 01:20:48 +03:00
parent 102b2dc738
commit 798bd2388b
5 changed files with 92 additions and 7 deletions

View file

@ -1023,7 +1023,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>458</width> <width>458</width>
<height>472</height> <height>498</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_20"> <layout class="QVBoxLayout" name="verticalLayout_20">
@ -1133,7 +1133,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="2" column="0">
<widget class="QCheckBox" name="checkMaxConnecsPerTorrent"> <widget class="QCheckBox" name="checkMaxConnecsPerTorrent">
<property name="text"> <property name="text">
<string>Maximum number of connections per torrent:</string> <string>Maximum number of connections per torrent:</string>
@ -1143,7 +1143,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="2" column="1">
<widget class="QSpinBox" name="spinMaxConnecPerTorrent"> <widget class="QSpinBox" name="spinMaxConnecPerTorrent">
<property name="minimum"> <property name="minimum">
<number>2</number> <number>2</number>
@ -1156,7 +1156,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="4" column="0">
<widget class="QCheckBox" name="checkMaxUploadsPerTorrent"> <widget class="QCheckBox" name="checkMaxUploadsPerTorrent">
<property name="text"> <property name="text">
<string>Maximum number of upload slots per torrent:</string> <string>Maximum number of upload slots per torrent:</string>
@ -1166,7 +1166,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="4" column="1">
<widget class="QSpinBox" name="spinMaxUploadsPerTorrent"> <widget class="QSpinBox" name="spinMaxUploadsPerTorrent">
<property name="maximum"> <property name="maximum">
<number>500</number> <number>500</number>
@ -1189,7 +1189,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="2"> <item row="2" column="2">
<spacer name="horizontalSpacer_4"> <spacer name="horizontalSpacer_4">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -1202,7 +1202,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="2" column="2"> <item row="4" column="2">
<spacer name="horizontalSpacer_6"> <spacer name="horizontalSpacer_6">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -1215,6 +1215,39 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkMaxUploads">
<property name="text">
<string>Global maximum number of upload slots:</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QSpinBox" name="spinMaxUploads">
<property name="maximum">
<number>2000</number>
</property>
<property name="value">
<number>8</number>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_15">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -2870,5 +2903,21 @@
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>checkMaxUploads</sender>
<signal>toggled(bool)</signal>
<receiver>spinMaxUploads</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>423</x>
<y>224</y>
</hint>
<hint type="destinationlabel">
<x>571</x>
<y>224</y>
</hint>
</hints>
</connection>
</connections> </connections>
</ui> </ui>

View file

@ -201,9 +201,11 @@ options_imp::options_imp(QWidget *parent):
// Bittorrent tab // Bittorrent tab
connect(checkMaxConnecs, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkMaxConnecs, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkMaxConnecsPerTorrent, 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(checkMaxUploadsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(spinMaxConnec, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinMaxConnec, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinMaxConnecPerTorrent, 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(spinMaxUploadsPerTorrent, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkDHT, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkDHT, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
#if LIBTORRENT_VERSION_NUM >= 001600 #if LIBTORRENT_VERSION_NUM >= 001600
@ -449,6 +451,7 @@ void options_imp::saveOptions() {
// Bittorrent preferences // Bittorrent preferences
pref.setMaxConnecs(getMaxConnecs()); pref.setMaxConnecs(getMaxConnecs());
pref.setMaxConnecsPerTorrent(getMaxConnecsPerTorrent()); pref.setMaxConnecsPerTorrent(getMaxConnecsPerTorrent());
pref.setMaxUploads(getMaxUploads());
pref.setMaxUploadsPerTorrent(getMaxUploadsPerTorrent()); pref.setMaxUploadsPerTorrent(getMaxUploadsPerTorrent());
pref.setDHTEnabled(isDHTEnabled()); pref.setDHTEnabled(isDHTEnabled());
pref.setPeXEnabled(checkPeX->isChecked()); pref.setPeXEnabled(checkPeX->isChecked());
@ -713,6 +716,17 @@ void options_imp::loadOptions() {
checkMaxConnecsPerTorrent->setChecked(false); checkMaxConnecsPerTorrent->setChecked(false);
spinMaxConnecPerTorrent->setEnabled(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(); intValue = pref.getMaxUploadsPerTorrent();
if (intValue > 0) { if (intValue > 0) {
// enable // enable
@ -907,6 +921,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 { int options_imp::getMaxUploadsPerTorrent() const {
if (!checkMaxUploadsPerTorrent->isChecked()) { if (!checkMaxUploadsPerTorrent->isChecked()) {
return -1; return -1;

View file

@ -123,6 +123,7 @@ private:
// Bittorrent options // Bittorrent options
int getMaxConnecs() const; int getMaxConnecs() const;
int getMaxConnecsPerTorrent() const; int getMaxConnecsPerTorrent() const;
int getMaxUploads() const;
int getMaxUploadsPerTorrent() const; int getMaxUploadsPerTorrent() const;
bool isDHTEnabled() const; bool isDHTEnabled() const;
bool isDHTPortSameAsBT() const; bool isDHTPortSameAsBT() const;

View file

@ -588,6 +588,15 @@ public:
setValue(QString::fromUtf8("Preferences/Bittorrent/MaxConnecsPerTorrent"), val); 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 { int getMaxUploadsPerTorrent() const {
return value(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), 4).toInt(); return value(QString::fromUtf8("Preferences/Bittorrent/MaxUploadsPerTorrent"), 4).toInt();
} }

View file

@ -475,11 +475,15 @@ void QBtSession::configureSession() {
sessionSettings.half_open_limit = pref.getMaxHalfOpenConnections(); sessionSettings.half_open_limit = pref.getMaxHalfOpenConnections();
// * Max connections limit // * Max connections limit
sessionSettings.connections_limit = pref.getMaxConnecs(); sessionSettings.connections_limit = pref.getMaxConnecs();
// * Global max upload slots
sessionSettings.unchoke_slots_limit = pref.getMaxUploads();
#else #else
// * Max Half-open connections // * Max Half-open connections
s->set_max_half_open_connections(pref.getMaxHalfOpenConnections()); s->set_max_half_open_connections(pref.getMaxHalfOpenConnections());
// * Max connections limit // * Max connections limit
setMaxConnections(pref.getMaxConnecs()); setMaxConnections(pref.getMaxConnecs());
// * Global max upload slots
s->set_max_uploads(pref.getMaxUploads());
#endif #endif
#if LIBTORRENT_VERSION_NUM >= 001600 #if LIBTORRENT_VERSION_NUM >= 001600
// uTP // uTP