mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-27 15:04:36 +00:00
- Queueing systems now updates the number of active torrents in tab titles
This commit is contained in:
parent
4b8532ea2d
commit
15ce9a7369
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(torrent_ratio_deleted(QString)), this, SLOT(deleteRatioTorrent(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");
|
||||
tabs = new QTabWidget();
|
||||
// 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(")"));
|
||||
}
|
||||
|
||||
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) {
|
||||
unsigned int paused = BTSession->getFinishedPausedTorrentsNb();
|
||||
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
|
||||
void GUI::torrentDoubleClicked(QString hash, bool finished) {
|
||||
int action;
|
||||
|
@ -124,6 +124,8 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
||||
void readSettings();
|
||||
void on_actionExit_triggered();
|
||||
void createTrayIcon();
|
||||
void updateUnfinishedTorrentNumberCalc();
|
||||
void updateFinishedTorrentNumberCalc();
|
||||
void updateUnfinishedTorrentNumber(unsigned int nb);
|
||||
void updateFinishedTorrentNumber(unsigned int nb);
|
||||
void fullDiskError(QTorrentHandle& h) const;
|
||||
|
@ -370,6 +370,7 @@ int bittorrent::getUpTorrentPriority(QString hash) const {
|
||||
|
||||
void bittorrent::updateUploadQueue() {
|
||||
Q_ASSERT(queueingEnabled);
|
||||
bool change = false;
|
||||
int maxActiveUploads = maxActiveTorrents - currentActiveDownloads;
|
||||
int currentActiveUploads = 0;
|
||||
// Check if it is necessary to queue uploads
|
||||
@ -381,6 +382,7 @@ void bittorrent::updateUploadQueue() {
|
||||
} else {
|
||||
// Queue it
|
||||
h.pause();
|
||||
change = true;
|
||||
if(!queuedUploads->contains(hash)) {
|
||||
queuedUploads->append(hash);
|
||||
// Create .queued file
|
||||
@ -395,6 +397,7 @@ void bittorrent::updateUploadQueue() {
|
||||
if(currentActiveUploads < maxActiveUploads && isUploadQueued(hash)) {
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
h.resume();
|
||||
change = true;
|
||||
queuedUploads->removeAll(hash);
|
||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
||||
++currentActiveUploads;
|
||||
@ -408,6 +411,7 @@ void bittorrent::updateUploadQueue() {
|
||||
if(uploadQueue->contains(hash)) {
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
h.resume();
|
||||
change = true;
|
||||
queuedUploads->removeAll(hash);
|
||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
||||
++currentActiveUploads;
|
||||
@ -417,10 +421,13 @@ void bittorrent::updateUploadQueue() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(change)
|
||||
emit updateFinishedTorrentNumber();
|
||||
}
|
||||
|
||||
void bittorrent::updateDownloadQueue() {
|
||||
Q_ASSERT(queueingEnabled);
|
||||
bool change = false;
|
||||
currentActiveDownloads = 0;
|
||||
// Check if it is necessary to queue torrents
|
||||
foreach(QString hash, *downloadQueue) {
|
||||
@ -431,6 +438,7 @@ void bittorrent::updateDownloadQueue() {
|
||||
} else {
|
||||
// Queue it
|
||||
h.pause();
|
||||
change = true;
|
||||
if(!queuedDownloads->contains(hash)) {
|
||||
queuedDownloads->append(hash);
|
||||
// Create .queued file
|
||||
@ -445,6 +453,7 @@ void bittorrent::updateDownloadQueue() {
|
||||
if(currentActiveDownloads < maxActiveDownloads && isDownloadQueued(hash)) {
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
h.resume();
|
||||
change = true;
|
||||
queuedDownloads->removeAll(hash);
|
||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
||||
++currentActiveDownloads;
|
||||
@ -458,6 +467,7 @@ void bittorrent::updateDownloadQueue() {
|
||||
if(downloadQueue->contains(hash)) {
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
h.resume();
|
||||
change = true;
|
||||
queuedDownloads->removeAll(hash);
|
||||
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
|
||||
++currentActiveDownloads;
|
||||
@ -467,6 +477,8 @@ void bittorrent::updateDownloadQueue() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(change)
|
||||
emit updateUnfinishedTorrentNumber();
|
||||
}
|
||||
|
||||
// Calculate the ETA using GASA
|
||||
|
@ -208,6 +208,8 @@ class bittorrent : public QObject{
|
||||
void torrent_ratio_deleted(QString fileName);
|
||||
void UPnPError(QString msg);
|
||||
void UPnPSuccess(QString msg);
|
||||
void updateFinishedTorrentNumber();
|
||||
void updateUnfinishedTorrentNumber();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user