mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-20 07:27:22 -06:00
Implement 'Force Start' feature. Closes #270.
This commit is contained in:
@@ -96,6 +96,9 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
case TorrentModelItem::STATE_DOWNLOADING_META:
|
||||
display = tr("Downloading metadata", "used when loading a magnet link");
|
||||
break;
|
||||
case TorrentModelItem::STATE_FORCED_DL:
|
||||
display = tr("[F] Downloading", "used when the torrent is forced started. You probably shouldn't translate the F.");
|
||||
break;
|
||||
case TorrentModelItem::STATE_ALLOCATING:
|
||||
display = tr("Allocating", "qBittorrent is allocating the files on disk");
|
||||
break;
|
||||
@@ -106,6 +109,9 @@ void TransferListDelegate::paint(QPainter * painter, const QStyleOptionViewItem
|
||||
case TorrentModelItem::STATE_STALLED_UP:
|
||||
display = tr("Seeding", "Torrent is complete and in upload-only mode");
|
||||
break;
|
||||
case TorrentModelItem::STATE_FORCED_UP:
|
||||
display = tr("[F] Seeding", "used when the torrent is forced started. You probably shouldn't translate the F.");
|
||||
break;
|
||||
case TorrentModelItem::STATE_QUEUED_DL:
|
||||
case TorrentModelItem::STATE_QUEUED_UP:
|
||||
display = tr("Queued", "i.e. torrent is queued");
|
||||
|
||||
@@ -152,8 +152,10 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
||||
switch (model->data(model->index(left.row(), TorrentModelItem::TR_STATUS)).toInt()) {
|
||||
case TorrentModelItem::STATE_DOWNLOADING:
|
||||
case TorrentModelItem::STATE_DOWNLOADING_META:
|
||||
case TorrentModelItem::STATE_FORCED_DL:
|
||||
case TorrentModelItem::STATE_STALLED_DL:
|
||||
case TorrentModelItem::STATE_SEEDING:
|
||||
case TorrentModelItem::STATE_FORCED_UP:
|
||||
case TorrentModelItem::STATE_STALLED_UP:
|
||||
activeL = true;
|
||||
break;
|
||||
@@ -164,8 +166,10 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex
|
||||
switch (model->data(model->index(right.row(), TorrentModelItem::TR_STATUS)).toInt()) {
|
||||
case TorrentModelItem::STATE_DOWNLOADING:
|
||||
case TorrentModelItem::STATE_DOWNLOADING_META:
|
||||
case TorrentModelItem::STATE_FORCED_DL:
|
||||
case TorrentModelItem::STATE_STALLED_DL:
|
||||
case TorrentModelItem::STATE_SEEDING:
|
||||
case TorrentModelItem::STATE_FORCED_UP:
|
||||
case TorrentModelItem::STATE_STALLED_UP:
|
||||
activeR = true;
|
||||
break;
|
||||
@@ -288,16 +292,17 @@ bool TransferListSortModel::matchStatusFilter(int sourceRow, const QModelIndex &
|
||||
return (state == TorrentModelItem::STATE_DOWNLOADING || state == TorrentModelItem::STATE_STALLED_DL
|
||||
|| state == TorrentModelItem::STATE_PAUSED_DL || state == TorrentModelItem::STATE_CHECKING_DL
|
||||
|| state == TorrentModelItem::STATE_QUEUED_DL || state == TorrentModelItem::STATE_DOWNLOADING_META
|
||||
|| state == TorrentModelItem::STATE_PAUSED_MISSING);
|
||||
|| state == TorrentModelItem::STATE_PAUSED_MISSING || state == TorrentModelItem::STATE_FORCED_DL);
|
||||
|
||||
case TorrentFilter::SEEDING:
|
||||
return (state == TorrentModelItem::STATE_SEEDING || state == TorrentModelItem::STATE_STALLED_UP
|
||||
|| state == TorrentModelItem::STATE_CHECKING_UP || state == TorrentModelItem::STATE_QUEUED_UP);
|
||||
|| state == TorrentModelItem::STATE_CHECKING_UP || state == TorrentModelItem::STATE_QUEUED_UP
|
||||
|| state == TorrentModelItem::STATE_FORCED_UP);
|
||||
|
||||
case TorrentFilter::COMPLETED:
|
||||
return (state == TorrentModelItem::STATE_SEEDING || state == TorrentModelItem::STATE_STALLED_UP
|
||||
|| state == TorrentModelItem::STATE_PAUSED_UP || state == TorrentModelItem::STATE_CHECKING_UP
|
||||
|| state == TorrentModelItem::STATE_QUEUED_UP);
|
||||
|| state == TorrentModelItem::STATE_QUEUED_UP || state == TorrentModelItem::STATE_FORCED_UP);
|
||||
|
||||
case TorrentFilter::PAUSED:
|
||||
return (state == TorrentModelItem::STATE_PAUSED_DL || state == TorrentModelItem::STATE_PAUSED_MISSING);
|
||||
@@ -312,7 +317,8 @@ bool TransferListSortModel::matchStatusFilter(int sourceRow, const QModelIndex &
|
||||
return (up_speed > 0);
|
||||
}
|
||||
|
||||
return (state == TorrentModelItem::STATE_DOWNLOADING || state == TorrentModelItem::STATE_SEEDING);
|
||||
return (state == TorrentModelItem::STATE_DOWNLOADING || state == TorrentModelItem::STATE_SEEDING
|
||||
|| state == TorrentModelItem::STATE_FORCED_DL || state == TorrentModelItem::STATE_FORCED_UP);
|
||||
|
||||
case TorrentFilter::INACTIVE:
|
||||
if (state == TorrentModelItem::STATE_STALLED_DL) {
|
||||
@@ -320,7 +326,8 @@ bool TransferListSortModel::matchStatusFilter(int sourceRow, const QModelIndex &
|
||||
return !(up_speed > 0);
|
||||
}
|
||||
|
||||
return (state != TorrentModelItem::STATE_DOWNLOADING && state != TorrentModelItem::STATE_SEEDING);
|
||||
return (state != TorrentModelItem::STATE_DOWNLOADING && state != TorrentModelItem::STATE_SEEDING
|
||||
&& state != TorrentModelItem::STATE_FORCED_DL && state != TorrentModelItem::STATE_FORCED_UP);
|
||||
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -282,6 +282,13 @@ void TransferListWidget::startSelectedTorrents()
|
||||
BTSession->resumeTorrent(hash);
|
||||
}
|
||||
|
||||
void TransferListWidget::forceStartSelectedTorrents()
|
||||
{
|
||||
const QStringList hashes = getSelectedTorrentsHashes();
|
||||
foreach (const QString &hash, hashes)
|
||||
BTSession->resumeTorrent(hash, true);
|
||||
}
|
||||
|
||||
void TransferListWidget::startVisibleTorrents()
|
||||
{
|
||||
QStringList hashes;
|
||||
@@ -725,6 +732,8 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||
// Create actions
|
||||
QAction actionStart(IconProvider::instance()->getIcon("media-playback-start"), tr("Resume", "Resume/start the torrent"), 0);
|
||||
connect(&actionStart, SIGNAL(triggered()), this, SLOT(startSelectedTorrents()));
|
||||
QAction actionForceStart(tr("Force Resume", "Force Resume/start the torrent"), 0);
|
||||
connect(&actionForceStart, SIGNAL(triggered()), this, SLOT(forceStartSelectedTorrents()));
|
||||
QAction actionPause(IconProvider::instance()->getIcon("media-playback-pause"), tr("Pause", "Pause the torrent"), 0);
|
||||
connect(&actionPause, SIGNAL(triggered()), this, SLOT(pauseSelectedTorrents()));
|
||||
QAction actionDelete(IconProvider::instance()->getIcon("edit-delete"), tr("Delete", "Delete the torrent"), 0);
|
||||
@@ -753,10 +762,8 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||
connect(&actionForce_recheck, SIGNAL(triggered()), this, SLOT(recheckSelectedTorrents()));
|
||||
QAction actionCopy_magnet_link(QIcon(":/icons/magnet.png"), tr("Copy magnet link"), 0);
|
||||
connect(&actionCopy_magnet_link, SIGNAL(triggered()), this, SLOT(copySelectedMagnetURIs()));
|
||||
|
||||
QAction actionCopy_name(IconProvider::instance()->getIcon("edit-copy"), tr("Copy name"), 0);
|
||||
connect(&actionCopy_name, SIGNAL(triggered()), this, SLOT(copySelectedNames()));
|
||||
|
||||
QAction actionSuper_seeding_mode(tr("Super seeding mode"), 0);
|
||||
actionSuper_seeding_mode.setCheckable(true);
|
||||
connect(&actionSuper_seeding_mode, SIGNAL(triggered()), this, SLOT(toggleSelectedTorrentsSuperSeeding()));
|
||||
@@ -771,13 +778,14 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||
// End of actions
|
||||
QMenu listMenu(this);
|
||||
// Enable/disable pause/start action given the DL state
|
||||
bool has_pause = false, has_start = false, has_preview = false;
|
||||
bool has_pause = false, has_start = false, has_force = false, has_preview = false;
|
||||
bool all_same_super_seeding = true;
|
||||
bool super_seeding_mode = false;
|
||||
bool all_same_sequential_download_mode = true, all_same_prio_firstlast = true;
|
||||
bool sequential_download_mode = false, prioritize_first_last = false;
|
||||
bool one_has_metadata = false, one_not_seed = false;
|
||||
bool first = true;
|
||||
bool forced = false;
|
||||
QTorrentHandle h;
|
||||
qDebug("Displaying menu");
|
||||
foreach (const QModelIndex &index, selectedIndexes) {
|
||||
@@ -788,6 +796,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||
if (!h.is_valid()) continue;
|
||||
if (h.has_metadata())
|
||||
one_has_metadata = true;
|
||||
forced = h.is_forced();
|
||||
if (!h.is_seed()) {
|
||||
one_not_seed = true;
|
||||
if (h.has_metadata()) {
|
||||
@@ -818,8 +827,26 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||
listMenu.addAction(&actionStart);
|
||||
has_start = true;
|
||||
}
|
||||
if (!has_force) {
|
||||
listMenu.addAction(&actionForceStart);
|
||||
has_force = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (!forced) {
|
||||
if (!has_force) {
|
||||
listMenu.addAction(&actionForceStart);
|
||||
has_force = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!has_start) {
|
||||
listMenu.addAction(&actionStart);
|
||||
has_start = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_pause) {
|
||||
listMenu.addAction(&actionPause);
|
||||
has_pause = true;
|
||||
@@ -828,7 +855,7 @@ void TransferListWidget::displayListMenu(const QPoint&)
|
||||
if (h.has_metadata() && BTSession->isFilePreviewPossible(hash) && !has_preview)
|
||||
has_preview = true;
|
||||
first = false;
|
||||
if (has_pause && has_start && has_preview && one_not_seed) break;
|
||||
if (has_pause && has_start && has_force && has_preview && one_not_seed) break;
|
||||
}
|
||||
listMenu.addSeparator();
|
||||
listMenu.addAction(&actionDelete);
|
||||
|
||||
@@ -61,6 +61,7 @@ public slots:
|
||||
void setRefreshInterval(int t);
|
||||
void setSelectedTorrentsLocation();
|
||||
void startSelectedTorrents();
|
||||
void forceStartSelectedTorrents();
|
||||
void startVisibleTorrents();
|
||||
void pauseSelectedTorrents();
|
||||
void pauseVisibleTorrents();
|
||||
|
||||
Reference in New Issue
Block a user