Browse Source

Still simplifying program options

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
da599da36d
  1. 22
      src/bittorrent.cpp
  2. 1
      src/bittorrent.h
  3. 28
      src/options_imp.cpp
  4. 2
      src/options_imp.h
  5. 5
      src/preferences.h
  6. 64
      src/ui/options.ui

22
src/bittorrent.cpp

@ -521,8 +521,6 @@ void Bittorrent::configureSession() {
addConsoleMessage(tr("Encryption support [OFF]"), QString::fromUtf8("blue")); addConsoleMessage(tr("Encryption support [OFF]"), QString::fromUtf8("blue"));
} }
applyEncryptionSettings(encryptionSettings); applyEncryptionSettings(encryptionSettings);
// * Desired ratio
setGlobalRatio(Preferences::getDesiredRatio());
// * Maximum ratio // * Maximum ratio
setDeleteRatio(Preferences::getDeleteRatio()); setDeleteRatio(Preferences::getDeleteRatio());
// Ip Filter // Ip Filter
@ -1763,26 +1761,6 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
s->set_upload_rate_limit(rate); s->set_upload_rate_limit(rate);
} }
// libtorrent allow to adjust ratio for each torrent
// This function will apply to same ratio to all torrents
void Bittorrent::setGlobalRatio(float ratio) {
if(ratio != -1 && ratio < 1.) ratio = 1.;
if(ratio == -1) {
// 0 means unlimited for libtorrent
ratio = 0;
}
std::vector<torrent_handle> handles = s->get_torrents();
std::vector<torrent_handle>::iterator it;
for(it = handles.begin(); it != handles.end(); it++) {
QTorrentHandle h(*it);
if(!h.is_valid()) {
qDebug("/!\\ Error: Invalid handle");
continue;
}
h.set_ratio(ratio);
}
}
// Torrents will a ratio superior to the given value will // Torrents will a ratio superior to the given value will
// be automatically deleted // be automatically deleted
void Bittorrent::setDeleteRatio(float ratio) { void Bittorrent::setDeleteRatio(float ratio) {

1
src/bittorrent.h

@ -153,7 +153,6 @@ public slots:
void setMaxUploadsPerTorrent(int max); void setMaxUploadsPerTorrent(int max);
void setDownloadRateLimit(long rate); void setDownloadRateLimit(long rate);
void setUploadRateLimit(long rate); void setUploadRateLimit(long rate);
void setGlobalRatio(float ratio);
void setDeleteRatio(float ratio); void setDeleteRatio(float ratio);
void setDHTPort(int dht_port); void setDHTPort(int dht_port);
void setPeerProxySettings(const proxy_settings &proxySettings); void setPeerProxySettings(const proxy_settings &proxySettings);

28
src/options_imp.cpp

@ -168,7 +168,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(checkMaxConnecs, SIGNAL(toggled(bool)), this, SLOT(enableMaxConnecsLimit(bool))); connect(checkMaxConnecs, SIGNAL(toggled(bool)), this, SLOT(enableMaxConnecsLimit(bool)));
connect(checkMaxConnecsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableMaxConnecsLimitPerTorrent(bool))); connect(checkMaxConnecsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableMaxConnecsLimitPerTorrent(bool)));
connect(checkMaxUploadsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableMaxUploadsLimitPerTorrent(bool))); connect(checkMaxUploadsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableMaxUploadsLimitPerTorrent(bool)));
connect(checkRatioLimit, SIGNAL(toggled(bool)), this, SLOT(enableShareRatio(bool)));
connect(checkRatioRemove, SIGNAL(toggled(bool)), this, SLOT(enableDeleteRatio(bool))); connect(checkRatioRemove, SIGNAL(toggled(bool)), this, SLOT(enableDeleteRatio(bool)));
connect(comboPeerID, SIGNAL(currentIndexChanged(int)), this, SLOT(enableSpoofingSettings(int))); connect(comboPeerID, SIGNAL(currentIndexChanged(int)), this, SLOT(enableSpoofingSettings(int)));
// Proxy tab // Proxy tab
@ -231,9 +230,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(client_version, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(client_version, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(client_build, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton())); connect(client_build, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(comboEncryption, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); connect(comboEncryption, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
connect(checkRatioLimit, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkRatioRemove, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkRatioRemove, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(spinRatio, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinMaxRatio, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinMaxRatio, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
// Proxy tab // Proxy tab
connect(comboProxyType_http, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); connect(comboProxyType_http, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
@ -471,7 +468,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
Preferences::setPeerID("qB"); Preferences::setPeerID("qB");
} }
settings.setValue(QString::fromUtf8("Encryption"), getEncryptionSetting()); settings.setValue(QString::fromUtf8("Encryption"), getEncryptionSetting());
settings.setValue(QString::fromUtf8("DesiredRatio"), getDesiredRatio());
settings.setValue(QString::fromUtf8("MaxRatio"), getDeleteRatio()); settings.setValue(QString::fromUtf8("MaxRatio"), getDeleteRatio());
// End Bittorrent preferences // End Bittorrent preferences
settings.endGroup(); settings.endGroup();
@ -793,17 +789,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
} }
} }
comboEncryption->setCurrentIndex(Preferences::getEncryptionSetting()); comboEncryption->setCurrentIndex(Preferences::getEncryptionSetting());
floatValue = Preferences::getDesiredRatio(); // Ratio limit
if(floatValue >= 1.) {
// Enable
checkRatioLimit->setChecked(true);
spinRatio->setEnabled(true);
spinRatio->setValue(floatValue);
} else {
// Disable
checkRatioLimit->setChecked(false);
spinRatio->setEnabled(false);
}
floatValue = Preferences::getDeleteRatio(); floatValue = Preferences::getDeleteRatio();
if(floatValue >= 1.) { if(floatValue >= 1.) {
// Enable // Enable
@ -989,14 +975,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
return spinDHTPort->value(); return spinDHTPort->value();
} }
// Return Share ratio
float options_imp::getDesiredRatio() const{
if(checkRatioLimit->isChecked()){
return spinRatio->value();
}
return -1;
}
// Return Share ratio // Return Share ratio
float options_imp::getDeleteRatio() const{ float options_imp::getDeleteRatio() const{
if(checkRatioRemove->isChecked()){ if(checkRatioRemove->isChecked()){
@ -1132,10 +1110,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
applyButton->setEnabled(true); applyButton->setEnabled(true);
} }
void options_imp::enableShareRatio(bool checked){
spinRatio->setEnabled(checked);
}
void options_imp::enableDeleteRatio(bool checked){ void options_imp::enableDeleteRatio(bool checked){
spinMaxRatio->setEnabled(checked); spinMaxRatio->setEnabled(checked);
} }

2
src/options_imp.h

@ -97,7 +97,6 @@ protected:
bool isLSDEnabled() const; bool isLSDEnabled() const;
bool isRSSEnabled() const; bool isRSSEnabled() const;
int getEncryptionSetting() const; int getEncryptionSetting() const;
float getDesiredRatio() const;
float getDeleteRatio() const; float getDeleteRatio() const;
// Proxy options // Proxy options
QString getHTTPProxyIp() const; QString getHTTPProxyIp() const;
@ -137,7 +136,6 @@ protected slots:
void enableMaxConnecsLimit(bool checked); void enableMaxConnecsLimit(bool checked);
void enableMaxConnecsLimitPerTorrent(bool checked); void enableMaxConnecsLimitPerTorrent(bool checked);
void enableMaxUploadsLimitPerTorrent(bool checked); void enableMaxUploadsLimitPerTorrent(bool checked);
void enableShareRatio(bool checked);
void enableDeleteRatio(bool checked); void enableDeleteRatio(bool checked);
void enableSpoofingSettings(int index); void enableSpoofingSettings(int index);
void setStyle(QString style); void setStyle(QString style);

5
src/preferences.h

@ -693,11 +693,6 @@ public:
settings.setValue(QString::fromUtf8("Preferences/Bittorrent/Encryption"), val); 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();
}
static float getDeleteRatio() { static float getDeleteRatio() {
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), -1).toDouble(); return settings.value(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), -1).toDouble();

64
src/ui/options.ui

@ -457,6 +457,9 @@
<property name="text"> <property name="text">
<string>Show splash screen on start up</string> <string>Show splash screen on start up</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -471,6 +474,9 @@
<property name="text"> <property name="text">
<string>Show qBittorrent icon in notification area</string> <string>Show qBittorrent icon in notification area</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -1506,7 +1512,7 @@ QGroupBox {
}</string> }</string>
</property> </property>
<property name="title"> <property name="title">
<string>Schedule alternative speed limits</string> <string>Schedule the use of alternative speed limits</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
@ -1950,60 +1956,6 @@ QGroupBox {
<string>Share ratio settings</string> <string>Share ratio settings</string>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QCheckBox" name="checkRatioLimit">
<property name="text">
<string>Desired ratio:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="spinRatio">
<property name="enabled">
<bool>false</bool>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
</font>
</property>
<property name="alignment">
<set>Qt::AlignHCenter</set>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>1.000000000000000</double>
</property>
<property name="maximum">
<double>10.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer>
<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>
</item>
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<item> <item>
@ -2895,8 +2847,6 @@ QGroupBox {
<tabstop>checkNATPMP</tabstop> <tabstop>checkNATPMP</tabstop>
<tabstop>checkLSD</tabstop> <tabstop>checkLSD</tabstop>
<tabstop>comboEncryption</tabstop> <tabstop>comboEncryption</tabstop>
<tabstop>checkRatioLimit</tabstop>
<tabstop>spinRatio</tabstop>
<tabstop>checkRatioRemove</tabstop> <tabstop>checkRatioRemove</tabstop>
<tabstop>spinMaxRatio</tabstop> <tabstop>spinMaxRatio</tabstop>
<tabstop>spinWebUiPort</tabstop> <tabstop>spinWebUiPort</tabstop>

Loading…
Cancel
Save