Browse Source

- Allow to set global upload/download bandwidth limit from tray icon menu

- Fixed a bug in bandwidth limitation per torrent (confused bytes with kbytes)
- Fixed a bug with paused torrents still displayed as checking
adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
8c5d38400a
  1. 2
      Changelog
  2. 3
      TODO
  3. 19
      src/GUI.cpp
  4. 2
      src/GUI.h
  5. 112
      src/MainWindow.ui
  6. 40
      src/allocationDlg.h
  7. 4
      src/bittorrent.cpp
  8. 1
      src/bittorrent.h

2
Changelog

@ -19,6 +19,8 @@
- FEATURE: Filtered files are not allocated on the hard-drive anymore (sparse file support) - FEATURE: Filtered files are not allocated on the hard-drive anymore (sparse file support)
- FEATURE: IPs blocked by filter are now logged in GUI - FEATURE: IPs blocked by filter are now logged in GUI
- FEATURE: Added a way to link against static libtorrent (useful for deb packages) - FEATURE: Added a way to link against static libtorrent (useful for deb packages)
- FEATURE: Allow to set global upload/download limits from tray icon menu
- FEATURE: IPv6 is now fully supported
- I18N: Added Hungarian translation - I18N: Added Hungarian translation
- BUGFIX: Progress of paused torrents is now correct on restart - BUGFIX: Progress of paused torrents is now correct on restart
- BUGFIX: Progress column gets sorted on restart it is was during last execution - BUGFIX: Progress column gets sorted on restart it is was during last execution

3
TODO

@ -43,4 +43,5 @@
- Fix all (or almost all) opened bugs in bug tracker - Fix all (or almost all) opened bugs in bug tracker
- Fix sorting with Qt 4.3 - Reported to Trolltech, waiting for fix - Fix sorting with Qt 4.3 - Reported to Trolltech, waiting for fix
- update sorting when a new torrent is added? - update sorting when a new torrent is added?
- Allow to adjust UP/DL speed limit from tray icon menu - Open -> cancel on tray icon closes qBT...
- Save bandwidth limits per torrent on hard disk

19
src/GUI.cpp

@ -101,6 +101,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
actionPreview_file->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/preview.png"))); actionPreview_file->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/preview.png")));
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))); actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
actionSet_download_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png"))); actionSet_download_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png")));
actionSet_global_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
actionSet_global_download_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png")));
actionDocumentation->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/qb_question.png"))); actionDocumentation->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/qb_question.png")));
connecStatusLblIcon = new QLabel(); connecStatusLblIcon = new QLabel();
connecStatusLblIcon->setFrameShape(QFrame::NoFrame); connecStatusLblIcon->setFrameShape(QFrame::NoFrame);
@ -340,6 +342,16 @@ void GUI::on_actionSet_upload_limit_triggered(){
new BandwidthAllocationDialog(this, true, &BTSession, hashes); new BandwidthAllocationDialog(this, true, &BTSession, hashes);
} }
void GUI::on_actionSet_global_upload_limit_triggered(){
qDebug("actionSet_global_upload_limit_triggered");
new BandwidthAllocationDialog(this, true, &BTSession, QStringList());
}
void GUI::on_actionSet_global_download_limit_triggered(){
qDebug("actionSet_global_download_limit_triggered");
new BandwidthAllocationDialog(this, false, &BTSession, QStringList());
}
void GUI::on_actionPreview_file_triggered(){ void GUI::on_actionPreview_file_triggered(){
if(tabs->currentIndex() > 1) return; if(tabs->currentIndex() > 1) return;
bool inDownloadList = true; bool inDownloadList = true;
@ -506,6 +518,9 @@ void GUI::updateDlList(bool force){
if(torrentStatus.state != torrent_status::checking_files && torrentStatus.state != torrent_status::queued_for_checking){ if(torrentStatus.state != torrent_status::checking_files && torrentStatus.state != torrent_status::queued_for_checking){
qDebug("Paused torrent finished checking with state: %d", torrentStatus.state); qDebug("Paused torrent finished checking with state: %d", torrentStatus.state);
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress)); DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)torrentStatus.progress));
DLListModel->setData(DLListModel->index(row, STATUS), QVariant(tr("Paused")));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
setRowColor(row, "red");
BTSession.pauseTorrent(fileHash); BTSession.pauseTorrent(fileHash);
continue; continue;
} }
@ -816,6 +831,7 @@ void GUI::closeEvent(QCloseEvent *e){
return; return;
} }
} }
hide();
// Save DHT entry // Save DHT entry
BTSession.saveDHTEntry(); BTSession.saveDHTEntry();
// Save window size, columns size // Save window size, columns size
@ -1572,6 +1588,9 @@ void GUI::createTrayIcon(){
myTrayIconMenu->addAction(actionOpen); myTrayIconMenu->addAction(actionOpen);
myTrayIconMenu->addAction(actionDownload_from_URL); myTrayIconMenu->addAction(actionDownload_from_URL);
myTrayIconMenu->addSeparator(); myTrayIconMenu->addSeparator();
myTrayIconMenu->addAction(actionSet_global_download_limit);
myTrayIconMenu->addAction(actionSet_global_upload_limit);
myTrayIconMenu->addSeparator();
myTrayIconMenu->addAction(actionStart_All); myTrayIconMenu->addAction(actionStart_All);
myTrayIconMenu->addAction(actionPause_All); myTrayIconMenu->addAction(actionPause_All);
myTrayIconMenu->addSeparator(); myTrayIconMenu->addSeparator();

2
src/GUI.h

@ -140,6 +140,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void on_actionDelete_triggered(); void on_actionDelete_triggered();
void on_actionSet_download_limit_triggered(); void on_actionSet_download_limit_triggered();
void on_actionSet_upload_limit_triggered(); void on_actionSet_upload_limit_triggered();
void on_actionSet_global_upload_limit_triggered();
void on_actionSet_global_download_limit_triggered();
void on_actionDocumentation_triggered(); void on_actionDocumentation_triggered();
void checkConnectionStatus(); void checkConnectionStatus();
void configureSession(bool deleteOptions); void configureSession(bool deleteOptions);

112
src/MainWindow.ui

@ -15,14 +15,26 @@
<property name="windowTitle" > <property name="windowTitle" >
<string/> <string/>
</property> </property>
<property name="unifiedTitleAndToolBarOnMac" >
<bool>false</bool>
</property>
<widget class="QWidget" name="centralwidget" > <widget class="QWidget" name="centralwidget" >
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QTabWidget" name="tabs" > <widget class="QTabWidget" name="tabs" >
<property name="tabPosition" > <property name="tabPosition" >
@ -36,28 +48,55 @@
<string>Downloads</string> <string>Downloads</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item> <property name="leftMargin" >
<layout class="QHBoxLayout" > <number>0</number>
<property name="margin" > </property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number> <number>0</number>
</property> </property>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
@ -275,18 +314,25 @@
<string>Log</string> <string>Log</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QTextBrowser" name="infoBar" > <widget class="QTextBrowser" name="infoBar" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -309,12 +355,21 @@
<string>IP filter</string> <string>IP filter</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QTextBrowser" name="textBlockedUsers" > <widget class="QTextBrowser" name="textBlockedUsers" >
<property name="maximumSize" > <property name="maximumSize" >
@ -408,7 +463,10 @@
</size> </size>
</property> </property>
<attribute name="toolBarArea" > <attribute name="toolBarArea" >
<number>4</number> <enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak" >
<bool>false</bool>
</attribute> </attribute>
<addaction name="actionOpen" /> <addaction name="actionOpen" />
<addaction name="actionDownload_from_URL" /> <addaction name="actionDownload_from_URL" />
@ -528,6 +586,16 @@
<string>Documentation</string> <string>Documentation</string>
</property> </property>
</action> </action>
<action name="actionSet_global_download_limit" >
<property name="text" >
<string>Set global download limit</string>
</property>
</action>
<action name="actionSet_global_upload_limit" >
<property name="text" >
<string>Set global upload limit</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

40
src/allocationDlg.h

@ -21,6 +21,7 @@
#include <QDialog> #include <QDialog>
#include <QList> #include <QList>
#include <QSettings>
#include "ui_bandwidth_limit.h" #include "ui_bandwidth_limit.h"
#include "misc.h" #include "misc.h"
#include "bittorrent.h" #include "bittorrent.h"
@ -34,12 +35,18 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
BandwidthAllocationDialog(QWidget *parent, bool uploadMode, bittorrent *BTSession, QStringList hashes): QDialog(parent), uploadMode(uploadMode){ BandwidthAllocationDialog(QWidget *parent, bool uploadMode, bittorrent *BTSession, QStringList hashes): QDialog(parent), uploadMode(uploadMode){
setupUi(this); setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
qDebug("Bandwidth allocation dialog creation");
this->BTSession = BTSession; this->BTSession = BTSession;
if(hashes.size() == 0)
global = true;
else
global = false;
if(uploadMode) if(uploadMode)
lblTitle->setText(tr("Upload limit:")); lblTitle->setText(tr("Upload limit:"));
else else
lblTitle->setText(tr("Download limit:")); lblTitle->setText(tr("Download limit:"));
connect(bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateBandwidthLabel(int))); connect(bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateBandwidthLabel(int)));
if(!global){
QString hash; QString hash;
foreach(hash, hashes){ foreach(hash, hashes){
torrent_handle h = BTSession->getTorrentHandle(hash); torrent_handle h = BTSession->getTorrentHandle(hash);
@ -75,6 +82,22 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)")); limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)"));
kb_lbl->setText(""); kb_lbl->setText("");
} }
}else{
// Global limit
int val;
session *s = BTSession->getSession();
if(uploadMode)
val = (int)(s->upload_rate_limit()/1024.);
else
val = (int)(s->download_rate_limit()/1024.);
if(val == -1){
bandwidthSlider->setValue(-1);
limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)"));
kb_lbl->setText("");
}else{
bandwidthSlider->setValue(val);
}
}
connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth())); connect(buttonBox, SIGNAL(accepted()), this, SLOT(setBandwidth()));
show(); show();
} }
@ -96,23 +119,36 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
void setBandwidth(){ void setBandwidth(){
int val = bandwidthSlider->value(); int val = bandwidthSlider->value();
if(!global){
torrent_handle h; torrent_handle h;
if(uploadMode) { if(uploadMode) {
foreach(h, handles) { foreach(h, handles) {
h.set_upload_limit(val); h.set_upload_limit(val*1024);
qDebug("Setting upload limit"); qDebug("Setting upload limit");
} }
} else { } else {
foreach(h, handles) { foreach(h, handles) {
h.set_download_limit(val); h.set_download_limit(val*1024);
qDebug("Setting download limit"); qDebug("Setting download limit");
} }
} }
}else{
QSettings settings("qBittorrent", "qBittorrent");
session *s = BTSession->getSession();
if(uploadMode){
s->set_upload_rate_limit(val*1024);
settings.setValue("Options/Main/UPLimit", val);
}else{
s->set_download_rate_limit(val*1024);
settings.setValue("Options/Main/DLLimit", val);
}
}
close(); close();
} }
private: private:
bool uploadMode; bool uploadMode;
bool global;
bittorrent *BTSession; bittorrent *BTSession;
QList<torrent_handle> handles; QList<torrent_handle> handles;
}; };

4
src/bittorrent.cpp

@ -594,6 +594,10 @@ void bittorrent::setDownloadRateLimit(int rate){
s->set_download_rate_limit(rate); s->set_download_rate_limit(rate);
} }
session* bittorrent::getSession() const{
return s;
}
// Set upload rate limit // Set upload rate limit
// -1 to disable // -1 to disable
void bittorrent::setUploadRateLimit(int rate){ void bittorrent::setUploadRateLimit(int rate){

1
src/bittorrent.h

@ -85,6 +85,7 @@ class bittorrent : public QObject{
long getETA(QString hash) const; long getETA(QString hash) const;
size_type torrentEffectiveSize(QString hash) const; size_type torrentEffectiveSize(QString hash) const;
bool inFullAllocationMode(const QString& hash) const; bool inFullAllocationMode(const QString& hash) const;
session* getSession() const;
public slots: public slots:
void addTorrent(const QString& path, bool fromScanDir = false, bool onStartup = false, const QString& from_url = QString()); void addTorrent(const QString& path, bool fromScanDir = false, bool onStartup = false, const QString& from_url = QString());

Loading…
Cancel
Save