mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-26 19:26:59 +03:00
Use TorrentTempData for overriding "add torrents paused" functionality
This commit is contained in:
parent
f5048a4586
commit
9a87afb562
4 changed files with 32 additions and 10 deletions
|
@ -560,7 +560,6 @@ void AddNewTorrentDialog::accept()
|
|||
// TODO: Check if destination actually exists
|
||||
TorrentTempData::setSeedingMode(m_hash, true);
|
||||
}
|
||||
pref->addTorrentsInPause(!ui->start_torrent_cb->isChecked());
|
||||
|
||||
// Label
|
||||
const QString label = ui->label_combo->currentText();
|
||||
|
@ -575,6 +574,8 @@ void AddNewTorrentDialog::accept()
|
|||
if (m_hasRenamedFile)
|
||||
TorrentTempData::setFilesPath(m_hash, m_filesPath);
|
||||
|
||||
TorrentTempData::setAddPaused(m_hash, !ui->start_torrent_cb->isChecked());
|
||||
|
||||
// Add torrent
|
||||
if (m_isMagnet)
|
||||
QBtSession::instance()->unhideMagnet(m_hash);
|
||||
|
|
|
@ -995,7 +995,10 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed, bool f
|
|||
loadTorrentSettings(h);
|
||||
|
||||
// Load filtered files
|
||||
bool add_paused = pref->addTorrentsInPause();
|
||||
if (!resumed) {
|
||||
if (TorrentTempData::hasTempData(hash))
|
||||
add_paused = TorrentTempData::isAddPaused(hash);
|
||||
loadTorrentTempData(h, savePath, true);
|
||||
}
|
||||
if (HiddenData::hasData(hash) && pref->isQueueingSystemEnabled()) {
|
||||
|
@ -1014,7 +1017,7 @@ QTorrentHandle QBtSession::addMagnetUri(QString magnet_uri, bool resumed, bool f
|
|||
s->set_settings(sessionSettings);
|
||||
h.queue_position_top();
|
||||
}
|
||||
if (!pref->addTorrentsInPause() || HiddenData::hasData(hash)) {
|
||||
if (!add_paused || HiddenData::hasData(hash)) {
|
||||
// Start torrent because it was added in paused state
|
||||
h.resume();
|
||||
}
|
||||
|
@ -1182,8 +1185,12 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
|||
|
||||
loadTorrentSettings(h);
|
||||
|
||||
bool add_paused = pref->addTorrentsInPause();
|
||||
if (!resumed) {
|
||||
qDebug("This is a NEW torrent (first time)...");
|
||||
if (TorrentTempData::hasTempData(hash))
|
||||
add_paused = TorrentTempData::isAddPaused(hash);
|
||||
|
||||
loadTorrentTempData(h, savePath, false);
|
||||
|
||||
// Append .!qB to incomplete files
|
||||
|
@ -1199,7 +1206,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr
|
|||
exportTorrentFile(h);
|
||||
}
|
||||
|
||||
if (!fastResume && !pref->addTorrentsInPause()) {
|
||||
if (!fastResume && !add_paused) {
|
||||
// Start torrent because it was added in paused state
|
||||
h.resume();
|
||||
}
|
||||
|
@ -2912,10 +2919,7 @@ void QBtSession::processDownloadedFile(QString url, QString file_path) {
|
|||
emit newDownloadedTorrent(file_path, url);
|
||||
} else {
|
||||
url_skippingDlg.removeAt(index);
|
||||
QTorrentHandle h = addTorrent(file_path, false, url, false);
|
||||
// Pause torrent if necessary
|
||||
if (h.is_valid() && pref->addTorrentsInPause() && pref->useAdditionDialog())
|
||||
h.pause();
|
||||
addTorrent(file_path, false, url, false);
|
||||
emit newDownloadedTorrentFromRss(url);
|
||||
}
|
||||
}
|
||||
|
@ -3093,6 +3097,11 @@ void QBtSession::unhideMagnet(const QString &hash) {
|
|||
return;
|
||||
}
|
||||
|
||||
bool add_paused = pref->addTorrentsInPause();
|
||||
if (TorrentTempData::hasTempData(hash)) {
|
||||
add_paused = TorrentTempData::isAddPaused(hash);
|
||||
}
|
||||
|
||||
if (!h.has_metadata()) {
|
||||
if (pref->isQueueingSystemEnabled()) {
|
||||
//Internally decrease the queue limits to ensure that other queued items aren't started
|
||||
|
@ -3109,13 +3118,13 @@ void QBtSession::unhideMagnet(const QString &hash) {
|
|||
sessionSettings.active_limit = max_active;
|
||||
s->set_settings(sessionSettings);
|
||||
}
|
||||
if (pref->addTorrentsInPause())
|
||||
if (add_paused)
|
||||
h.pause();
|
||||
}
|
||||
|
||||
h.queue_position_bottom();
|
||||
loadTorrentTempData(h, h.save_path(), !h.has_metadata()); //TempData are deleted by a call to TorrentPersistentData::saveTorrentPersistentData()
|
||||
if (!pref->addTorrentsInPause())
|
||||
if (!add_paused)
|
||||
h.resume();
|
||||
h.move_storage(save_path);
|
||||
|
||||
|
|
|
@ -160,6 +160,14 @@ QString TorrentTempData::getQueuedPath(const QString &hash) {
|
|||
return i->queuedPath;
|
||||
}
|
||||
|
||||
void TorrentTempData::setAddPaused(const QString &hash, const bool &paused) {
|
||||
data[hash].add_paused = paused;
|
||||
}
|
||||
|
||||
bool TorrentTempData::isAddPaused(const QString &hash) {
|
||||
return data.value(hash).add_paused;
|
||||
}
|
||||
|
||||
void HiddenData::addData(const QString &hash) {
|
||||
data[hash] = false;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <QHash>
|
||||
#include <QStringList>
|
||||
#include <vector>
|
||||
#include "preferences.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QDateTime;
|
||||
|
@ -65,16 +66,19 @@ public:
|
|||
static QString getOldPath(const QString &hash);
|
||||
static QString getNewPath(const QString &hash);
|
||||
static QString getQueuedPath(const QString &hash);
|
||||
static void setAddPaused(const QString &hash, const bool &paused);
|
||||
static bool isAddPaused(const QString &hash);
|
||||
|
||||
private:
|
||||
struct TorrentData {
|
||||
TorrentData(): sequential(false), seed(false) {}
|
||||
TorrentData(): sequential(false), seed(false), add_paused(Preferences::instance()->addTorrentsInPause()) {}
|
||||
std::vector<int> files_priority;
|
||||
QStringList path_list;
|
||||
QString save_path;
|
||||
QString label;
|
||||
bool sequential;
|
||||
bool seed;
|
||||
bool add_paused;
|
||||
};
|
||||
|
||||
struct TorrentMoveState {
|
||||
|
|
Loading…
Reference in a new issue