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 @@ @@ -19,6 +19,8 @@
- 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: 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
- BUGFIX: Progress of paused torrents is now correct on restart
- BUGFIX: Progress column gets sorted on restart it is was during last execution

3
TODO

@ -43,4 +43,5 @@ @@ -43,4 +43,5 @@
- Fix all (or almost all) opened bugs in bug tracker
- Fix sorting with Qt 4.3 - Reported to Trolltech, waiting for fix
- 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){ @@ -101,6 +101,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
actionPreview_file->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/preview.png")));
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.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")));
connecStatusLblIcon = new QLabel();
connecStatusLblIcon->setFrameShape(QFrame::NoFrame);
@ -340,6 +342,16 @@ void GUI::on_actionSet_upload_limit_triggered(){ @@ -340,6 +342,16 @@ void GUI::on_actionSet_upload_limit_triggered(){
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(){
if(tabs->currentIndex() > 1) return;
bool inDownloadList = true;
@ -506,6 +518,9 @@ void GUI::updateDlList(bool force){ @@ -506,6 +518,9 @@ void GUI::updateDlList(bool force){
if(torrentStatus.state != torrent_status::checking_files && torrentStatus.state != torrent_status::queued_for_checking){
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, STATUS), QVariant(tr("Paused")));
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(":/Icons/skin/paused.png")), Qt::DecorationRole);
setRowColor(row, "red");
BTSession.pauseTorrent(fileHash);
continue;
}
@ -816,6 +831,7 @@ void GUI::closeEvent(QCloseEvent *e){ @@ -816,6 +831,7 @@ void GUI::closeEvent(QCloseEvent *e){
return;
}
}
hide();
// Save DHT entry
BTSession.saveDHTEntry();
// Save window size, columns size
@ -1572,6 +1588,9 @@ void GUI::createTrayIcon(){ @@ -1572,6 +1588,9 @@ void GUI::createTrayIcon(){
myTrayIconMenu->addAction(actionOpen);
myTrayIconMenu->addAction(actionDownload_from_URL);
myTrayIconMenu->addSeparator();
myTrayIconMenu->addAction(actionSet_global_download_limit);
myTrayIconMenu->addAction(actionSet_global_upload_limit);
myTrayIconMenu->addSeparator();
myTrayIconMenu->addAction(actionStart_All);
myTrayIconMenu->addAction(actionPause_All);
myTrayIconMenu->addSeparator();

2
src/GUI.h

@ -140,6 +140,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{ @@ -140,6 +140,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{
void on_actionDelete_triggered();
void on_actionSet_download_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 checkConnectionStatus();
void configureSession(bool deleteOptions);

112
src/MainWindow.ui

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

40
src/allocationDlg.h

@ -21,6 +21,7 @@ @@ -21,6 +21,7 @@
#include <QDialog>
#include <QList>
#include <QSettings>
#include "ui_bandwidth_limit.h"
#include "misc.h"
#include "bittorrent.h"
@ -34,12 +35,18 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { @@ -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){
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){
QString hash;
foreach(hash, hashes){
torrent_handle h = BTSession->getTorrentHandle(hash);
@ -75,6 +82,22 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { @@ -75,6 +82,22 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
limit_lbl->setText(tr("Unlimited", "Unlimited (bandwidth)"));
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()));
show();
}
@ -96,23 +119,36 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg { @@ -96,23 +119,36 @@ class BandwidthAllocationDialog : public QDialog, private Ui_bandwidth_dlg {
void setBandwidth(){
int val = bandwidthSlider->value();
if(!global){
torrent_handle h;
if(uploadMode) {
foreach(h, handles) {
h.set_upload_limit(val);
h.set_upload_limit(val*1024);
qDebug("Setting upload limit");
}
} else {
foreach(h, handles) {
h.set_download_limit(val);
h.set_download_limit(val*1024);
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();
}
private:
bool uploadMode;
bool global;
bittorrent *BTSession;
QList<torrent_handle> handles;
};

4
src/bittorrent.cpp

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

1
src/bittorrent.h

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

Loading…
Cancel
Save