Browse Source

FEATURE: User can set alternative speed limits for fast toggling

Bandwidth scheduler is not functional yet (but appears in program preferences)
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
06efd64a80
  1. 3
      Changelog
  2. 14
      src/GUI.cpp
  3. 1
      src/GUI.h
  4. BIN
      src/Icons/oxygen/chronometer.png
  5. BIN
      src/Icons/slow.png
  6. BIN
      src/Icons/slow48.png
  7. BIN
      src/Icons/slow_off.png
  8. 4
      src/icons.qrc
  9. 174
      src/options_imp.cpp
  10. 1
      src/options_imp.h
  11. 77
      src/preferences.h
  12. 56
      src/statusbar.h
  13. 9
      src/ui/mainwindow.ui
  14. 348
      src/ui/options.ui

3
Changelog

@ -1,3 +1,6 @@
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.2.0
- FEATURE: User can set alternative speed limits for fast toggling
* Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0 * Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0
- FEATURE: Graphical User Interface can be disabled at compilation time (headless running) - FEATURE: Graphical User Interface can be disabled at compilation time (headless running)
- FEATURE: Torrents can be labeled/categorized - FEATURE: Torrents can be labeled/categorized

14
src/GUI.cpp

@ -180,6 +180,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
createKeyboardShortcuts(); createKeyboardShortcuts();
// Create status bar // Create status bar
status_bar = new StatusBar(QMainWindow::statusBar(), BTSession); 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(); 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() { void GUI::createTrayIcon() {
// Tray icon // Tray icon
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@ -892,6 +904,8 @@ void GUI::createTrayIcon() {
myTrayIconMenu->addAction(actionOpen); myTrayIconMenu->addAction(actionOpen);
myTrayIconMenu->addAction(actionDownload_from_URL); myTrayIconMenu->addAction(actionDownload_from_URL);
myTrayIconMenu->addSeparator(); myTrayIconMenu->addSeparator();
updateAltSpeedsBtn(Preferences::isAltBandwidthEnabled());
myTrayIconMenu->addAction(actionUse_alternative_speed_limits);
myTrayIconMenu->addAction(actionSet_global_download_limit); myTrayIconMenu->addAction(actionSet_global_download_limit);
myTrayIconMenu->addAction(actionSet_global_upload_limit); myTrayIconMenu->addAction(actionSet_global_upload_limit);
myTrayIconMenu->addSeparator(); myTrayIconMenu->addSeparator();

1
src/GUI.h

@ -143,6 +143,7 @@ public slots:
void setTabText(int index, QString text) const; void setTabText(int index, QString text) const;
void showNotificationBaloon(QString title, QString msg) const; void showNotificationBaloon(QString title, QString msg) const;
void downloadFromURLList(const QStringList& urls); void downloadFromURLList(const QStringList& urls);
void updateAltSpeedsBtn(bool alternative);
protected: protected:
void closeEvent(QCloseEvent *); void closeEvent(QCloseEvent *);

BIN
src/Icons/oxygen/chronometer.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

BIN
src/Icons/slow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

BIN
src/Icons/slow48.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
src/Icons/slow_off.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

4
src/icons.qrc

@ -1,13 +1,16 @@
<!DOCTYPE RCC><RCC version="1.0"> <!DOCTYPE RCC><RCC version="1.0">
<qresource> <qresource>
<file>Icons/slow48.png</file>
<file>Icons/rss32.png</file> <file>Icons/rss32.png</file>
<file>Icons/sphere2.png</file> <file>Icons/sphere2.png</file>
<file>Icons/downarrow.png</file> <file>Icons/downarrow.png</file>
<file>Icons/url.png</file> <file>Icons/url.png</file>
<file>Icons/locale.png</file> <file>Icons/locale.png</file>
<file>Icons/loading.png</file> <file>Icons/loading.png</file>
<file>Icons/slow.png</file>
<file>Icons/magnet.png</file> <file>Icons/magnet.png</file>
<file>Icons/sphere.png</file> <file>Icons/sphere.png</file>
<file>Icons/slow_off.png</file>
<file>Icons/uparrow.png</file> <file>Icons/uparrow.png</file>
<file>Icons/rss16.png</file> <file>Icons/rss16.png</file>
<file>Icons/skin/checkingUP.png</file> <file>Icons/skin/checkingUP.png</file>
@ -154,6 +157,7 @@
<file>Icons/oxygen/unsubscribe16.png</file> <file>Icons/oxygen/unsubscribe16.png</file>
<file>Icons/oxygen/subscribe.png</file> <file>Icons/oxygen/subscribe.png</file>
<file>Icons/oxygen/edit-copy.png</file> <file>Icons/oxygen/edit-copy.png</file>
<file>Icons/oxygen/chronometer.png</file>
<file>Icons/oxygen/bt_settings.png</file> <file>Icons/oxygen/bt_settings.png</file>
<file>Icons/oxygen/document-new.png</file> <file>Icons/oxygen/document-new.png</file>
<file>Icons/oxygen/preferences-desktop.png</file> <file>Icons/oxygen/preferences-desktop.png</file>

174
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("한글")); comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/south_korea.png"))), QString::fromUtf8("한글"));
locales << "ko_KR"; locales << "ko_KR";
// Load week days (scheduler)
for(uint i=1; i<=7; ++i) {
schedule_days->addItem(QDate::longDayName(i, QDate::StandaloneFormat));
}
// Load options // Load options
loadOptions(); loadOptions();
// Disable systray integration if it is not supported by the system // 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 // Connection tab
connect(checkUploadLimit, SIGNAL(toggled(bool)), this, SLOT(enableUploadLimit(bool))); connect(checkUploadLimit, SIGNAL(toggled(bool)), this, SLOT(enableUploadLimit(bool)));
connect(checkDownloadLimit, SIGNAL(toggled(bool)), this, SLOT(enableDownloadLimit(bool))); connect(checkDownloadLimit, SIGNAL(toggled(bool)), this, SLOT(enableDownloadLimit(bool)));
connect(check_schedule, SIGNAL(toggled(bool)), this, SLOT(enableSchedulerFields(bool)));
// Bittorrent tab // Bittorrent tab
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)));
@ -210,6 +216,10 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(spinDownloadLimit, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton())); connect(spinDownloadLimit, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkResolveCountries, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton())); connect(checkResolveCountries, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkResolveHosts, 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 // 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()));
@ -395,6 +405,12 @@ void options_imp::saveOptions(){
settings.setValue(QString::fromUtf8("NAT-PMP"), isNATPMPEnabled()); settings.setValue(QString::fromUtf8("NAT-PMP"), isNATPMPEnabled());
settings.setValue(QString::fromUtf8("GlobalDLLimit"), getGlobalBandwidthLimits().first); settings.setValue(QString::fromUtf8("GlobalDLLimit"), getGlobalBandwidthLimits().first);
settings.setValue(QString::fromUtf8("GlobalUPLimit"), getGlobalBandwidthLimits().second); 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("ResolvePeerCountries", checkResolveCountries->isChecked());
settings.setValue("ResolvePeerHostNames", checkResolveHosts->isChecked()); settings.setValue("ResolvePeerHostNames", checkResolveHosts->isChecked());
settings.setValue(QString::fromUtf8("ProxyType"), getPeerProxyType()); settings.setValue(QString::fromUtf8("ProxyType"), getPeerProxyType());
@ -646,6 +662,14 @@ void options_imp::loadOptions(){
checkUploadLimit->setChecked(false); checkUploadLimit->setChecked(false);
spinUploadLimit->setEnabled(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 // Peer connections
checkResolveCountries->setChecked(Preferences::resolvePeerCountries()); checkResolveCountries->setChecked(Preferences::resolvePeerCountries());
checkResolveHosts->setChecked(Preferences::resolvePeerHostNames()); checkResolveHosts->setChecked(Preferences::resolvePeerHostNames());
@ -1095,38 +1119,27 @@ bool options_imp::useAdditionDialog() const{
return checkAdditionDialog->isChecked(); 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){ void options_imp::enableMaxConnecsLimit(bool checked){
if(checked) { spinMaxConnec->setEnabled(checked);
spinMaxConnec->setEnabled(true);
}else{
spinMaxConnec->setEnabled(false);
}
} }
void options_imp::enableQueueingSystem(bool checked) { void options_imp::enableQueueingSystem(bool checked) {
if(checked) { spinMaxActiveDownloads->setEnabled(checked);
spinMaxActiveDownloads->setEnabled(true); spinMaxActiveUploads->setEnabled(checked);
spinMaxActiveUploads->setEnabled(true); label_max_active_dl->setEnabled(checked);
label_max_active_dl->setEnabled(true); label_max_active_up->setEnabled(checked);
label_max_active_up->setEnabled(true); maxActiveTorrents_lbl->setEnabled(checked);
maxActiveTorrents_lbl->setEnabled(true); spinMaxActiveTorrents->setEnabled(checked);
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);
}
} }
void options_imp::enableMaxConnecsLimitPerTorrent(bool checked){ void options_imp::enableMaxConnecsLimitPerTorrent(bool checked){
if(checked) { spinMaxConnecPerTorrent->setEnabled(checked);
spinMaxConnecPerTorrent->setEnabled(true);
}else{
spinMaxConnecPerTorrent->setEnabled(false);
}
} }
void options_imp::enableSystrayOptions() { void options_imp::enableSystrayOptions() {
@ -1158,55 +1171,30 @@ void options_imp::enableMaxUploadsLimitPerTorrent(bool checked){
} }
void options_imp::enableFilter(bool checked){ void options_imp::enableFilter(bool checked){
if(checked){ lblFilterPath->setEnabled(checked);
lblFilterPath->setEnabled(true); textFilterPath->setEnabled(checked);
textFilterPath->setEnabled(true); browseFilterButton->setEnabled(checked);
browseFilterButton->setEnabled(true);
}else{
lblFilterPath->setEnabled(false);
textFilterPath->setEnabled(false);
browseFilterButton->setEnabled(false);
}
} }
void options_imp::enableRSS(bool checked) { void options_imp::enableRSS(bool checked) {
if(checked){ groupRSSSettings->setEnabled(checked);
groupRSSSettings->setEnabled(true);
}else{
groupRSSSettings->setEnabled(false);
}
} }
void options_imp::enableUploadLimit(bool checked){ void options_imp::enableUploadLimit(bool checked){
if(checked){ spinUploadLimit->setEnabled(checked);
spinUploadLimit->setEnabled(true);
}else{
spinUploadLimit->setEnabled(false);
}
} }
void options_imp::enableApplyButton(){ void options_imp::enableApplyButton(){
if(!applyButton->isEnabled()){ applyButton->setEnabled(true);
applyButton->setEnabled(true);
}
} }
void options_imp::enableShareRatio(bool checked){ void options_imp::enableShareRatio(bool checked){
if(checked){ spinRatio->setEnabled(checked);
spinRatio->setEnabled(true);
}else{
spinRatio->setEnabled(false);
}
} }
void options_imp::enableDHTPortSettings(bool checked) { void options_imp::enableDHTPortSettings(bool checked) {
if(checked){ spinDHTPort->setEnabled(checked);
spinDHTPort->setEnabled(true); dh_port_lbl->setEnabled(checked);
dh_port_lbl->setEnabled(true);
}else{
spinDHTPort->setEnabled(false);
dh_port_lbl->setEnabled(false);
}
} }
void options_imp::enableDHTSettings(bool checked) { void options_imp::enableDHTSettings(bool checked) {
@ -1221,11 +1209,7 @@ void options_imp::enableDHTSettings(bool checked) {
void options_imp::enableDeleteRatio(bool checked){ void options_imp::enableDeleteRatio(bool checked){
if(checked){ spinMaxRatio->setEnabled(checked);
spinMaxRatio->setEnabled(true);
}else{
spinMaxRatio->setEnabled(false);
}
} }
void options_imp::enablePeerProxy(int index){ void options_imp::enablePeerProxy(int index){
@ -1253,60 +1237,34 @@ void options_imp::enablePeerProxy(int index){
} }
void options_imp::enableHTTPProxy(int index){ void options_imp::enableHTTPProxy(int index){
if(index){ bool enable = (index > 0);
//enable lblProxyIP_http->setEnabled(enable);
lblProxyIP_http->setEnabled(true); textProxyIP_http->setEnabled(enable);
textProxyIP_http->setEnabled(true); lblProxyPort_http->setEnabled(enable);
lblProxyPort_http->setEnabled(true); spinProxyPort_http->setEnabled(enable);
spinProxyPort_http->setEnabled(true); checkProxyAuth_http->setEnabled(enable);
checkProxyAuth_http->setEnabled(true);
}else{ if(!enable)
//disable
lblProxyIP_http->setEnabled(false);
textProxyIP_http->setEnabled(false);
lblProxyPort_http->setEnabled(false);
spinProxyPort_http->setEnabled(false);
checkProxyAuth_http->setEnabled(false);
checkProxyAuth_http->setChecked(false); checkProxyAuth_http->setChecked(false);
}
} }
void options_imp::enablePeerProxyAuth(bool checked){ void options_imp::enablePeerProxyAuth(bool checked){
if(checked){ lblProxyUsername->setEnabled(checked);
lblProxyUsername->setEnabled(true); lblProxyPassword->setEnabled(checked);
lblProxyPassword->setEnabled(true); textProxyUsername->setEnabled(checked);
textProxyUsername->setEnabled(true); textProxyPassword->setEnabled(checked);
textProxyPassword->setEnabled(true);
}else{
lblProxyUsername->setEnabled(false);
lblProxyPassword->setEnabled(false);
textProxyUsername->setEnabled(false);
textProxyPassword->setEnabled(false);
}
} }
void options_imp::enableHTTPProxyAuth(bool checked){ void options_imp::enableHTTPProxyAuth(bool checked){
if(checked){ lblProxyUsername_http->setEnabled(checked);
lblProxyUsername_http->setEnabled(true); lblProxyPassword_http->setEnabled(checked);
lblProxyPassword_http->setEnabled(true); textProxyUsername_http->setEnabled(checked);
textProxyUsername_http->setEnabled(true); textProxyPassword_http->setEnabled(checked);
textProxyPassword_http->setEnabled(true);
}else{
lblProxyUsername_http->setEnabled(false);
lblProxyPassword_http->setEnabled(false);
textProxyUsername_http->setEnabled(false);
textProxyPassword_http->setEnabled(false);
}
} }
void options_imp::enableDirScan(bool checked){ void options_imp::enableDirScan(bool checked){
if(checked){ textScanDir->setEnabled(checked);
textScanDir->setEnabled(true); browseScanDirButton->setEnabled(checked);
browseScanDirButton->setEnabled(true);
}else{
textScanDir->setEnabled(false);
browseScanDirButton->setEnabled(false);
}
} }
bool options_imp::isSlashScreenDisabled() const { bool options_imp::isSlashScreenDisabled() const {

1
src/options_imp.h

@ -142,6 +142,7 @@ 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 enableSchedulerFields(bool checked);
void enableShareRatio(bool checked); void enableShareRatio(bool checked);
void enableDeleteRatio(bool checked); void enableDeleteRatio(bool checked);
void enableFilter(bool checked); void enableFilter(bool checked);

77
src/preferences.h

@ -35,8 +35,10 @@
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QPair> #include <QPair>
#include <QDir> #include <QDir>
#include <QTime>
#define QBT_REALM "Web UI Access" #define QBT_REALM "Web UI Access"
enum scheduler_days { EVERY_DAY, WEEK_DAYS, WEEK_ENDS, MON, TUE, WED, THU, FRI, SAT, SUN };
class Preferences { class Preferences {
public: public:
@ -266,7 +268,7 @@ public:
static int getGlobalUploadLimit() { static int getGlobalUploadLimit() {
QSettings settings("qBittorrent", "qBittorrent"); 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) { static void setGlobalUploadLimit(int limit) {
@ -275,6 +277,79 @@ public:
settings.setValue("Preferences/Connection/GlobalUPLimit", limit); 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() { static bool resolvePeerCountries() {
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), true).toBool(); return settings.value(QString::fromUtf8("Preferences/Connection/ResolvePeerCountries"), true).toBool();

56
src/statusbar.h

@ -54,7 +54,9 @@ private:
QFrame *statusSep1; QFrame *statusSep1;
QFrame *statusSep2; QFrame *statusSep2;
QFrame *statusSep3; QFrame *statusSep3;
QFrame *statusSep4;
QLabel *connecStatusLblIcon; QLabel *connecStatusLblIcon;
QPushButton *altSpeedsBtn;
QTimer *refreshTimer; QTimer *refreshTimer;
QWidget *container; QWidget *container;
QGridLayout *layout; QGridLayout *layout;
@ -77,6 +79,14 @@ public:
//dlSpeedLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred); //dlSpeedLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
connect(dlSpeedLbl, SIGNAL(clicked()), this, SLOT(capDownloadSpeed())); connect(dlSpeedLbl, SIGNAL(clicked()), this, SLOT(capDownloadSpeed()));
dlSpeedLbl->setFlat(true); 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 = 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); //upSpeedLbl->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
connect(upSpeedLbl, SIGNAL(clicked()), this, SLOT(capUploadSpeed())); connect(upSpeedLbl, SIGNAL(clicked()), this, SLOT(capUploadSpeed()));
@ -95,6 +105,10 @@ public:
statusSep3->setFixedSize(3, dlSpeedLbl->fontMetrics().height()); statusSep3->setFixedSize(3, dlSpeedLbl->fontMetrics().height());
statusSep3->setFrameStyle(QFrame::VLine); statusSep3->setFrameStyle(QFrame::VLine);
statusSep3->setFrameShadow(QFrame::Raised); 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->addWidget(DHTLbl, 0, 0, Qt::AlignLeft);
//layout->setColumnStretch(0, 10); //layout->setColumnStretch(0, 10);
layout->addWidget(statusSep1, 0, 1, Qt::AlignRight); layout->addWidget(statusSep1, 0, 1, Qt::AlignRight);
@ -105,9 +119,11 @@ public:
//layout->setColumnStretch(3, 1); //layout->setColumnStretch(3, 1);
layout->addWidget(dlSpeedLbl, 0, 4, Qt::AlignLeft); layout->addWidget(dlSpeedLbl, 0, 4, Qt::AlignLeft);
//layout->setColumnStretch(4, 10); //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->setColumnStretch(5, 10);
layout->addWidget(upSpeedLbl, 0, 6, Qt::AlignLeft); layout->addWidget(upSpeedLbl, 0, 8, Qt::AlignLeft);
//layout->setColumnStretch(6, 10); //layout->setColumnStretch(6, 10);
bar->addPermanentWidget(container); bar->addPermanentWidget(container);
@ -133,7 +149,9 @@ public:
delete statusSep1; delete statusSep1;
delete statusSep2; delete statusSep2;
delete statusSep3; delete statusSep3;
delete statusSep4;
delete connecStatusLblIcon; delete connecStatusLblIcon;
delete altSpeedsBtn;
delete layout; delete layout;
delete container; 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))); 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() { void capDownloadSpeed() {
bool ok = false; bool ok = false;
long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), BTSession->getSession()->download_rate_limit()); long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), BTSession->getSession()->download_rate_limit());
if(ok) { if(ok) {
bool alt = Preferences::isAltBandwidthEnabled();
if(new_limit <= 0) { if(new_limit <= 0) {
qDebug("Setting global download rate limit to Unlimited"); 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); Preferences::setGlobalDownloadLimit(-1);
} else { } else {
qDebug("Setting global download rate limit to %.1fKb/s", new_limit/1024.); 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.); Preferences::setGlobalDownloadLimit(new_limit/1024.);
} }
} }
@ -200,6 +245,9 @@ public slots:
} }
} }
} }
signals:
void alternativeSpeedsToggled(bool alternative);
}; };
#endif // STATUSBAR_H #endif // STATUSBAR_H

9
src/ui/mainwindow.ui

@ -259,6 +259,15 @@
<string>Log Window</string> <string>Log Window</string>
</property> </property>
</action> </action>
<action name="actionUse_alternative_speed_limits">
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/Icons/slow_off.png</normaloff>:/Icons/slow_off.png</iconset>
</property>
<property name="text">
<string>Use alternative speed limits</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="../icons.qrc"/> <include location="../icons.qrc"/>

348
src/ui/options.ui

@ -141,6 +141,15 @@
<set>ItemIsSelectable|ItemIsEnabled</set> <set>ItemIsSelectable|ItemIsEnabled</set>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Speed</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/Icons/oxygen/chronometer.png</normaloff>:/Icons/oxygen/chronometer.png</iconset>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>Bittorrent</string> <string>Bittorrent</string>
@ -1113,11 +1122,11 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>602</width> <width>620</width>
<height>514</height> <height>482</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_18"> <layout class="QVBoxLayout" name="verticalLayout_28">
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout">
<item> <item>
@ -1324,16 +1333,81 @@ QGroupBox {
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Peer connections</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
<item>
<widget class="QCheckBox" name="checkResolveCountries">
<property name="text">
<string>Resolve peer countries</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkResolveHosts">
<property name="text">
<string>Resolve peer host names</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QVBoxLayout"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_34">
<item>
<widget class="QScrollArea" name="scrollArea_9">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_9">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>620</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_33">
<item> <item>
<widget class="QGroupBox" name="bandwidthBox"> <widget class="QGroupBox" name="bandwidthBox">
<property name="title"> <property name="title">
<string>Global bandwidth limiting</string> <string>Global speed limits</string>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout" name="verticalLayout_18">
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout" name="_3">
<item> <item>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout" name="_5">
<item> <item>
<widget class="QCheckBox" name="checkUploadLimit"> <widget class="QCheckBox" name="checkUploadLimit">
<property name="minimumSize"> <property name="minimumSize">
@ -1366,9 +1440,9 @@ QGroupBox {
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout" name="_18">
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout" name="_19">
<item> <item>
<widget class="QSpinBox" name="spinUploadLimit"> <widget class="QSpinBox" name="spinUploadLimit">
<property name="enabled"> <property name="enabled">
@ -1404,7 +1478,7 @@ QGroupBox {
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout" name="_20">
<item> <item>
<widget class="QSpinBox" name="spinDownloadLimit"> <widget class="QSpinBox" name="spinDownloadLimit">
<property name="enabled"> <property name="enabled">
@ -1460,40 +1534,239 @@ QGroupBox {
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox_2"> <widget class="QGroupBox" name="groupBox_6">
<property name="title"> <property name="title">
<string>Peer connections</string> <string>Alternative global speed limits</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_25"> <layout class="QVBoxLayout" name="verticalLayout_32">
<item> <item>
<widget class="QCheckBox" name="checkResolveCountries"> <layout class="QHBoxLayout" name="horizontalLayout_12">
<property name="text"> <item>
<string>Resolve peer countries</string> <layout class="QVBoxLayout" name="verticalLayout_31">
</property> <item>
<property name="checked"> <widget class="QLabel" name="label_11">
<bool>true</bool> <property name="text">
</property> <string>Upload:</string>
</widget> </property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Download:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_30">
<item>
<widget class="QSpinBox" name="spinUploadLimitAlt">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinDownloadLimitAlt">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_29">
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>KiB/s</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_15">
<property name="text">
<string>KiB/s</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_16">
<property name="minimumSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>48</width>
<height>48</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../icons.qrc">:/Icons/slow48.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<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> <item>
<widget class="QCheckBox" name="checkResolveHosts"> <layout class="QHBoxLayout" name="horizontalLayout_13">
<property name="text"> <item>
<string>Resolve peer host names</string> <widget class="QCheckBox" name="check_schedule">
</property> <property name="text">
</widget> <string>Scheduled times:</string>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="schedule_from">
<property name="enabled">
<bool>false</bool>
</property>
<property name="time">
<time>
<hour>8</hour>
<minute>0</minute>
<second>0</second>
</time>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string extracomment="time1 to time2">to</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTimeEdit" name="schedule_to">
<property name="enabled">
<bool>false</bool>
</property>
<property name="time">
<time>
<hour>20</hour>
<minute>0</minute>
<second>0</second>
</time>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<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>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QLabel" name="label_18">
<property name="text">
<string>On days:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="schedule_days">
<property name="enabled">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Every day</string>
</property>
</item>
<item>
<property name="text">
<string>Week days</string>
</property>
</item>
<item>
<property name="text">
<string>Week ends</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_10">
<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>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<spacer name="verticalSpacer_7"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>58</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -1502,9 +1775,6 @@ QGroupBox {
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<layout class="QVBoxLayout"/>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tabOptionPage4"> <widget class="QWidget" name="tabOptionPage4">
@ -1936,8 +2206,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>620</width> <width>484</width>
<height>490</height> <height>312</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_16"> <layout class="QVBoxLayout" name="verticalLayout_16">
@ -2370,8 +2640,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>620</width> <width>290</width>
<height>490</height> <height>124</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_21"> <layout class="QVBoxLayout" name="verticalLayout_21">
@ -2467,8 +2737,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>620</width> <width>219</width>
<height>490</height> <height>221</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_23"> <layout class="QVBoxLayout" name="verticalLayout_23">
@ -2634,8 +2904,8 @@ QGroupBox {
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>620</width> <width>452</width>
<height>490</height> <height>192</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_24"> <layout class="QVBoxLayout" name="verticalLayout_24">

Loading…
Cancel
Save