Browse Source

- extending Queueing system to seeding list (unfinished)

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
20ae3d997c
  1. 3
      src/FinishedListDelegate.h
  2. 33
      src/FinishedTorrents.cpp
  3. 2
      src/FinishedTorrents.h
  4. 17
      src/GUI.cpp
  5. 227
      src/bittorrent.cpp
  6. 24
      src/bittorrent.h
  7. 7
      src/downloadingTorrents.cpp
  8. 253
      src/options.ui
  9. 11
      src/options_imp.cpp
  10. 1
      src/options_imp.h
  11. 5
      src/seeding.ui

3
src/FinishedListDelegate.h

@ -37,7 +37,8 @@ @@ -37,7 +37,8 @@
#define F_UPSPEED 2
#define F_LEECH 3
#define F_RATIO 4
#define F_HASH 5
#define F_PRIORITY 5
#define F_HASH 6
class FinishedListDelegate: public QItemDelegate {
Q_OBJECT

33
src/FinishedTorrents.cpp

@ -38,14 +38,17 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par @@ -38,14 +38,17 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png")));
connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), this, SLOT(torrentAdded(QString, QTorrentHandle&, bool)));
finishedListModel = new QStandardItemModel(0,6);
finishedListModel = new QStandardItemModel(0,7);
finishedListModel->setHeaderData(F_NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
finishedListModel->setHeaderData(F_SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
finishedListModel->setHeaderData(F_UPSPEED, Qt::Horizontal, tr("UP Speed", "i.e: Upload speed"));
finishedListModel->setHeaderData(F_LEECH, Qt::Horizontal, tr("Leechers", "i.e: full/partial sources"));
finishedListModel->setHeaderData(F_RATIO, Qt::Horizontal, tr("Ratio"));
finishedListModel->setHeaderData(F_PRIORITY, Qt::Horizontal, tr("Priority"));
finishedList->setModel(finishedListModel);
loadHiddenColumns();
// Hide priority column
finishedList->hideColumn(F_PRIORITY);
// Hide hash column
finishedList->hideColumn(F_HASH);
// Load last columns width for download list
@ -82,6 +85,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par @@ -82,6 +85,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
connect(actionHOSColUpSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpSpeed()));
connect(actionHOSColLeechers, SIGNAL(triggered()), this, SLOT(hideOrShowColumnLeechers()));
connect(actionHOSColRatio, SIGNAL(triggered()), this, SLOT(hideOrShowColumnRatio()));
connect(actionHOSColPriority, SIGNAL(triggered()), this, SLOT(hideOrShowColumnPriority()));
}
FinishedTorrents::~FinishedTorrents(){
@ -97,6 +101,10 @@ void FinishedTorrents::notifyTorrentDoubleClicked(const QModelIndex& index) { @@ -97,6 +101,10 @@ void FinishedTorrents::notifyTorrentDoubleClicked(const QModelIndex& index) {
emit torrentDoubleClicked(hash, true);
}
void FinishedTorrents::hidePriorityColumn(bool hide) {
finishedList->setColumnHidden(F_PRIORITY, hide);
}
void FinishedTorrents::addTorrent(QString hash){
if(!BTSession->isFinished(hash)){
BTSession->setFinishedTorrent(hash);
@ -112,6 +120,8 @@ void FinishedTorrents::addTorrent(QString hash){ @@ -112,6 +120,8 @@ void FinishedTorrents::addTorrent(QString hash){
finishedListModel->setData(finishedListModel->index(row, F_UPSPEED), QVariant((double)0.));
finishedListModel->setData(finishedListModel->index(row, F_LEECH), QVariant("0"));
finishedListModel->setData(finishedListModel->index(row, F_RATIO), QVariant(QString::fromUtf8(misc::toString(BTSession->getRealRatio(hash)).c_str())));
if(BTSession->isQueueingEnabled())
finishedListModel->setData(finishedListModel->index(row, F_PRIORITY), QVariant((int)BTSession->getUpTorrentPriority(hash)));
finishedListModel->setData(finishedListModel->index(row, F_HASH), QVariant(hash));
if(h.is_paused()) {
finishedListModel->setData(finishedListModel->index(row, F_NAME), QIcon(":/Icons/skin/paused.png"), Qt::DecorationRole);
@ -237,6 +247,14 @@ void FinishedTorrents::updateFinishedList(){ @@ -237,6 +247,14 @@ void FinishedTorrents::updateFinishedList(){
row = getRowFromHash(hash);
}
Q_ASSERT(row != -1);
// Update priority
if(BTSession->isQueueingEnabled()) {
finishedListModel->setData(finishedListModel->index(row, F_PRIORITY), QVariant((int)BTSession->getDlTorrentPriority(hash)));
if(h.is_paused() && BTSession->isUploadQueued(hash)) {
finishedListModel->setData(finishedListModel->index(row, F_NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/queued.png"))), Qt::DecorationRole);
setRowColor(row, QString::fromUtf8("grey"));
}
}
if(h.is_paused()) continue;
if(BTSession->getTorrentsToPauseAfterChecking().indexOf(hash) != -1) {
continue;
@ -406,6 +424,12 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){ @@ -406,6 +424,12 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
void FinishedTorrents::displayFinishedHoSMenu(const QPoint& pos){
QMenu hideshowColumn(this);
hideshowColumn.setTitle(tr("Hide or Show Column"));
int lastCol;
if(BTSession->isQueueingEnabled()) {
lastCol = F_PRIORITY;
} else {
lastCol = F_RATIO;
}
for(int i=0; i<=F_RATIO; i++) {
hideshowColumn.addAction(getActionHoSCol(i));
}
@ -464,6 +488,10 @@ void FinishedTorrents::hideOrShowColumnRatio() { @@ -464,6 +488,10 @@ void FinishedTorrents::hideOrShowColumnRatio() {
hideOrShowColumn(F_RATIO);
}
void FinishedTorrents::hideOrShowColumnPriority() {
hideOrShowColumn(F_PRIORITY);
}
// load the previous settings, and hide the columns
bool FinishedTorrents::loadHiddenColumns() {
bool loaded = false;
@ -525,6 +553,9 @@ QAction* FinishedTorrents::getActionHoSCol(int index) { @@ -525,6 +553,9 @@ QAction* FinishedTorrents::getActionHoSCol(int index) {
case F_RATIO :
return actionHOSColRatio;
break;
case F_PRIORITY :
return actionHOSColPriority;
break;
default :
return NULL;
}

2
src/FinishedTorrents.h

@ -72,6 +72,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding { @@ -72,6 +72,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
void hideOrShowColumnUpSpeed();
void hideOrShowColumnLeechers();
void hideOrShowColumnRatio();
void hideOrShowColumnPriority();
public slots:
void addTorrent(QString hash);
@ -81,6 +82,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding { @@ -81,6 +82,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
void propertiesSelection();
void deleteTorrent(QString hash);
void showPropertiesFromHash(QString hash);
void hidePriorityColumn(bool hide);
signals:
void torrentMovedFromFinishedList(QString);

17
src/GUI.cpp

@ -1112,15 +1112,22 @@ void GUI::configureSession(bool deleteOptions) { @@ -1112,15 +1112,22 @@ void GUI::configureSession(bool deleteOptions) {
}
// Queueing System
if(options->isQueueingSystemEnabled()) {
if(!BTSession->isDlQueueingEnabled()) {
BTSession->setMaxActiveDlTorrents(options->getMaxActiveDownloads());
BTSession->setDlQueueingEnabled(true);
if(!BTSession->isQueueingEnabled()) {
int max_torrents = options->getMaxActiveTorrents();
int max_downloads = options->getMaxActiveDownloads();
if(max_torrents < max_downloads)
max_torrents = max_downloads;
BTSession->setMaxActiveTorrents(max_torrents);
BTSession->setMaxActiveDownloads(max_downloads);
BTSession->setQueueingEnabled(true);
downloadingTorrentTab->hidePriorityColumn(false);
finishedTorrentTab->hidePriorityColumn(false);
}
} else {
if(BTSession->isDlQueueingEnabled()) {
BTSession->setDlQueueingEnabled(false);
if(BTSession->isQueueingEnabled()) {
BTSession->setQueueingEnabled(false);
downloadingTorrentTab->hidePriorityColumn(true);
finishedTorrentTab->hidePriorityColumn(true);
}
}
// Clean up

227
src/bittorrent.cpp

@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
#define MAX_TRACKER_ERRORS 2
// Main constructor
bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), max_ratio(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), folderScanInterval(5), dlQueueingEnabled(false) {
bittorrent::bittorrent() : timerScan(0), DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), max_ratio(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), folderScanInterval(5), queueingEnabled(false) {
// To avoid some exceptions
fs::path::default_name_check(fs::no_check);
// Creating bittorrent session
@ -99,11 +99,15 @@ bittorrent::~bittorrent() { @@ -99,11 +99,15 @@ bittorrent::~bittorrent() {
if(filterParser != 0)
delete filterParser;
delete downloader;
if(dlQueueingEnabled) {
if(queueingEnabled) {
Q_ASSERT(downloadQueue);
delete downloadQueue;
Q_ASSERT(queuedDownloads);
delete queuedDownloads;
Q_ASSERT(uploadQueue);
delete uploadQueue;
Q_ASSERT(queuedUploads);
delete queuedUploads;
}
// Delete BT session
qDebug("Deleting session");
@ -154,12 +158,16 @@ void bittorrent::setDownloadLimit(QString hash, long val) { @@ -154,12 +158,16 @@ void bittorrent::setDownloadLimit(QString hash, long val) {
saveTorrentSpeedLimits(hash);
}
bool bittorrent::isDlQueueingEnabled() const {
return dlQueueingEnabled;
bool bittorrent::isQueueingEnabled() const {
return queueingEnabled;
}
void bittorrent::setMaxActiveDlTorrents(int val) {
maxActiveDlTorrents = val;
void bittorrent::setMaxActiveDownloads(int val) {
maxActiveDownloads = val;
}
void bittorrent::setMaxActiveTorrents(int val) {
maxActiveTorrents = val;
}
void bittorrent::increaseDlTorrentPriority(QString hash) {
@ -167,24 +175,46 @@ void bittorrent::increaseDlTorrentPriority(QString hash) { @@ -167,24 +175,46 @@ void bittorrent::increaseDlTorrentPriority(QString hash) {
Q_ASSERT(index != -1);
if(index > 0) {
downloadQueue->swap(index-1, index);
saveDlTorrentPriority(hash, index-1);
saveDlTorrentPriority(downloadQueue->at(index), index);
saveTorrentPriority(hash, index-1);
saveTorrentPriority(downloadQueue->at(index), index);
updateDownloadQueue();
}
}
void bittorrent::increaseUpTorrentPriority(QString hash) {
int index = uploadQueue->indexOf(hash);
Q_ASSERT(index != -1);
if(index > 0) {
uploadQueue->swap(index-1, index);
saveTorrentPriority(hash, index-1);
saveTorrentPriority(uploadQueue->at(index), index);
updateUploadQueue();
}
}
void bittorrent::decreaseDlTorrentPriority(QString hash) {
int index = downloadQueue->indexOf(hash);
Q_ASSERT(index != -1);
if(index >= 0 && index < (downloadQueue->size()-1)) {
downloadQueue->swap(index+1, index);
saveDlTorrentPriority(hash, index+1);
saveDlTorrentPriority(downloadQueue->at(index), index);
saveTorrentPriority(hash, index+1);
saveTorrentPriority(downloadQueue->at(index), index);
updateDownloadQueue();
}
}
void bittorrent::saveDlTorrentPriority(QString hash, int prio) {
void bittorrent::decreaseUpTorrentPriority(QString hash) {
int index = uploadQueue->indexOf(hash);
Q_ASSERT(index != -1);
if(index >= 0 && index < (uploadQueue->size()-1)) {
uploadQueue->swap(index+1, index);
saveTorrentPriority(hash, index+1);
saveTorrentPriority(uploadQueue->at(index), index);
updateUploadQueue();
}
}
void bittorrent::saveTorrentPriority(QString hash, int prio) {
// Write .queued file
QFile prio_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
prio_file.open(QIODevice::WriteOnly | QIODevice::Text);
@ -192,7 +222,7 @@ void bittorrent::saveDlTorrentPriority(QString hash, int prio) { @@ -192,7 +222,7 @@ void bittorrent::saveDlTorrentPriority(QString hash, int prio) {
prio_file.close();
}
int bittorrent::loadDlTorrentPriority(QString hash) {
int bittorrent::loadTorrentPriority(QString hash) {
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio")) {
// Read .queued file
QFile prio_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
@ -212,10 +242,15 @@ int bittorrent::loadDlTorrentPriority(QString hash) { @@ -212,10 +242,15 @@ int bittorrent::loadDlTorrentPriority(QString hash) {
}
bool bittorrent::isDownloadQueued(QString hash) const {
Q_ASSERT(dlQueueingEnabled);
Q_ASSERT(queueingEnabled);
return queuedDownloads->contains(hash);
}
bool bittorrent::isUploadQueued(QString hash) const {
Q_ASSERT(queueingEnabled);
return queuedUploads->contains(hash);
}
void bittorrent::setUploadLimit(QString hash, long val) {
qDebug("Set upload limit rate to %ld", val);
QTorrentHandle h = getTorrentHandle(hash);
@ -232,16 +267,16 @@ void bittorrent::startTorrentsInPause(bool b) { @@ -232,16 +267,16 @@ void bittorrent::startTorrentsInPause(bool b) {
addInPause = b;
}
void bittorrent::setDlQueueingEnabled(bool enable) {
if(dlQueueingEnabled != enable) {
dlQueueingEnabled = enable;
void bittorrent::setQueueingEnabled(bool enable) {
if(queueingEnabled != enable) {
queueingEnabled = enable;
if(enable) {
// Load priorities
QList<QPair<int, QString> > tmp_list;
QStringList noprio;
QStringList finished = getUnfinishedTorrents();
foreach(QString hash, finished) {
int prio = loadDlTorrentPriority(hash);
QStringList unfinished = getUnfinishedTorrents();
foreach(QString hash, unfinished) {
int prio = loadTorrentPriority(hash);
if(prio != -1) {
misc::insertSort2<QString>(tmp_list, QPair<int,QString>(prio,hash), Qt::AscendingOrder);
} else {
@ -257,16 +292,45 @@ void bittorrent::setDlQueueingEnabled(bool enable) { @@ -257,16 +292,45 @@ void bittorrent::setDlQueueingEnabled(bool enable) {
// save priorities
int i=0;
foreach(QString hash, *downloadQueue) {
saveDlTorrentPriority(hash, i);
saveTorrentPriority(hash, i);
++i;
}
queuedDownloads = new QStringList();
updateDownloadQueue();
QList<QPair<int, QString> > tmp_list2;
QStringList noprio2;
QStringList finished = getFinishedTorrents();
foreach(QString hash, finished) {
int prio = loadTorrentPriority(hash);
if(prio != -1) {
misc::insertSort2<QString>(tmp_list2, QPair<int,QString>(prio,hash), Qt::AscendingOrder);
} else {
noprio2 << hash;
}
}
uploadQueue = new QStringList();
QPair<int,QString> couple2;
foreach(couple2, tmp_list2) {
uploadQueue->append(couple2.second);
}
(*uploadQueue)<<noprio;
// save priorities
int j=0;
foreach(QString hash, *uploadQueue) {
saveTorrentPriority(hash, j);
++j;
}
queuedUploads = new QStringList();
updateUploadQueue();
} else {
delete downloadQueue;
downloadQueue = 0;
delete queuedDownloads;
queuedDownloads = 0;
delete uploadQueue;
uploadQueue = 0;
delete queuedUploads;
queuedUploads = 0;
}
}
}
@ -276,15 +340,71 @@ int bittorrent::getDlTorrentPriority(QString hash) const { @@ -276,15 +340,71 @@ int bittorrent::getDlTorrentPriority(QString hash) const {
return downloadQueue->indexOf(hash);
}
int bittorrent::getUpTorrentPriority(QString hash) const {
Q_ASSERT(uploadQueue != 0);
return uploadQueue->indexOf(hash);
}
void bittorrent::updateUploadQueue() {
Q_ASSERT(queueingEnabled);
int maxActiveUploads = maxActiveTorrents - currentActiveDownloads;
int currentActiveUploads = 0;
// Check if it is necessary to queue uploads
foreach(QString hash, *uploadQueue) {
QTorrentHandle h = getTorrentHandle(hash);
if(!h.is_paused()) {
if(currentActiveUploads < maxActiveUploads) {
++currentActiveUploads;
} else {
// Queue it
h.pause();
if(!queuedUploads->contains(hash)) {
queuedUploads->append(hash);
// Create .queued file
if(!QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued")) {
QFile queued_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
queued_file.open(QIODevice::WriteOnly | QIODevice::Text);
queued_file.close();
}
}
}
} else {
if(currentActiveUploads < maxActiveUploads && isUploadQueued(hash)) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
queuedUploads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveUploads;
}
}
}
if(currentActiveUploads < maxActiveUploads) {
// Could not fill download slots, unqueue torrents
foreach(QString hash, *uploadQueue) {
if(uploadQueue->size() != 0 && currentActiveUploads < maxActiveUploads) {
if(uploadQueue->contains(hash)) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
queuedUploads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveUploads;
}
} else {
break;
}
}
}
}
void bittorrent::updateDownloadQueue() {
Q_ASSERT(dlQueueingEnabled);
int currentActiveTorrents = 0;
Q_ASSERT(queueingEnabled);
currentActiveDownloads = 0;
// Check if it is necessary to queue torrents
foreach(QString hash, *downloadQueue) {
QTorrentHandle h = getTorrentHandle(hash);
if(!h.is_paused()) {
if(currentActiveTorrents < maxActiveDlTorrents) {
++currentActiveTorrents;
if(currentActiveDownloads < maxActiveDownloads) {
++currentActiveDownloads;
} else {
// Queue it
h.pause();
@ -299,25 +419,25 @@ void bittorrent::updateDownloadQueue() { @@ -299,25 +419,25 @@ void bittorrent::updateDownloadQueue() {
}
}
} else {
if(currentActiveTorrents < maxActiveDlTorrents && isDownloadQueued(hash)) {
if(currentActiveDownloads < maxActiveDownloads && isDownloadQueued(hash)) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
queuedDownloads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveTorrents;
++currentActiveDownloads;
}
}
}
if(currentActiveTorrents < maxActiveDlTorrents) {
if(currentActiveDownloads < maxActiveDownloads) {
// Could not fill download slots, unqueue torrents
foreach(QString hash, *downloadQueue) {
if(downloadQueue->size() != 0 && currentActiveTorrents < maxActiveDlTorrents) {
if(downloadQueue->size() != 0 && currentActiveDownloads < maxActiveDownloads) {
if(downloadQueue->contains(hash)) {
QTorrentHandle h = getTorrentHandle(hash);
h.resume();
queuedDownloads->removeAll(hash);
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
++currentActiveTorrents;
++currentActiveDownloads;
}
} else {
break;
@ -438,14 +558,23 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) { @@ -438,14 +558,23 @@ void bittorrent::deleteTorrent(QString hash, bool permanent) {
std::cerr << "Error: Torrent " << hash.toStdString() << " is neither in finished or unfinished list\n";
}
}
// Remove it from downloadQueue
if(dlQueueingEnabled) {
downloadQueue->removeAll(hash);
queuedDownloads->removeAll(hash);
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
updateDownloadQueue();
// Remove it from downloadQueue or UploadQueue
if(queueingEnabled) {
if(downloadQueue->contains(hash)) {
downloadQueue->removeAll(hash);
queuedDownloads->removeAll(hash);
updateDownloadQueue();
}
if(uploadQueue->contains(hash)) {
uploadQueue->removeAll(hash);
queuedUploads->removeAll(hash);
updateUploadQueue();
}
}
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
if(permanent && files_arb != 0) {
// Remove from Hard drive
qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName));
@ -484,10 +613,10 @@ void bittorrent::setUnfinishedTorrent(QString hash) { @@ -484,10 +613,10 @@ void bittorrent::setUnfinishedTorrent(QString hash) {
TorrentsStartTime[hash] = QDateTime::currentDateTime();
}
// Add it to downloadQueue
if(dlQueueingEnabled) {
if(queueingEnabled) {
if(!downloadQueue->contains(hash)) {
downloadQueue->append(hash);
saveDlTorrentPriority(hash, downloadQueue->size()-1);
saveTorrentPriority(hash, downloadQueue->size()-1);
updateDownloadQueue();
}
}
@ -511,12 +640,16 @@ void bittorrent::setFinishedTorrent(QString hash) { @@ -511,12 +640,16 @@ void bittorrent::setFinishedTorrent(QString hash) {
TorrentsStartTime.remove(hash);
TorrentsStartData.remove(hash);
// Remove it from downloadQueue
if(dlQueueingEnabled) {
if(queueingEnabled) {
downloadQueue->removeAll(hash);
queuedDownloads->removeAll(hash);
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
updateDownloadQueue();
uploadQueue->append(hash);
updateUploadQueue();
}
// Save fast resume data
saveFastResumeAndRatioData(hash);
@ -549,6 +682,13 @@ bool bittorrent::pauseTorrent(QString hash) { @@ -549,6 +682,13 @@ bool bittorrent::pauseTorrent(QString hash) {
// Remove it from TorrentsStartTime hash table
TorrentsStartTime.remove(hash);
TorrentsStartData.remove(hash);
// Remove it from queued list if present
if(queuedDownloads->contains(hash))
queuedDownloads->removeAll(hash);
if(queuedUploads->contains(hash))
queuedUploads->removeAll(hash);
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"))
QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
return change;
}
@ -744,12 +884,17 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo @@ -744,12 +884,17 @@ void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bo
h.resume();
if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) {
finishedTorrents << hash;
if(queueingEnabled) {
uploadQueue->append(hash);
saveTorrentPriority(hash, uploadQueue->size()-1);
updateUploadQueue();
}
}else{
unfinishedTorrents << hash;
// Add it to downloadQueue
if(dlQueueingEnabled) {
if(queueingEnabled) {
downloadQueue->append(hash);
saveDlTorrentPriority(hash, downloadQueue->size()-1);
saveTorrentPriority(hash, downloadQueue->size()-1);
updateDownloadQueue();
}
}

24
src/bittorrent.h

@ -70,10 +70,14 @@ class bittorrent : public QObject{ @@ -70,10 +70,14 @@ class bittorrent : public QObject{
FilterParserThread *filterParser;
QString filterPath;
int folderScanInterval; // in seconds
bool dlQueueingEnabled;
int maxActiveDlTorrents;
bool queueingEnabled;
int maxActiveDownloads;
int maxActiveTorrents;
int currentActiveDownloads;
QStringList *downloadQueue;
QStringList *queuedDownloads;
QStringList *uploadQueue;
QStringList *queuedUploads;
protected:
QString getSavePath(QString hash);
@ -101,10 +105,12 @@ class bittorrent : public QObject{ @@ -101,10 +105,12 @@ class bittorrent : public QObject{
bool has_filtered_files(QString hash) const;
unsigned int getFinishedPausedTorrentsNb() const;
unsigned int getUnfinishedPausedTorrentsNb() const;
bool isDlQueueingEnabled() const;
bool isQueueingEnabled() const;
int getDlTorrentPriority(QString hash) const;
int getUpTorrentPriority(QString hash) const;
bool isDownloadQueued(QString hash) const;
int loadDlTorrentPriority(QString hash);
bool isUploadQueued(QString hash) const;
int loadTorrentPriority(QString hash);
public slots:
void addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
@ -124,7 +130,7 @@ class bittorrent : public QObject{ @@ -124,7 +130,7 @@ class bittorrent : public QObject{
void enablePeerExchange();
void enableIPFilter(QString filter);
void disableIPFilter();
void setDlQueueingEnabled(bool enable);
void setQueueingEnabled(bool enable);
void resumeUnfinishedTorrents();
void saveTorrentSpeedLimits(QString hash);
void loadTorrentSpeedLimits(QString hash);
@ -133,9 +139,12 @@ class bittorrent : public QObject{ @@ -133,9 +139,12 @@ class bittorrent : public QObject{
void handleDownloadFailure(QString url, QString reason);
void loadWebSeeds(QString fileHash);
void updateDownloadQueue();
void updateUploadQueue();
void increaseDlTorrentPriority(QString hash);
void decreaseDlTorrentPriority(QString hash);
void saveDlTorrentPriority(QString hash, int prio);
void increaseUpTorrentPriority(QString hash);
void decreaseUpTorrentPriority(QString hash);
void saveTorrentPriority(QString hash, int prio);
// Session configuration - Setters
void setListeningPortsRange(std::pair<unsigned short, unsigned short> ports);
void setMaxConnections(int maxConnec);
@ -162,7 +171,8 @@ class bittorrent : public QObject{ @@ -162,7 +171,8 @@ class bittorrent : public QObject{
bool enableDHT(bool b);
void reloadTorrent(const QTorrentHandle &h, bool full_alloc);
void setTimerScanInterval(int secs);
void setMaxActiveDlTorrents(int val);
void setMaxActiveDownloads(int val);
void setMaxActiveTorrents(int val);
protected slots:
void scanDirectory();

7
src/downloadingTorrents.cpp

@ -335,7 +335,7 @@ void DownloadingTorrents::displayDLHoSMenu(const QPoint& pos){ @@ -335,7 +335,7 @@ void DownloadingTorrents::displayDLHoSMenu(const QPoint& pos){
QMenu hideshowColumn(this);
hideshowColumn.setTitle(tr("Hide or Show Column"));
int lastCol;
if(BTSession->isDlQueueingEnabled()) {
if(BTSession->isQueueingEnabled()) {
lastCol = PRIORITY;
} else {
lastCol = ETA;
@ -552,10 +552,9 @@ void DownloadingTorrents::updateDlList() { @@ -552,10 +552,9 @@ void DownloadingTorrents::updateDlList() {
}
Q_ASSERT(row != -1);
// Update Priority
if(BTSession->isDlQueueingEnabled()) {
if(BTSession->isQueueingEnabled()) {
DLListModel->setData(DLListModel->index(row, PRIORITY), QVariant((int)BTSession->getDlTorrentPriority(hash)));
if(h.is_paused() && BTSession->isDownloadQueued(hash)) {
qDebug("Download queued");
DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/queued.png"))), Qt::DecorationRole);
if(!downloadList->isColumnHidden(ETA)) {
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
@ -672,7 +671,7 @@ void DownloadingTorrents::addTorrent(QString hash) { @@ -672,7 +671,7 @@ void DownloadingTorrents::addTorrent(QString hash) {
DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)0.));
DLListModel->setData(DLListModel->index(row, SEEDSLEECH), QVariant(QString::fromUtf8("0/0")));
DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
if(BTSession->isDlQueueingEnabled())
if(BTSession->isQueueingEnabled())
DLListModel->setData(DLListModel->index(row, PRIORITY), QVariant((int)BTSession->getDlTorrentPriority(hash)));
DLListModel->setData(DLListModel->index(row, HASH), QVariant(hash));
// Pause torrent if it was paused last time

253
src/options.ui

@ -22,7 +22,16 @@ @@ -22,7 +22,16 @@
<property name="spacing" >
<number>6</number>
</property>
<property name="margin" >
<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>
@ -74,20 +83,11 @@ @@ -74,20 +83,11 @@
<enum>Qt::ElideLeft</enum>
</property>
<widget class="QWidget" name="tab" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" >
<string>General</string>
</attribute>
<attribute name="icon" >
<iconset resource="icons.qrc" >
<normaloff>:/Icons/star.png</normaloff>:/Icons/star.png</iconset>
<iconset resource="icons.qrc" >:/Icons/star.png</iconset>
</attribute>
<layout class="QVBoxLayout" >
<item>
@ -120,7 +120,7 @@ @@ -120,7 +120,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -189,7 +189,7 @@ @@ -189,7 +189,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -250,7 +250,7 @@ @@ -250,7 +250,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -318,7 +318,7 @@ @@ -318,7 +318,7 @@
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>623</width>
<height>20</height>
@ -329,22 +329,13 @@ @@ -329,22 +329,13 @@
</layout>
</widget>
<widget class="QWidget" name="tab_5" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" >
<string>Downloads</string>
</attribute>
<attribute name="icon" >
<iconset resource="icons.qrc" >
<normaloff>:/Icons/download.png</normaloff>:/Icons/download.png</iconset>
<iconset resource="icons.qrc" >:/Icons/download.png</iconset>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4" >
<layout class="QVBoxLayout" >
<item>
<widget class="QGroupBox" name="fileSystemBox" >
<property name="sizePolicy" >
@ -369,7 +360,16 @@ @@ -369,7 +360,16 @@
<property name="spacing" >
<number>6</number>
</property>
<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>
@ -377,7 +377,16 @@ @@ -377,7 +377,16 @@
<property name="spacing" >
<number>6</number>
</property>
<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>
@ -419,9 +428,9 @@ @@ -419,9 +428,9 @@
<property name="title" >
<string>When adding a torrent</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" >
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<layout class="QHBoxLayout" >
<item>
<widget class="QCheckBox" name="checkAdditionDialog" >
<property name="text" >
@ -433,11 +442,11 @@ @@ -433,11 +442,11 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -468,7 +477,7 @@ @@ -468,7 +477,7 @@
<property name="title" >
<string comment="qBittorrent will watch a directory and automatically download torrents present in it" >Folder watching</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="checkScanDir" >
<property name="text" >
@ -481,7 +490,16 @@ @@ -481,7 +490,16 @@
<property name="spacing" >
<number>6</number>
</property>
<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>
@ -504,7 +522,7 @@ @@ -504,7 +522,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="FolderScanLbl" >
<property name="text" >
@ -591,7 +609,7 @@ @@ -591,7 +609,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -634,7 +652,7 @@ @@ -634,7 +652,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -650,20 +668,11 @@ @@ -650,20 +668,11 @@
</layout>
</widget>
<widget class="QWidget" name="tab_3" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" >
<string>Connection</string>
</attribute>
<attribute name="icon" >
<iconset resource="icons.qrc" >
<normaloff>:/Icons/connection.png</normaloff>:/Icons/connection.png</iconset>
<iconset resource="icons.qrc" >:/Icons/connection.png</iconset>
</attribute>
<layout class="QVBoxLayout" >
<item>
@ -726,7 +735,7 @@ @@ -726,7 +735,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>20</width>
<height>20</height>
@ -974,7 +983,7 @@ @@ -974,7 +983,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>21</width>
<height>29</height>
@ -1063,7 +1072,7 @@ @@ -1063,7 +1072,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -1165,20 +1174,11 @@ @@ -1165,20 +1174,11 @@
</layout>
</widget>
<widget class="QWidget" name="tab_6" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" >
<string>Bittorrent</string>
</attribute>
<attribute name="icon" >
<iconset resource="icons.qrc" >
<normaloff>:/Icons/bt_settings.png</normaloff>:/Icons/bt_settings.png</iconset>
<iconset resource="icons.qrc" >:/Icons/bt_settings.png</iconset>
</attribute>
<layout class="QVBoxLayout" >
<item>
@ -1225,7 +1225,7 @@ @@ -1225,7 +1225,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -1270,7 +1270,7 @@ @@ -1270,7 +1270,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -1312,7 +1312,7 @@ @@ -1312,7 +1312,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -1401,7 +1401,7 @@ @@ -1401,7 +1401,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -1464,7 +1464,7 @@ @@ -1464,7 +1464,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -1518,7 +1518,7 @@ @@ -1518,7 +1518,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -1536,7 +1536,7 @@ @@ -1536,7 +1536,7 @@
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
@ -1547,22 +1547,13 @@ @@ -1547,22 +1547,13 @@
</layout>
</widget>
<widget class="QWidget" name="tab_4" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" >
<string>Misc</string>
</attribute>
<attribute name="icon" >
<iconset resource="icons.qrc" >
<normaloff>:/Icons/configure.png</normaloff>:/Icons/configure.png</iconset>
<iconset resource="icons.qrc" >:/Icons/configure.png</iconset>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8" >
<layout class="QVBoxLayout" >
<item>
<widget class="QGroupBox" name="filterBox" >
<property name="enabled" >
@ -1571,20 +1562,19 @@ @@ -1571,20 +1562,19 @@
<property name="title" >
<string>Filter Settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="checkIPFilter" >
<property name="text" >
<string>Activate IP Filtering</string>
</property>
<property name="icon" >
<iconset resource="icons.qrc" >
<normaloff>:/Icons/filter.png</normaloff>:/Icons/filter.png</iconset>
<iconset resource="icons.qrc" >:/Icons/filter.png</iconset>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="lblFilterPath" >
<property name="enabled" >
@ -1622,7 +1612,7 @@ @@ -1622,7 +1612,7 @@
<property name="title" >
<string>RSS</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6" >
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="checkEnableRSS" >
<property name="text" >
@ -1638,7 +1628,7 @@ @@ -1638,7 +1628,7 @@
<property name="title" >
<string>RSS settings</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5" >
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
@ -1702,7 +1692,7 @@ @@ -1702,7 +1692,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -1736,7 +1726,7 @@ @@ -1736,7 +1726,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -1759,9 +1749,9 @@ @@ -1759,9 +1749,9 @@
<item>
<widget class="QGroupBox" name="groupQueueing" >
<property name="title" >
<string>Download queueing</string>
<string>Torrent queueing</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7" >
<layout class="QVBoxLayout" >
<item>
<widget class="QCheckBox" name="checkEnableQueueing" >
<property name="text" >
@ -1770,7 +1760,7 @@ @@ -1770,7 +1760,7 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4" >
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="label_max_active" >
<property name="enabled" >
@ -1798,11 +1788,11 @@ @@ -1798,11 +1788,11 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
@ -1812,18 +1802,61 @@ @@ -1812,18 +1802,61 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="maxActiveTorrents_lbl" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="text" >
<string>Maximum active torrents:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinMaxActiveTorrents" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="minimum" >
<number>1</number>
</property>
<property name="maximum" >
<number>999</number>
</property>
<property name="value" >
<number>5</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>381</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
<width>623</width>
<height>20</height>
</size>
</property>
</spacer>
@ -1831,20 +1864,11 @@ @@ -1831,20 +1864,11 @@
</layout>
</widget>
<widget class="QWidget" name="tab_2" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>641</width>
<height>457</height>
</rect>
</property>
<attribute name="title" >
<string>Web UI</string>
</attribute>
<attribute name="icon" >
<iconset resource="icons.qrc" >
<normaloff>:/Icons/password.png</normaloff>:/Icons/password.png</iconset>
<iconset resource="icons.qrc" >:/Icons/password.png</iconset>
</attribute>
<layout class="QVBoxLayout" >
<item>
@ -1897,7 +1921,7 @@ @@ -1897,7 +1921,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>21</width>
<height>29</height>
@ -1982,7 +2006,7 @@ @@ -1982,7 +2006,7 @@
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>198</width>
<height>57</height>
@ -1998,7 +2022,7 @@ @@ -1998,7 +2022,7 @@
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<property name="sizeHint" >
<size>
<width>623</width>
<height>41</height>
@ -2015,7 +2039,16 @@ @@ -2015,7 +2039,16 @@
<property name="spacing" >
<number>6</number>
</property>
<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>
@ -2024,7 +2057,7 @@ @@ -2024,7 +2057,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons" >
<bool>true</bool>

11
src/options_imp.cpp

@ -210,6 +210,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ @@ -210,6 +210,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
connect(checkEnableRSS, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(checkEnableQueueing, SIGNAL(stateChanged(int)), this, SLOT(enableApplyButton()));
connect(spinMaxActiveDownloads, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
connect(spinMaxActiveTorrents, SIGNAL(valueChanged(QString)), this, SLOT(enableApplyButton()));
// Web UI tab
connect(checkWebUi, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(spinWebUiPort, SIGNAL(valueChanged(int)), this, SLOT(enableApplyButton()));
@ -354,6 +355,7 @@ void options_imp::saveOptions(){ @@ -354,6 +355,7 @@ void options_imp::saveOptions(){
settings.beginGroup("Queueing");
settings.setValue(QString::fromUtf8("QueueingEnabled"), isQueueingSystemEnabled());
settings.setValue(QString::fromUtf8("MaxActiveDownloads"), spinMaxActiveDownloads->value());
settings.setValue(QString::fromUtf8("MaxActiveTorrents"), spinMaxActiveTorrents->value());
// End Queueing system preferences
settings.endGroup();
// Web UI
@ -635,6 +637,7 @@ void options_imp::loadOptions(){ @@ -635,6 +637,7 @@ void options_imp::loadOptions(){
if(isQueueingSystemEnabled()) {
enableQueueingSystem(2); // Enable
spinMaxActiveDownloads->setValue(settings.value(QString::fromUtf8("MaxActiveDownloads"), 3).toInt());
spinMaxActiveTorrents->setValue(settings.value(QString::fromUtf8("MaxActiveTorrents"), 5).toInt());
} else {
enableQueueingSystem(0); // Disable
}
@ -665,6 +668,10 @@ int options_imp::getMaxActiveDownloads() const { @@ -665,6 +668,10 @@ int options_imp::getMaxActiveDownloads() const {
return spinMaxActiveDownloads->value();
}
int options_imp::getMaxActiveTorrents() const {
return spinMaxActiveTorrents->value();
}
bool options_imp::minimizeToTray() const{
if(checkNoSystray->isChecked()) return false;
return checkMinimizeToSysTray->isChecked();
@ -855,10 +862,14 @@ void options_imp::enableQueueingSystem(int checkBoxValue) { @@ -855,10 +862,14 @@ void options_imp::enableQueueingSystem(int checkBoxValue) {
//Disable
spinMaxActiveDownloads->setEnabled(false);
label_max_active->setEnabled(false);
maxActiveTorrents_lbl->setEnabled(false);
spinMaxActiveTorrents->setEnabled(false);
}else{
//enable
spinMaxActiveDownloads->setEnabled(true);
label_max_active->setEnabled(true);
maxActiveTorrents_lbl->setEnabled(true);
spinMaxActiveTorrents->setEnabled(true);
}
}

1
src/options_imp.h

@ -110,6 +110,7 @@ class options_imp : public QDialog, private Ui::Dialog { @@ -110,6 +110,7 @@ class options_imp : public QDialog, private Ui::Dialog {
// Queueing system
bool isQueueingSystemEnabled() const;
int getMaxActiveDownloads() const;
int getMaxActiveTorrents() const;
bool isWebUiEnabled() const;
quint16 webUiPort() const;
QString webUiUsername() const;

5
src/seeding.ui

@ -134,6 +134,11 @@ @@ -134,6 +134,11 @@
<string>Buy it</string>
</property>
</action>
<action name="actionHOSColPriority" >
<property name="text" >
<string>Priority</string>
</property>
</action>
</widget>
<resources>
<include location="icons.qrc" />

Loading…
Cancel
Save