From da599da36d6426e7fdb0695ab625b1d4721494dc Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Mon, 21 Jun 2010 21:39:29 +0000 Subject: [PATCH] Still simplifying program options --- src/bittorrent.cpp | 22 ---------------- src/bittorrent.h | 1 - src/options_imp.cpp | 28 +------------------- src/options_imp.h | 2 -- src/preferences.h | 5 ---- src/ui/options.ui | 64 +++++---------------------------------------- 6 files changed, 8 insertions(+), 114 deletions(-) diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index da49eef11..3c1a2dc54 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -521,8 +521,6 @@ void Bittorrent::configureSession() { addConsoleMessage(tr("Encryption support [OFF]"), QString::fromUtf8("blue")); } applyEncryptionSettings(encryptionSettings); - // * Desired ratio - setGlobalRatio(Preferences::getDesiredRatio()); // * Maximum ratio setDeleteRatio(Preferences::getDeleteRatio()); // Ip Filter @@ -1763,26 +1761,6 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { 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 handles = s->get_torrents(); - std::vector::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 // be automatically deleted void Bittorrent::setDeleteRatio(float ratio) { diff --git a/src/bittorrent.h b/src/bittorrent.h index 12203126e..d9108dd93 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -153,7 +153,6 @@ public slots: void setMaxUploadsPerTorrent(int max); void setDownloadRateLimit(long rate); void setUploadRateLimit(long rate); - void setGlobalRatio(float ratio); void setDeleteRatio(float ratio); void setDHTPort(int dht_port); void setPeerProxySettings(const proxy_settings &proxySettings); diff --git a/src/options_imp.cpp b/src/options_imp.cpp index bbddac2fa..c69e22cac 100644 --- a/src/options_imp.cpp +++ b/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(checkMaxConnecsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableMaxConnecsLimitPerTorrent(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(comboPeerID, SIGNAL(currentIndexChanged(int)), this, SLOT(enableSpoofingSettings(int))); // 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_build, SIGNAL(textChanged(QString)), 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(spinRatio, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinMaxRatio, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); // Proxy tab connect(comboProxyType_http, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); @@ -471,7 +468,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ Preferences::setPeerID("qB"); } settings.setValue(QString::fromUtf8("Encryption"), getEncryptionSetting()); - settings.setValue(QString::fromUtf8("DesiredRatio"), getDesiredRatio()); settings.setValue(QString::fromUtf8("MaxRatio"), getDeleteRatio()); // End Bittorrent preferences settings.endGroup(); @@ -793,17 +789,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ } } comboEncryption->setCurrentIndex(Preferences::getEncryptionSetting()); - floatValue = Preferences::getDesiredRatio(); - if(floatValue >= 1.) { - // Enable - checkRatioLimit->setChecked(true); - spinRatio->setEnabled(true); - spinRatio->setValue(floatValue); - } else { - // Disable - checkRatioLimit->setChecked(false); - spinRatio->setEnabled(false); - } + // Ratio limit floatValue = Preferences::getDeleteRatio(); if(floatValue >= 1.) { // Enable @@ -989,14 +975,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ return spinDHTPort->value(); } - // Return Share ratio - float options_imp::getDesiredRatio() const{ - if(checkRatioLimit->isChecked()){ - return spinRatio->value(); - } - return -1; - } - // Return Share ratio float options_imp::getDeleteRatio() const{ if(checkRatioRemove->isChecked()){ @@ -1132,10 +1110,6 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ applyButton->setEnabled(true); } - void options_imp::enableShareRatio(bool checked){ - spinRatio->setEnabled(checked); - } - void options_imp::enableDeleteRatio(bool checked){ spinMaxRatio->setEnabled(checked); } diff --git a/src/options_imp.h b/src/options_imp.h index 4301e0d85..37da85c7b 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -97,7 +97,6 @@ protected: bool isLSDEnabled() const; bool isRSSEnabled() const; int getEncryptionSetting() const; - float getDesiredRatio() const; float getDeleteRatio() const; // Proxy options QString getHTTPProxyIp() const; @@ -137,7 +136,6 @@ protected slots: void enableMaxConnecsLimit(bool checked); void enableMaxConnecsLimitPerTorrent(bool checked); void enableMaxUploadsLimitPerTorrent(bool checked); - void enableShareRatio(bool checked); void enableDeleteRatio(bool checked); void enableSpoofingSettings(int index); void setStyle(QString style); diff --git a/src/preferences.h b/src/preferences.h index 38cfde52f..78f9100b6 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -693,11 +693,6 @@ public: 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() { QSettings settings("qBittorrent", "qBittorrent"); return settings.value(QString::fromUtf8("Preferences/Bittorrent/MaxRatio"), -1).toDouble(); diff --git a/src/ui/options.ui b/src/ui/options.ui index 0d37bd6e3..96f5d31e8 100644 --- a/src/ui/options.ui +++ b/src/ui/options.ui @@ -457,6 +457,9 @@ Show splash screen on start up + + true + @@ -471,6 +474,9 @@ Show qBittorrent icon in notification area + + true + @@ -1506,7 +1512,7 @@ QGroupBox { } - Schedule alternative speed limits + Schedule the use of alternative speed limits true @@ -1950,60 +1956,6 @@ QGroupBox { Share ratio settings - - - - - - Desired ratio: - - - - - - - false - - - - 8 - - - - Qt::AlignHCenter - - - 1 - - - 1.000000000000000 - - - 10.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - @@ -2895,8 +2847,6 @@ QGroupBox { checkNATPMP checkLSD comboEncryption - checkRatioLimit - spinRatio checkRatioRemove spinMaxRatio spinWebUiPort