diff --git a/Changelog b/Changelog index 9e010e195..fbed539cb 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +* Unreleased - Christophe Dumez - v2.2.0 + - FEATURE: User can set alternative speed limits for fast toggling + * Mon Jan 18 2010 - Christophe Dumez - v2.1.0 - FEATURE: Graphical User Interface can be disabled at compilation time (headless running) - FEATURE: Torrents can be labeled/categorized diff --git a/src/GUI.cpp b/src/GUI.cpp index da0430f66..87cec4dd5 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -180,6 +180,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis createKeyboardShortcuts(); // Create status bar status_bar = new StatusBar(QMainWindow::statusBar(), BTSession); + connect(actionUse_alternative_speed_limits, SIGNAL(triggered()), status_bar, SLOT(toggleAlternativeSpeeds())); + connect(status_bar, SIGNAL(alternativeSpeedsToggled(bool)), this, SLOT(updateAltSpeedsBtn(bool))); show(); @@ -879,6 +881,16 @@ void GUI::createSystrayDelayed() { } } +void GUI::updateAltSpeedsBtn(bool alternative) { + if(alternative) { + actionUse_alternative_speed_limits->setIcon(QIcon(":/Icons/slow.png")); + actionUse_alternative_speed_limits->setText(tr("Use normal speed limits")); + } else { + actionUse_alternative_speed_limits->setIcon(QIcon(":/Icons/slow_off.png")); + actionUse_alternative_speed_limits->setText(tr("Use alternative speed limits")); + } +} + void GUI::createTrayIcon() { // Tray icon #ifdef Q_WS_WIN @@ -892,6 +904,8 @@ void GUI::createTrayIcon() { myTrayIconMenu->addAction(actionOpen); myTrayIconMenu->addAction(actionDownload_from_URL); myTrayIconMenu->addSeparator(); + updateAltSpeedsBtn(Preferences::isAltBandwidthEnabled()); + myTrayIconMenu->addAction(actionUse_alternative_speed_limits); myTrayIconMenu->addAction(actionSet_global_download_limit); myTrayIconMenu->addAction(actionSet_global_upload_limit); myTrayIconMenu->addSeparator(); diff --git a/src/GUI.h b/src/GUI.h index 0bf1812c8..0843a0a50 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -143,6 +143,7 @@ public slots: void setTabText(int index, QString text) const; void showNotificationBaloon(QString title, QString msg) const; void downloadFromURLList(const QStringList& urls); + void updateAltSpeedsBtn(bool alternative); protected: void closeEvent(QCloseEvent *); diff --git a/src/Icons/oxygen/chronometer.png b/src/Icons/oxygen/chronometer.png new file mode 100644 index 000000000..00386b705 Binary files /dev/null and b/src/Icons/oxygen/chronometer.png differ diff --git a/src/Icons/slow.png b/src/Icons/slow.png new file mode 100644 index 000000000..2098177e1 Binary files /dev/null and b/src/Icons/slow.png differ diff --git a/src/Icons/slow48.png b/src/Icons/slow48.png new file mode 100644 index 000000000..92f079bdb Binary files /dev/null and b/src/Icons/slow48.png differ diff --git a/src/Icons/slow_off.png b/src/Icons/slow_off.png new file mode 100644 index 000000000..4ed909be3 Binary files /dev/null and b/src/Icons/slow_off.png differ diff --git a/src/icons.qrc b/src/icons.qrc index c4ebd12bf..e875a45e8 100644 --- a/src/icons.qrc +++ b/src/icons.qrc @@ -1,13 +1,16 @@ + Icons/slow48.png Icons/rss32.png Icons/sphere2.png Icons/downarrow.png Icons/url.png Icons/locale.png Icons/loading.png + Icons/slow.png Icons/magnet.png Icons/sphere.png + Icons/slow_off.png Icons/uparrow.png Icons/rss16.png Icons/skin/checkingUP.png @@ -154,6 +157,7 @@ Icons/oxygen/unsubscribe16.png Icons/oxygen/subscribe.png Icons/oxygen/edit-copy.png + Icons/oxygen/chronometer.png Icons/oxygen/bt_settings.png Icons/oxygen/document-new.png Icons/oxygen/preferences-desktop.png diff --git a/src/options_imp.cpp b/src/options_imp.cpp index 9322860b5..77b5e31e4 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -136,6 +136,11 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/south_korea.png"))), QString::fromUtf8("한글")); locales << "ko_KR"; + // Load week days (scheduler) + for(uint i=1; i<=7; ++i) { + schedule_days->addItem(QDate::longDayName(i, QDate::StandaloneFormat)); + } + // Load options loadOptions(); // Disable systray integration if it is not supported by the system @@ -154,6 +159,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ // Connection tab connect(checkUploadLimit, SIGNAL(toggled(bool)), this, SLOT(enableUploadLimit(bool))); connect(checkDownloadLimit, SIGNAL(toggled(bool)), this, SLOT(enableDownloadLimit(bool))); + connect(check_schedule, SIGNAL(toggled(bool)), this, SLOT(enableSchedulerFields(bool))); // Bittorrent tab connect(checkMaxConnecs, SIGNAL(toggled(bool)), this, SLOT(enableMaxConnecsLimit(bool))); connect(checkMaxConnecsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableMaxConnecsLimitPerTorrent(bool))); @@ -210,6 +216,10 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ connect(spinDownloadLimit, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(checkResolveCountries, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkResolveHosts, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); + connect(check_schedule, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); + connect(schedule_from, SIGNAL(timeChanged(QTime)), this, SLOT(enableApplyButton())); + connect(schedule_to, SIGNAL(timeChanged(QTime)), this, SLOT(enableApplyButton())); + connect(schedule_days, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton())); // Bittorrent tab connect(checkMaxConnecs, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkMaxConnecsPerTorrent, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); @@ -395,6 +405,12 @@ void options_imp::saveOptions(){ settings.setValue(QString::fromUtf8("NAT-PMP"), isNATPMPEnabled()); settings.setValue(QString::fromUtf8("GlobalDLLimit"), getGlobalBandwidthLimits().first); settings.setValue(QString::fromUtf8("GlobalUPLimit"), getGlobalBandwidthLimits().second); + Preferences::setAltGlobalDownloadLimit(spinDownloadLimitAlt->value()); + Preferences::setAltGlobalUploadLimit(spinUploadLimitAlt->value()); + Preferences::setSchedulerEnabled(check_schedule->isChecked()); + Preferences::setSchedulerStartTime(schedule_from->time()); + Preferences::setSchedulerEndTime(schedule_to->time()); + Preferences::setSchedulerDays((scheduler_days)schedule_days->currentIndex()); settings.setValue("ResolvePeerCountries", checkResolveCountries->isChecked()); settings.setValue("ResolvePeerHostNames", checkResolveHosts->isChecked()); settings.setValue(QString::fromUtf8("ProxyType"), getPeerProxyType()); @@ -646,6 +662,14 @@ void options_imp::loadOptions(){ checkUploadLimit->setChecked(false); spinUploadLimit->setEnabled(false); } + spinUploadLimitAlt->setValue(Preferences::getAltGlobalUploadLimit()); + spinDownloadLimitAlt->setValue(Preferences::getAltGlobalDownloadLimit()); + // Scheduler + check_schedule->setChecked(Preferences::isSchedulerEnabled()); + enableSchedulerFields(check_schedule->isChecked()); + schedule_from->setTime(Preferences::getSchedulerStartTime()); + schedule_to->setTime(Preferences::getSchedulerEndTime()); + schedule_days->setCurrentIndex((int)Preferences::getSchedulerDays()); // Peer connections checkResolveCountries->setChecked(Preferences::resolvePeerCountries()); checkResolveHosts->setChecked(Preferences::resolvePeerHostNames()); @@ -1095,38 +1119,27 @@ bool options_imp::useAdditionDialog() const{ return checkAdditionDialog->isChecked(); } +void options_imp::enableSchedulerFields(bool checked) { + schedule_from->setEnabled(checked); + schedule_to->setEnabled(checked); + schedule_days->setEnabled(checked); +} + void options_imp::enableMaxConnecsLimit(bool checked){ - if(checked) { - spinMaxConnec->setEnabled(true); - }else{ - spinMaxConnec->setEnabled(false); - } + spinMaxConnec->setEnabled(checked); } void options_imp::enableQueueingSystem(bool checked) { - if(checked) { - spinMaxActiveDownloads->setEnabled(true); - spinMaxActiveUploads->setEnabled(true); - label_max_active_dl->setEnabled(true); - label_max_active_up->setEnabled(true); - maxActiveTorrents_lbl->setEnabled(true); - spinMaxActiveTorrents->setEnabled(true); - }else{ - spinMaxActiveDownloads->setEnabled(false); - spinMaxActiveUploads->setEnabled(false); - label_max_active_dl->setEnabled(false); - label_max_active_up->setEnabled(false); - maxActiveTorrents_lbl->setEnabled(false); - spinMaxActiveTorrents->setEnabled(false); - } + spinMaxActiveDownloads->setEnabled(checked); + spinMaxActiveUploads->setEnabled(checked); + label_max_active_dl->setEnabled(checked); + label_max_active_up->setEnabled(checked); + maxActiveTorrents_lbl->setEnabled(checked); + spinMaxActiveTorrents->setEnabled(checked); } void options_imp::enableMaxConnecsLimitPerTorrent(bool checked){ - if(checked) { - spinMaxConnecPerTorrent->setEnabled(true); - }else{ - spinMaxConnecPerTorrent->setEnabled(false); - } + spinMaxConnecPerTorrent->setEnabled(checked); } void options_imp::enableSystrayOptions() { @@ -1158,55 +1171,30 @@ void options_imp::enableMaxUploadsLimitPerTorrent(bool checked){ } void options_imp::enableFilter(bool checked){ - if(checked){ - lblFilterPath->setEnabled(true); - textFilterPath->setEnabled(true); - browseFilterButton->setEnabled(true); - }else{ - lblFilterPath->setEnabled(false); - textFilterPath->setEnabled(false); - browseFilterButton->setEnabled(false); - } + lblFilterPath->setEnabled(checked); + textFilterPath->setEnabled(checked); + browseFilterButton->setEnabled(checked); } void options_imp::enableRSS(bool checked) { - if(checked){ - groupRSSSettings->setEnabled(true); - }else{ - groupRSSSettings->setEnabled(false); - } + groupRSSSettings->setEnabled(checked); } void options_imp::enableUploadLimit(bool checked){ - if(checked){ - spinUploadLimit->setEnabled(true); - }else{ - spinUploadLimit->setEnabled(false); - } + spinUploadLimit->setEnabled(checked); } void options_imp::enableApplyButton(){ - if(!applyButton->isEnabled()){ - applyButton->setEnabled(true); - } + applyButton->setEnabled(true); } void options_imp::enableShareRatio(bool checked){ - if(checked){ - spinRatio->setEnabled(true); - }else{ - spinRatio->setEnabled(false); - } + spinRatio->setEnabled(checked); } void options_imp::enableDHTPortSettings(bool checked) { - if(checked){ - spinDHTPort->setEnabled(true); - dh_port_lbl->setEnabled(true); - }else{ - spinDHTPort->setEnabled(false); - dh_port_lbl->setEnabled(false); - } + spinDHTPort->setEnabled(checked); + dh_port_lbl->setEnabled(checked); } void options_imp::enableDHTSettings(bool checked) { @@ -1221,11 +1209,7 @@ void options_imp::enableDHTSettings(bool checked) { void options_imp::enableDeleteRatio(bool checked){ - if(checked){ - spinMaxRatio->setEnabled(true); - }else{ - spinMaxRatio->setEnabled(false); - } + spinMaxRatio->setEnabled(checked); } void options_imp::enablePeerProxy(int index){ @@ -1253,60 +1237,34 @@ void options_imp::enablePeerProxy(int index){ } void options_imp::enableHTTPProxy(int index){ - if(index){ - //enable - lblProxyIP_http->setEnabled(true); - textProxyIP_http->setEnabled(true); - lblProxyPort_http->setEnabled(true); - spinProxyPort_http->setEnabled(true); - checkProxyAuth_http->setEnabled(true); - }else{ - //disable - lblProxyIP_http->setEnabled(false); - textProxyIP_http->setEnabled(false); - lblProxyPort_http->setEnabled(false); - spinProxyPort_http->setEnabled(false); - checkProxyAuth_http->setEnabled(false); + bool enable = (index > 0); + lblProxyIP_http->setEnabled(enable); + textProxyIP_http->setEnabled(enable); + lblProxyPort_http->setEnabled(enable); + spinProxyPort_http->setEnabled(enable); + checkProxyAuth_http->setEnabled(enable); + + if(!enable) checkProxyAuth_http->setChecked(false); - } } void options_imp::enablePeerProxyAuth(bool checked){ - if(checked){ - lblProxyUsername->setEnabled(true); - lblProxyPassword->setEnabled(true); - textProxyUsername->setEnabled(true); - textProxyPassword->setEnabled(true); - }else{ - lblProxyUsername->setEnabled(false); - lblProxyPassword->setEnabled(false); - textProxyUsername->setEnabled(false); - textProxyPassword->setEnabled(false); - } + lblProxyUsername->setEnabled(checked); + lblProxyPassword->setEnabled(checked); + textProxyUsername->setEnabled(checked); + textProxyPassword->setEnabled(checked); } void options_imp::enableHTTPProxyAuth(bool checked){ - if(checked){ - lblProxyUsername_http->setEnabled(true); - lblProxyPassword_http->setEnabled(true); - textProxyUsername_http->setEnabled(true); - textProxyPassword_http->setEnabled(true); - }else{ - lblProxyUsername_http->setEnabled(false); - lblProxyPassword_http->setEnabled(false); - textProxyUsername_http->setEnabled(false); - textProxyPassword_http->setEnabled(false); - } + lblProxyUsername_http->setEnabled(checked); + lblProxyPassword_http->setEnabled(checked); + textProxyUsername_http->setEnabled(checked); + textProxyPassword_http->setEnabled(checked); } void options_imp::enableDirScan(bool checked){ - if(checked){ - textScanDir->setEnabled(true); - browseScanDirButton->setEnabled(true); - }else{ - textScanDir->setEnabled(false); - browseScanDirButton->setEnabled(false); - } + textScanDir->setEnabled(checked); + browseScanDirButton->setEnabled(checked); } bool options_imp::isSlashScreenDisabled() const { diff --git a/src/options_imp.h b/src/options_imp.h index e79e19cc3..57933bf49 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -142,6 +142,7 @@ protected slots: void enableMaxConnecsLimit(bool checked); void enableMaxConnecsLimitPerTorrent(bool checked); void enableMaxUploadsLimitPerTorrent(bool checked); + void enableSchedulerFields(bool checked); void enableShareRatio(bool checked); void enableDeleteRatio(bool checked); void enableFilter(bool checked); diff --git a/src/preferences.h b/src/preferences.h index d632e4c00..0b84792ec 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -35,8 +35,10 @@ #include #include #include +#include #define QBT_REALM "Web UI Access" +enum scheduler_days { EVERY_DAY, WEEK_DAYS, WEEK_ENDS, MON, TUE, WED, THU, FRI, SAT, SUN }; class Preferences { public: @@ -266,7 +268,7 @@ public: static int getGlobalUploadLimit() { QSettings settings("qBittorrent", "qBittorrent"); - return settings.value(QString::fromUtf8("Preferences/Connection/GlobalUPLimit"), -1).toInt(); + return settings.value(QString::fromUtf8("Preferences/Connection/GlobalUPLimit"), 50).toInt(); } static void setGlobalUploadLimit(int limit) { @@ -275,6 +277,79 @@ public: settings.setValue("Preferences/Connection/GlobalUPLimit", limit); } + static int getAltGlobalDownloadLimit() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Connection/GlobalDLLimitAlt"), 10).toInt(); + } + + static void setAltGlobalDownloadLimit(int limit) { + QSettings settings("qBittorrent", "qBittorrent"); + if(limit <= 0) limit = -1; + settings.setValue("Preferences/Connection/GlobalDLLimitAlt", limit); + } + + static int getAltGlobalUploadLimit() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Connection/GlobalUPLimitAlt"), 10).toInt(); + } + + static void setAltGlobalUploadLimit(int limit) { + QSettings settings("qBittorrent", "qBittorrent"); + if(limit <= 0) limit = -1; + settings.setValue("Preferences/Connection/GlobalUPLimit", limit); + } + + static bool isAltBandwidthEnabled() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value("Preferences/Connection/alt_speeds_on", false).toBool(); + } + + static void setAltBandwidthEnabled(bool enabled) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue("Preferences/Connection/alt_speeds_on", enabled); + } + + static void setSchedulerEnabled(bool enabled) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Scheduler/Enabled"), enabled); + } + + static bool isSchedulerEnabled() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Scheduler/Enabled"), false).toBool(); + } + + static QTime getSchedulerStartTime() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Scheduler/start_time"), QTime(8,0)).toTime(); + } + + static void setSchedulerStartTime(QTime time) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Scheduler/start_time"), time); + } + + static QTime getSchedulerEndTime() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/Scheduler/end_time"), QTime(20,0)).toTime(); + } + + static void setSchedulerEndTime(QTime time) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Scheduler/end_time"), time); + } + + static scheduler_days getSchedulerDays() { + QSettings settings("qBittorrent", "qBittorrent"); + return (scheduler_days)settings.value(QString::fromUtf8("Preferences/Scheduler/days"), EVERY_DAY).toInt(); + } + + static void setSchedulerDays(scheduler_days days) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/Scheduler/days"), (int)days); + } + + static bool resolvePeerCountries() { QSettings settings("qBittorrent", "qBittorrent"); return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), true).toBool(); diff --git a/src/statusbar.h b/src/statusbar.h index 657fd7854..97c63a045 100644 --- a/src/statusbar.h +++ b/src/statusbar.h @@ -54,7 +54,9 @@ private: QFrame *statusSep1; QFrame *statusSep2; QFrame *statusSep3; + QFrame *statusSep4; QLabel *connecStatusLblIcon; + QPushButton *altSpeedsBtn; QTimer *refreshTimer; QWidget *container; QGridLayout *layout; @@ -77,6 +79,14 @@ public: //dlSpeedLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); connect(dlSpeedLbl, SIGNAL(clicked()), this, SLOT(capDownloadSpeed())); dlSpeedLbl->setFlat(true); + + altSpeedsBtn = new QPushButton(); + altSpeedsBtn->setFixedWidth(22); + updateAltSpeedsBtn(Preferences::isAltBandwidthEnabled()); + + connect(altSpeedsBtn, SIGNAL(clicked()), this, SLOT(toggleAlternativeSpeeds())); + altSpeedsBtn->setFlat(true); + upSpeedLbl = new QPushButton(tr("U: %1 B/s - T: %2", "Upload speed: x B/s - Transferred: x MiB").arg("0.0").arg(misc::friendlyUnit(0))); //upSpeedLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); connect(upSpeedLbl, SIGNAL(clicked()), this, SLOT(capUploadSpeed())); @@ -95,6 +105,10 @@ public: statusSep3->setFixedSize(3, dlSpeedLbl->fontMetrics().height()); statusSep3->setFrameStyle(QFrame::VLine); statusSep3->setFrameShadow(QFrame::Raised); + statusSep4 = new QFrame(); + statusSep4->setFixedSize(3, dlSpeedLbl->fontMetrics().height()); + statusSep4->setFrameStyle(QFrame::VLine); + statusSep4->setFrameShadow(QFrame::Raised); layout->addWidget(DHTLbl, 0, 0, Qt::AlignLeft); //layout->setColumnStretch(0, 10); layout->addWidget(statusSep1, 0, 1, Qt::AlignRight); @@ -105,9 +119,11 @@ public: //layout->setColumnStretch(3, 1); layout->addWidget(dlSpeedLbl, 0, 4, Qt::AlignLeft); //layout->setColumnStretch(4, 10); - layout->addWidget(statusSep3, 0, 5, Qt::AlignLeft); + layout->addWidget(statusSep3, 0, 5, Qt::AlignRight); + layout->addWidget(altSpeedsBtn, 0, 6); + layout->addWidget(statusSep4, 0, 7, Qt::AlignLeft); //layout->setColumnStretch(5, 10); - layout->addWidget(upSpeedLbl, 0, 6, Qt::AlignLeft); + layout->addWidget(upSpeedLbl, 0, 8, Qt::AlignLeft); //layout->setColumnStretch(6, 10); bar->addPermanentWidget(container); @@ -133,7 +149,9 @@ public: delete statusSep1; delete statusSep2; delete statusSep3; + delete statusSep4; delete connecStatusLblIcon; + delete altSpeedsBtn; delete layout; delete container; } @@ -169,17 +187,44 @@ public slots: upSpeedLbl->setText(tr("U: %1/s - T: %2", "Upload speed: x KiB/s - Transferred: x MiB").arg(misc::friendlyUnit(sessionStatus.payload_upload_rate)).arg(misc::friendlyUnit(sessionStatus.total_payload_upload))); } + void updateAltSpeedsBtn(bool alternative) { + if(alternative) { + altSpeedsBtn->setIcon(QIcon(":/Icons/slow.png")); + altSpeedsBtn->setToolTip(tr("Click to disable alternative speed limits")); + } else { + altSpeedsBtn->setIcon(QIcon(":/Icons/slow_off.png")); + altSpeedsBtn->setToolTip(tr("Click to enable alternative speed limits")); + } + } + + void toggleAlternativeSpeeds() { + bool alt = !Preferences::isAltBandwidthEnabled(); + Preferences::setAltBandwidthEnabled(alt); + if(alt) { + BTSession->getSession()->set_download_rate_limit(Preferences::getAltGlobalDownloadLimit()*1024); + BTSession->getSession()->set_upload_rate_limit(Preferences::getAltGlobalUploadLimit()*1024); + } else { + BTSession->getSession()->set_download_rate_limit(Preferences::getGlobalDownloadLimit()*1024); + BTSession->getSession()->set_upload_rate_limit(Preferences::getGlobalUploadLimit()*1024); + } + updateAltSpeedsBtn(alt); + emit alternativeSpeedsToggled(alt); + } + void capDownloadSpeed() { bool ok = false; long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), BTSession->getSession()->download_rate_limit()); if(ok) { + bool alt = Preferences::isAltBandwidthEnabled(); if(new_limit <= 0) { qDebug("Setting global download rate limit to Unlimited"); - BTSession->getSession()->set_download_rate_limit(-1); + if(!alt) + BTSession->getSession()->set_download_rate_limit(-1); Preferences::setGlobalDownloadLimit(-1); } else { qDebug("Setting global download rate limit to %.1fKb/s", new_limit/1024.); - BTSession->getSession()->set_download_rate_limit(new_limit); + if(!alt) + BTSession->getSession()->set_download_rate_limit(new_limit); Preferences::setGlobalDownloadLimit(new_limit/1024.); } } @@ -200,6 +245,9 @@ public slots: } } } + +signals: + void alternativeSpeedsToggled(bool alternative); }; #endif // STATUSBAR_H diff --git a/src/ui/mainwindow.ui b/src/ui/mainwindow.ui index d7b9fc37e..9e0cabe8c 100644 --- a/src/ui/mainwindow.ui +++ b/src/ui/mainwindow.ui @@ -259,6 +259,15 @@ Log Window + + + + :/Icons/slow_off.png:/Icons/slow_off.png + + + Use alternative speed limits + + diff --git a/src/ui/options.ui b/src/ui/options.ui index e67dbd370..2ffe266c2 100644 --- a/src/ui/options.ui +++ b/src/ui/options.ui @@ -141,6 +141,15 @@ ItemIsSelectable|ItemIsEnabled + + + Speed + + + + :/Icons/oxygen/chronometer.png:/Icons/oxygen/chronometer.png + + Bittorrent @@ -1113,11 +1122,11 @@ QGroupBox { 0 0 - 602 - 514 + 620 + 482 - + @@ -1324,16 +1333,81 @@ QGroupBox { + + + + Peer connections + + + + + + Resolve peer countries + + + true + + + + + + + Resolve peer host names + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + + + true + + + + + 0 + 0 + 620 + 490 + + + - Global bandwidth limiting + Global speed limits - + - + - + @@ -1366,9 +1440,9 @@ QGroupBox { - + - + @@ -1404,7 +1478,7 @@ QGroupBox { - + @@ -1460,40 +1534,239 @@ QGroupBox { - + - Peer connections + Alternative global speed limits - + - - - Resolve peer countries - - - true - - + + + + + + + Upload: + + + + + + + Download: + + + + + + + + + + + 1 + + + 1000000 + + + 10 + + + + + + + 1 + + + 1000000 + + + 10 + + + + + + + + + + + KiB/s + + + + + + + KiB/s + + + + + + + + + + 48 + 48 + + + + + 48 + 48 + + + + + + + :/Icons/slow48.png + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - Resolve peer host names - - + + + + + Scheduled times: + + + + + + + false + + + + + + + + + + to + + + Qt::AlignCenter + + + + + + + false + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + On days: + + + + + + + false + + + + Every day + + + + + Week days + + + + + Week ends + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - + Qt::Vertical 20 - 40 + 58 @@ -1502,9 +1775,6 @@ QGroupBox { - - - @@ -1936,8 +2206,8 @@ QGroupBox { 0 0 - 620 - 490 + 484 + 312 @@ -2370,8 +2640,8 @@ QGroupBox { 0 0 - 620 - 490 + 290 + 124 @@ -2467,8 +2737,8 @@ QGroupBox { 0 0 - 620 - 490 + 219 + 221 @@ -2634,8 +2904,8 @@ QGroupBox { 0 0 - 620 - 490 + 452 + 192