mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-13 16:53:08 -07:00
- Queueing systems now updates the number of active torrents in tab titles
This commit is contained in:
parent
4b8532ea2d
commit
15ce9a7369
4 changed files with 30 additions and 0 deletions
14
src/GUI.cpp
14
src/GUI.cpp
|
@ -133,6 +133,8 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
|
||||||
connect(BTSession, SIGNAL(deletedTorrent(QString)), this, SLOT(deleteTorrent(QString)));
|
connect(BTSession, SIGNAL(deletedTorrent(QString)), this, SLOT(deleteTorrent(QString)));
|
||||||
connect(BTSession, SIGNAL(torrent_ratio_deleted(QString)), this, SLOT(deleteRatioTorrent(QString)));
|
connect(BTSession, SIGNAL(torrent_ratio_deleted(QString)), this, SLOT(deleteRatioTorrent(QString)));
|
||||||
connect(BTSession, SIGNAL(pausedTorrent(QString)), this, SLOT(pauseTorrent(QString)));
|
connect(BTSession, SIGNAL(pausedTorrent(QString)), this, SLOT(pauseTorrent(QString)));
|
||||||
|
connect(BTSession, SIGNAL(updateUnfinishedTorrentNumber()), this, SLOT(updateUnfinishedTorrentNumberCalc()));
|
||||||
|
connect(BTSession, SIGNAL(updateFinishedTorrentNumber()), this, SLOT(updateFinishedTorrentNumberCalc()));
|
||||||
qDebug("create tabWidget");
|
qDebug("create tabWidget");
|
||||||
tabs = new QTabWidget();
|
tabs = new QTabWidget();
|
||||||
// Download torrents tab
|
// Download torrents tab
|
||||||
|
@ -1142,11 +1144,23 @@ void GUI::updateUnfinishedTorrentNumber(unsigned int nb) {
|
||||||
tabs->setTabText(0, tr("Downloads") +QString::fromUtf8(" (")+misc::toQString(nb-paused)+"/"+misc::toQString(nb)+QString::fromUtf8(")"));
|
tabs->setTabText(0, tr("Downloads") +QString::fromUtf8(" (")+misc::toQString(nb-paused)+"/"+misc::toQString(nb)+QString::fromUtf8(")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::updateUnfinishedTorrentNumberCalc() {
|
||||||
|
unsigned int paused = BTSession->getUnfinishedPausedTorrentsNb();
|
||||||
|
unsigned int nb = BTSession->getUnfinishedTorrents().size();
|
||||||
|
tabs->setTabText(0, tr("Downloads") +QString::fromUtf8(" (")+misc::toQString(nb-paused)+"/"+misc::toQString(nb)+QString::fromUtf8(")"));
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::updateFinishedTorrentNumber(unsigned int nb) {
|
void GUI::updateFinishedTorrentNumber(unsigned int nb) {
|
||||||
unsigned int paused = BTSession->getFinishedPausedTorrentsNb();
|
unsigned int paused = BTSession->getFinishedPausedTorrentsNb();
|
||||||
tabs->setTabText(1, tr("Finished") +QString::fromUtf8(" (")+misc::toQString(nb-paused)+"/"+misc::toQString(nb)+QString::fromUtf8(")"));
|
tabs->setTabText(1, tr("Finished") +QString::fromUtf8(" (")+misc::toQString(nb-paused)+"/"+misc::toQString(nb)+QString::fromUtf8(")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::updateFinishedTorrentNumberCalc() {
|
||||||
|
unsigned int paused = BTSession->getFinishedPausedTorrentsNb();
|
||||||
|
unsigned int nb = BTSession->getFinishedTorrents().size();
|
||||||
|
tabs->setTabText(1, tr("Finished") +QString::fromUtf8(" (")+misc::toQString(nb-paused)+"/"+misc::toQString(nb)+QString::fromUtf8(")"));
|
||||||
|
}
|
||||||
|
|
||||||
// Allow to change action on double-click
|
// Allow to change action on double-click
|
||||||
void GUI::torrentDoubleClicked(QString hash, bool finished) {
|
void GUI::torrentDoubleClicked(QString hash, bool finished) {
|
||||||
int action;
|
int action;
|
||||||
|
|
|
@ -124,6 +124,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void on_actionExit_triggered();
|
void on_actionExit_triggered();
|
||||||
void createTrayIcon();
|
void createTrayIcon();
|
||||||
|
void updateUnfinishedTorrentNumberCalc();
|
||||||
|
void updateFinishedTorrentNumberCalc();
|
||||||
void updateUnfinishedTorrentNumber(unsigned int nb);
|
void updateUnfinishedTorrentNumber(unsigned int nb);
|
||||||
void updateFinishedTorrentNumber(unsigned int nb);
|
void updateFinishedTorrentNumber(unsigned int nb);
|
||||||
void fullDiskError(QTorrentHandle& h) const;
|
void fullDiskError(QTorrentHandle& h) const;
|
||||||
|
|
|
@ -370,6 +370,7 @@ int bittorrent::getUpTorrentPriority(QString hash) const {
|
||||||
|
|
||||||
void bittorrent::updateUploadQueue() {
|
void bittorrent::updateUploadQueue() {
|
||||||
Q_ASSERT(queueingEnabled);
|
Q_ASSERT(queueingEnabled);
|
||||||
|
bool change = false;
|
||||||
int maxActiveUploads = maxActiveTorrents - currentActiveDownloads;
|
int maxActiveUploads = maxActiveTorrents - currentActiveDownloads;
|
||||||
int currentActiveUploads = 0;
|
int currentActiveUploads = 0;
|
||||||
// Check if it is necessary to queue uploads
|
// Check if it is necessary to queue uploads
|
||||||
|
@ -381,6 +382,7 @@ void bittorrent::updateUploadQueue() {
|
||||||
} else {
|
} else {
|
||||||
// Queue it
|
// Queue it
|
||||||
h.pause();
|
h.pause();
|
||||||
|
change = true;
|
||||||
if(!queuedUploads->contains(hash)) {
|
if(!queuedUploads->contains(hash)) {
|
||||||
queuedUploads->append(hash);
|
queuedUploads->append(hash);
|
||||||
// Create .queued file
|
// Create .queued file
|
||||||
|
@ -395,6 +397,7 @@ void bittorrent::updateUploadQueue() {
|
||||||
if(currentActiveUploads < maxActiveUploads && isUploadQueued(hash)) {
|
if(currentActiveUploads < maxActiveUploads && isUploadQueued(hash)) {
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
h.resume();
|
h.resume();
|
||||||
|
change = true;
|
||||||
queuedUploads->removeAll(hash);
|
queuedUploads->removeAll(hash);
|
||||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
||||||
++currentActiveUploads;
|
++currentActiveUploads;
|
||||||
|
@ -408,6 +411,7 @@ void bittorrent::updateUploadQueue() {
|
||||||
if(uploadQueue->contains(hash)) {
|
if(uploadQueue->contains(hash)) {
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
h.resume();
|
h.resume();
|
||||||
|
change = true;
|
||||||
queuedUploads->removeAll(hash);
|
queuedUploads->removeAll(hash);
|
||||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
||||||
++currentActiveUploads;
|
++currentActiveUploads;
|
||||||
|
@ -417,10 +421,13 @@ void bittorrent::updateUploadQueue() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(change)
|
||||||
|
emit updateFinishedTorrentNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
void bittorrent::updateDownloadQueue() {
|
void bittorrent::updateDownloadQueue() {
|
||||||
Q_ASSERT(queueingEnabled);
|
Q_ASSERT(queueingEnabled);
|
||||||
|
bool change = false;
|
||||||
currentActiveDownloads = 0;
|
currentActiveDownloads = 0;
|
||||||
// Check if it is necessary to queue torrents
|
// Check if it is necessary to queue torrents
|
||||||
foreach(QString hash, *downloadQueue) {
|
foreach(QString hash, *downloadQueue) {
|
||||||
|
@ -431,6 +438,7 @@ void bittorrent::updateDownloadQueue() {
|
||||||
} else {
|
} else {
|
||||||
// Queue it
|
// Queue it
|
||||||
h.pause();
|
h.pause();
|
||||||
|
change = true;
|
||||||
if(!queuedDownloads->contains(hash)) {
|
if(!queuedDownloads->contains(hash)) {
|
||||||
queuedDownloads->append(hash);
|
queuedDownloads->append(hash);
|
||||||
// Create .queued file
|
// Create .queued file
|
||||||
|
@ -445,6 +453,7 @@ void bittorrent::updateDownloadQueue() {
|
||||||
if(currentActiveDownloads < maxActiveDownloads && isDownloadQueued(hash)) {
|
if(currentActiveDownloads < maxActiveDownloads && isDownloadQueued(hash)) {
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
h.resume();
|
h.resume();
|
||||||
|
change = true;
|
||||||
queuedDownloads->removeAll(hash);
|
queuedDownloads->removeAll(hash);
|
||||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
||||||
++currentActiveDownloads;
|
++currentActiveDownloads;
|
||||||
|
@ -458,6 +467,7 @@ void bittorrent::updateDownloadQueue() {
|
||||||
if(downloadQueue->contains(hash)) {
|
if(downloadQueue->contains(hash)) {
|
||||||
QTorrentHandle h = getTorrentHandle(hash);
|
QTorrentHandle h = getTorrentHandle(hash);
|
||||||
h.resume();
|
h.resume();
|
||||||
|
change = true;
|
||||||
queuedDownloads->removeAll(hash);
|
queuedDownloads->removeAll(hash);
|
||||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
||||||
++currentActiveDownloads;
|
++currentActiveDownloads;
|
||||||
|
@ -467,6 +477,8 @@ void bittorrent::updateDownloadQueue() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(change)
|
||||||
|
emit updateUnfinishedTorrentNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the ETA using GASA
|
// Calculate the ETA using GASA
|
||||||
|
|
|
@ -208,6 +208,8 @@ class bittorrent : public QObject{
|
||||||
void torrent_ratio_deleted(QString fileName);
|
void torrent_ratio_deleted(QString fileName);
|
||||||
void UPnPError(QString msg);
|
void UPnPError(QString msg);
|
||||||
void UPnPSuccess(QString msg);
|
void UPnPSuccess(QString msg);
|
||||||
|
void updateFinishedTorrentNumber();
|
||||||
|
void updateUnfinishedTorrentNumber();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue