From 5ffcf5a9dce35cdab37a493626b384e38c8e5740 Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 17 Nov 2009 13:11:32 +0000 Subject: [PATCH] - Fixed per torrent speed limiting - A lot of cleanup in speed limiting dialog --- src/GUI.cpp | 24 ++++- src/TransferListWidget.cpp | 67 +++++++++++-- src/allocationDlg.h | 188 ------------------------------------- src/bandwidth_limit.ui | 138 ++++++++++++++------------- src/bittorrent.cpp | 24 +++-- src/bittorrent.h | 2 - src/peeraddition.h | 15 +-- src/preferences.h | 12 +++ src/speedlimitdlg.h | 96 +++++++++++++++++++ src/src.pro | 2 +- 10 files changed, 275 insertions(+), 293 deletions(-) delete mode 100644 src/allocationDlg.h create mode 100644 src/speedlimitdlg.h diff --git a/src/GUI.cpp b/src/GUI.cpp index 53ded82a7..9abce1c44 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -58,7 +58,7 @@ #include "about_imp.h" #include "trackerLogin.h" #include "options_imp.h" -#include "allocationDlg.h" +#include "speedlimitdlg.h" #include "preferences.h" #include #include "console_imp.h" @@ -482,7 +482,16 @@ void GUI::handleDownloadFromUrlFailure(QString url, QString reason) const{ void GUI::on_actionSet_global_upload_limit_triggered() { qDebug("actionSet_global_upload_limit_triggered"); - new BandwidthAllocationDialog(this, true, BTSession, QStringList()); + bool ok; + long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), BTSession->getSession()->upload_rate_limit()); + if(ok) { + qDebug("Setting global upload rate limit to %.1fKb/s", new_limit/1024.); + BTSession->getSession()->set_upload_rate_limit(new_limit); + if(new_limit <= 0) + Preferences::setGlobalUploadLimit(-1); + else + Preferences::setGlobalUploadLimit(new_limit/1024.); + } } void GUI::on_actionShow_console_triggered() { @@ -491,7 +500,16 @@ void GUI::on_actionShow_console_triggered() { void GUI::on_actionSet_global_download_limit_triggered() { qDebug("actionSet_global_download_limit_triggered"); - new BandwidthAllocationDialog(this, false, BTSession, QStringList()); + bool ok; + long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), BTSession->getSession()->download_rate_limit()); + if(ok) { + qDebug("Setting global download rate limit to %.1fKb/s", new_limit/1024.); + BTSession->getSession()->set_download_rate_limit(new_limit); + if(new_limit <= 0) + Preferences::setGlobalDownloadLimit(-1); + else + Preferences::setGlobalDownloadLimit(new_limit/1024.); + } } // Necessary if we want to close the window diff --git a/src/TransferListWidget.cpp b/src/TransferListWidget.cpp index 6783406f1..9c186d0fc 100644 --- a/src/TransferListWidget.cpp +++ b/src/TransferListWidget.cpp @@ -33,7 +33,7 @@ #include "bittorrent.h" #include "torrentPersistentData.h" #include "previewSelect.h" -#include "allocationDlg.h" +#include "speedlimitdlg.h" #include "options_imp.h" #include #include @@ -559,26 +559,75 @@ void TransferListWidget::previewSelectedTorrents() { void TransferListWidget::setDlLimitSelectedTorrents() { QModelIndexList selectedIndexes = selectionModel()->selectedRows(); QStringList hashes; + QList selected_torrents; + bool first = true; + bool all_same_limit = true; foreach(const QModelIndex &index, selectedIndexes) { // Get the file hash QString hash = getHashFromRow(proxyModel->mapToSource(index).row()); QTorrentHandle h = BTSession->getTorrentHandle(hash); - if(h.is_valid() && !h.is_seed()) - hashes << hash; + if(h.is_valid() && !h.is_seed()) { + selected_torrents << h; + // Determine current limit for selected torrents + if(first) { + first = false; + } else { + if(all_same_limit && h.download_limit() != selected_torrents.first().download_limit()) + all_same_limit = false; + } + } + } + if(selected_torrents.empty()) return; + + bool ok=false; + int default_limit = -1; + if(all_same_limit) + default_limit = selected_torrents.first().download_limit(); + long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Torrent Download Speed Limiting"), default_limit); + if(ok) { + foreach(QTorrentHandle h, selected_torrents) { + qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (long)(new_limit/1024.), h.hash().toLocal8Bit().data()); + h.set_download_limit(new_limit); + TorrentPersistentData::saveSpeedLimits(h); + } } - Q_ASSERT(hashes.size() > 0); - new BandwidthAllocationDialog(this, false, BTSession, hashes); } void TransferListWidget::setUpLimitSelectedTorrents() { - QModelIndexList selectedIndexes = selectionModel()->selectedRows(); + QModelIndexList selectedIndexes = selectionModel()->selectedRows(); QStringList hashes; + QList selected_torrents; + bool first = true; + bool all_same_limit = true; foreach(const QModelIndex &index, selectedIndexes) { // Get the file hash - hashes << getHashFromRow(proxyModel->mapToSource(index).row()); + QString hash = getHashFromRow(proxyModel->mapToSource(index).row()); + QTorrentHandle h = BTSession->getTorrentHandle(hash); + if(h.is_valid() && !h.is_seed()) { + selected_torrents << h; + // Determine current limit for selected torrents + if(first) { + first = false; + } else { + if(all_same_limit && h.upload_limit() != selected_torrents.first().upload_limit()) + all_same_limit = false; + } + } + } + if(selected_torrents.empty()) return; + + bool ok=false; + int default_limit = -1; + if(all_same_limit) + default_limit = selected_torrents.first().upload_limit(); + long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Torrent Upload Speed Limiting"), default_limit); + if(ok) { + foreach(QTorrentHandle h, selected_torrents) { + qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (long)(new_limit/1024.), h.hash().toLocal8Bit().data()); + h.set_upload_limit(new_limit); + TorrentPersistentData::saveSpeedLimits(h); + } } - Q_ASSERT(hashes.size() > 0); - new BandwidthAllocationDialog(this, true, BTSession, hashes); } void TransferListWidget::recheckSelectedTorrents() { diff --git a/src/allocationDlg.h b/src/allocationDlg.h deleted file mode 100644 index 9609c3fa7..000000000 --- a/src/allocationDlg.h +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Bittorrent Client using Qt4 and libtorrent. - * Copyright (C) 2006 Christophe Dumez - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * In addition, as a special exception, the copyright holders give permission to - * link this program with the OpenSSL project's "OpenSSL" library (or with - * modified versions of it that use the same license as the "OpenSSL" library), - * and distribute the linked executables. You must obey the GNU General Public - * License in all respects for all of the code used other than "OpenSSL". If you - * modify file(s), you may extend this exception to your version of the file(s), - * but you are not obligated to do so. If you do not wish to do so, delete this - * exception statement from your version. - * - * Contact : chris@qbittorrent.org - */ - -#ifndef BANDWIDTH_ALLOCATION_H -#define BANDWIDTH_ALLOCATION_H - -#include -#include -#include -#include "ui_bandwidth_limit.h" -#include "misc.h" -#include "bittorrent.h" - -using namespace libtorrent; - -class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { - Q_OBJECT - - public: - BandwidthAllocationDialog(QWidget *parent, bool uploadMode, bittorrent *BTSession, QStringList hashes): QDialog(parent), uploadMode(uploadMode), hashes(hashes){ - setupUi(this); - setAttribute(Qt::WA_DeleteOnClose); - qDebug("Bandwidth allocation dialog creation"); - this->BTSession = BTSession; - if(hashes.size() == 0) - global = true; - else - global = false; - if(uploadMode) - lblTitle->setText(tr("Upload limit:")); - else - lblTitle->setText(tr("Download limit:")); - connect(bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateBandwidthLabel(int))); - if(!global){ - unsigned int nbTorrents = hashes.size(); - if(!nbTorrents) close(); - int val = 0; - int max = -1; - if(nbTorrents == 1){ - QTorrentHandle h = BTSession->getTorrentHandle(hashes.at(0)); - if(uploadMode){ - if(h.upload_limit() > 0) - val = (int)(h.upload_limit() / 1024.); - if(BTSession->getSession()->upload_rate_limit() > 0) - max = (int)(BTSession->getSession()->upload_rate_limit() / 1024.); - }else{ - if(h.download_limit() > 0) - val = (int)(h.download_limit() / 1024.); - if(BTSession->getSession()->download_rate_limit() > 0){ - qDebug("there is a global download rate limit at: %d kb/s", (int)(BTSession->getSession()->download_rate_limit() / 1024.)); - max = (int)(BTSession->getSession()->download_rate_limit() / 1024.); - } - } - if(max != -1) - bandwidthSlider->setMaximum(max); - qDebug("Bandwidth limit: %d", val); - if(val > bandwidthSlider->maximum()) - val = bandwidthSlider->maximum(); - else if(val < bandwidthSlider->minimum()) - val = 0; - bandwidthSlider->setValue(val); - if(val == 0) { - limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)")); - kb_lbl->setText(QString::fromUtf8("")); - } else { - limit_lbl->setText(misc::toQString(val)); - } - }else{ - qDebug("More than one torrent selected, no initilization"); - bandwidthSlider->setValue(0); - limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)")); - kb_lbl->setText(QString::fromUtf8("")); - } - }else{ - // Global limit - int val = 0; - session *s = BTSession->getSession(); - if(uploadMode){ - if(s->upload_rate_limit() > 0) - val = (int)(s->upload_rate_limit()/1024.); - }else{ - if(s->download_rate_limit() > 0) - val = (int)(s->download_rate_limit()/1024.); - } - if(val == 0){ - bandwidthSlider->setValue(0); - limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)")); - kb_lbl->setText(QString::fromUtf8("")); - }else{ - bandwidthSlider->setValue(val); - } - } - connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth())); - show(); - } - - ~BandwidthAllocationDialog(){ - qDebug("Deleting bandwidth allocation dialog"); - } - - protected slots: - void updateBandwidthLabel(int val){ - if(val == 0){ - limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)")); - kb_lbl->setText(QString::fromUtf8("")); - }else{ - limit_lbl->setText(misc::toQString(val)); - kb_lbl->setText(tr("KiB/s")); - } - } - - void setBandwidth(){ - qDebug("setBandwidth called"); - int val = bandwidthSlider->value(); - if(!global){ - QString hash; - if(uploadMode) { - foreach(hash, hashes) { - if(!val) - BTSession->setUploadLimit(hash, -1); - else - BTSession->setUploadLimit(hash, val*1024); - qDebug("Setting upload limit"); - } - } else { - foreach(hash, hashes) { - if(!val) - BTSession->setDownloadLimit(hash, -1); - else - BTSession->setDownloadLimit(hash, val*1024); - qDebug("Setting download limit"); - } - } - }else{ - QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); - session *s = BTSession->getSession(); - if(uploadMode){ - if(!val) - s->set_upload_rate_limit(-1); - else - s->set_upload_rate_limit(val*1024); - settings.setValue(QString::fromUtf8("Preferences/Connection/GlobalUPLimit"), val); - }else{ - if(!val) - s->set_download_rate_limit(-1); - else - s->set_download_rate_limit(val*1024); - settings.setValue(QString::fromUtf8("Preferences/Connection/GlobalDLLimit"), val); - } - } - close(); - } - - private: - bool uploadMode; - bool global; - bittorrent *BTSession; - QStringList hashes; -}; - -#endif diff --git a/src/bandwidth_limit.ui b/src/bandwidth_limit.ui index 62ea9c192..d41503cc9 100644 --- a/src/bandwidth_limit.ui +++ b/src/bandwidth_limit.ui @@ -1,95 +1,77 @@ - + + bandwidth_dlg - - + + 0 0 - 222 - 129 + 338 + 83 - - Bandwidth allocation + + Bandwidth allocation - - - 9 - - - 6 - + - - - 0 - - - 6 - + - - - + + + 0 - - - - - - + + 1000 - - - - - - KiB/s + + 0 + + + Qt::Horizontal - - - Qt::Horizontal + + + 6 - - - 40 - 20 - + + 0 - + + + + + + + + + + + + + + + - - - 0 - - - 1000 - - - 0 - - - Qt::Horizontal - - - - - - + + Qt::Horizontal - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + bandwidthSlider + buttonBox + kb_lbl @@ -99,13 +81,29 @@ bandwidth_dlg reject() - - 212 - 83 + + 221 + 73 - + 221 - 98 + 82 + + + + + buttonBox + accepted() + bandwidth_dlg + accept() + + + 277 + 59 + + + 343 + 80 diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index e1f54a3b6..df74ecca7 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -59,7 +59,7 @@ enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4}; // Main constructor -bittorrent::bittorrent() : DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), ratio_limit(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), queueingEnabled(false), geoipDBLoaded(false) { +bittorrent::bittorrent() : DHTEnabled(false), preAllocateAll(false), addInPause(false), ratio_limit(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), queueingEnabled(false), geoipDBLoaded(false) { resolve_countries = false; // To avoid some exceptions fs::path::default_name_check(fs::no_check); @@ -692,9 +692,14 @@ QTorrentHandle bittorrent::addMagnetUri(QString magnet_uri, bool resumed) { } Q_ASSERT(h.hash() == hash); // Connections limit per torrent - h.set_max_connections(maxConnecsPerTorrent); + h.set_max_connections(Preferences::getMaxConnecsPerTorrent()); // Uploads limit per torrent - h.set_max_uploads(maxUploadsPerTorrent); + h.set_max_uploads(Preferences::getMaxUploadsPerTorrent()); + // Speed limits + if(TorrentPersistentData::isKnownTorrent(h.hash())) { + h.set_download_limit(TorrentPersistentData::getDownloadLimit(h.hash())); + h.set_upload_limit(TorrentPersistentData::getUploadLimit(h.hash())); + } // Resolve countries h.resolve_countries(resolve_countries); // Load filtered files @@ -866,9 +871,14 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr return h; } // Connections limit per torrent - h.set_max_connections(maxConnecsPerTorrent); + h.set_max_connections(Preferences::getMaxConnecsPerTorrent()); // Uploads limit per torrent - h.set_max_uploads(maxUploadsPerTorrent); + h.set_max_uploads(Preferences::getMaxUploadsPerTorrent()); + // Speed limits + if(TorrentPersistentData::isKnownTorrent(h.hash())) { + h.set_download_limit(TorrentPersistentData::getDownloadLimit(h.hash())); + h.set_upload_limit(TorrentPersistentData::getUploadLimit(h.hash())); + } // Resolve countries qDebug("AddTorrent: Resolve_countries: %d", (int)resolve_countries); h.resolve_countries(resolve_countries); @@ -951,7 +961,6 @@ void bittorrent::setMaxConnections(int maxConnec) { } void bittorrent::setMaxConnectionsPerTorrent(int max) { - maxConnecsPerTorrent = max; // Apply this to all session torrents std::vector handles = s->get_torrents(); unsigned int nbHandles = handles.size(); @@ -962,11 +971,11 @@ void bittorrent::setMaxConnectionsPerTorrent(int max) { continue; } h.set_max_connections(max); + TorrentPersistentData::saveSpeedLimits(h); } } void bittorrent::setMaxUploadsPerTorrent(int max) { - maxUploadsPerTorrent = max; // Apply this to all session torrents std::vector handles = s->get_torrents(); unsigned int nbHandles = handles.size(); @@ -977,6 +986,7 @@ void bittorrent::setMaxUploadsPerTorrent(int max) { continue; } h.set_max_uploads(max); + TorrentPersistentData::saveSpeedLimits(h); } } diff --git a/src/bittorrent.h b/src/bittorrent.h index e33b9ccd7..a2722e9f7 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -66,8 +66,6 @@ class bittorrent : public QObject { QStringList peerBanMessages; bool preAllocateAll; bool addInPause; - int maxConnecsPerTorrent; - int maxUploadsPerTorrent; float ratio_limit; bool UPnPEnabled; bool NATPMPEnabled; diff --git a/src/peeraddition.h b/src/peeraddition.h index 927585b5e..52685a89e 100644 --- a/src/peeraddition.h +++ b/src/peeraddition.h @@ -40,11 +40,8 @@ class PeerAdditionDlg: public QDialog, private Ui::addPeerDialog { Q_OBJECT -private: - bool valid; - public: - PeerAdditionDlg(QWidget *parent=0): QDialog(parent), valid(false) { + PeerAdditionDlg(QWidget *parent=0): QDialog(parent) { setupUi(this); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); connect(buttonBox, SIGNAL(accepted()), this, SLOT(validateInput())); @@ -60,15 +57,10 @@ public: return spinPort->value(); } - bool isValid() const { - return valid; - } - static boost::asio::ip::tcp::endpoint askForPeerEndpoint() { boost::asio::ip::tcp::endpoint ep; PeerAdditionDlg dlg; - dlg.exec(); - if(dlg.isValid()) { + if(dlg.exec() == QDialog::Accepted) { const QRegExp is_ipv6(QString::fromUtf8("[0-9a-f]{4}(:[0-9a-f]{4}){7}"), Qt::CaseInsensitive, QRegExp::RegExp); const QRegExp is_ipv4(QString::fromUtf8("(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))(\\.(([0-1]?[0-9]?[0-9])|(2[0-4][0-9])|(25[0-5]))){3}"), Qt::CaseInsensitive, QRegExp::RegExp); QString IP = dlg.getIP(); @@ -91,18 +83,15 @@ protected slots: QString IP = getIP(); if(is_ipv4.exactMatch(IP)) { qDebug("Detected IPv4 address: %s", IP.toLocal8Bit().data()); - valid = true; accept(); } else { if(is_ipv6.exactMatch(IP)) { qDebug("Detected IPv6 address: %s", IP.toLocal8Bit().data()); - valid = true; accept(); } else { QMessageBox::warning(this, tr("Invalid IP"), tr("The IP you provided is invalid."), QMessageBox::Ok); - } } } diff --git a/src/preferences.h b/src/preferences.h index 95264248e..6bf7df93c 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -182,11 +182,23 @@ public: return settings.value(QString::fromUtf8("Preferences/Connection/GlobalDLLimit"), -1).toInt(); } + static void setGlobalDownloadLimit(int limit) { + QSettings settings("qBittorrent", "qBittorrent"); + if(limit == 0) limit = -1; + settings.setValue("Preferences/Connection/GlobalDLLimit", limit); + } + static int getGlobalUploadLimit() { QSettings settings("qBittorrent", "qBittorrent"); return settings.value(QString::fromUtf8("Preferences/Connection/GlobalUPLimit"), -1).toInt(); } + static void setGlobalUploadLimit(int limit) { + QSettings settings("qBittorrent", "qBittorrent"); + if(limit == 0) limit = -1; + settings.setValue("Preferences/Connection/GlobalUPLimit", limit); + } + static bool resolvePeerCountries() { QSettings settings("qBittorrent", "qBittorrent"); return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), false).toBool(); diff --git a/src/speedlimitdlg.h b/src/speedlimitdlg.h new file mode 100644 index 000000000..a6a18dd9c --- /dev/null +++ b/src/speedlimitdlg.h @@ -0,0 +1,96 @@ +/* + * Bittorrent Client using Qt4 and libtorrent. + * Copyright (C) 2006 Christophe Dumez + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * In addition, as a special exception, the copyright holders give permission to + * link this program with the OpenSSL project's "OpenSSL" library (or with + * modified versions of it that use the same license as the "OpenSSL" library), + * and distribute the linked executables. You must obey the GNU General Public + * License in all respects for all of the code used other than "OpenSSL". If you + * modify file(s), you may extend this exception to your version of the file(s), + * but you are not obligated to do so. If you do not wish to do so, delete this + * exception statement from your version. + * + * Contact : chris@qbittorrent.org + */ + +#ifndef BANDWIDTH_ALLOCATION_H +#define BANDWIDTH_ALLOCATION_H + +#include +#include +#include +#include "ui_bandwidth_limit.h" +#include "misc.h" +#include "bittorrent.h" + +using namespace libtorrent; + +class SpeedLimitDialog : public QDialog, private Ui_bandwidth_dlg { + Q_OBJECT + + public: + SpeedLimitDialog(QWidget *parent=0): QDialog(parent) { + setupUi(this); + qDebug("Bandwidth allocation dialog creation"); + // Connect to slots + connect(bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateBandwidthLabel(int))); + } + + ~SpeedLimitDialog(){ + qDebug("Deleting bandwidth allocation dialog"); + } + + // -2: if cancel + static long askSpeedLimit(bool *ok, QString title, long default_value) { + SpeedLimitDialog dlg; + dlg.setWindowTitle(title); + dlg.setDefaultValue(default_value/1024.); + if(dlg.exec() == QDialog::Accepted) { + *ok = true; + return dlg.getSpeedLimit()*1024; + } else { + *ok = false; + return -2; + } + } + + protected slots: + void updateBandwidthLabel(int val){ + if(val <= 0){ + limit_lbl->setText(QString::fromUtf8("∞")); + kb_lbl->setText(QString::fromUtf8("")); + }else{ + limit_lbl->setText(misc::toQString(val)); + kb_lbl->setText(tr("KiB/s")); + } + } + + long getSpeedLimit() const { + long val = bandwidthSlider->value(); + if(val > 0) + return val; + return -1; + } + + void setDefaultValue(long val) const { + if(val < 0) val = 0; + bandwidthSlider->setValue(val); + } +}; + +#endif diff --git a/src/src.pro b/src/src.pro index 4cc5210f0..597f5c3a2 100644 --- a/src/src.pro +++ b/src/src.pro @@ -157,7 +157,7 @@ HEADERS += GUI.h \ searchEngine.h \ rss.h \ rss_imp.h \ - allocationDlg.h \ + speedlimitdlg.h \ qtorrenthandle.h \ engineSelectDlg.h \ pluginSource.h \