mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
Merge pull request #11825 from FranciscoPombal/stalled_filter
Add stalled filters to GUI and Web API/UI
This commit is contained in:
commit
322ae3e0bc
@ -41,6 +41,9 @@ const TorrentFilter TorrentFilter::PausedTorrent(TorrentFilter::Paused);
|
||||
const TorrentFilter TorrentFilter::ResumedTorrent(TorrentFilter::Resumed);
|
||||
const TorrentFilter TorrentFilter::ActiveTorrent(TorrentFilter::Active);
|
||||
const TorrentFilter TorrentFilter::InactiveTorrent(TorrentFilter::Inactive);
|
||||
const TorrentFilter TorrentFilter::StalledTorrent(TorrentFilter::Stalled);
|
||||
const TorrentFilter TorrentFilter::StalledUploadingTorrent(TorrentFilter::StalledUploading);
|
||||
const TorrentFilter TorrentFilter::StalledDownloadingTorrent(TorrentFilter::StalledDownloading);
|
||||
const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored);
|
||||
|
||||
using BitTorrent::TorrentHandle;
|
||||
@ -95,6 +98,12 @@ bool TorrentFilter::setTypeByName(const QString &filter)
|
||||
type = Active;
|
||||
else if (filter == "inactive")
|
||||
type = Inactive;
|
||||
else if (filter == "stalled")
|
||||
type = Stalled;
|
||||
else if (filter == "stalled_uploading")
|
||||
type = StalledUploading;
|
||||
else if (filter == "stalled_downloading")
|
||||
type = StalledDownloading;
|
||||
else if (filter == "errored")
|
||||
type = Errored;
|
||||
|
||||
@ -163,6 +172,13 @@ bool TorrentFilter::matchState(const BitTorrent::TorrentHandle *const torrent) c
|
||||
return torrent->isActive();
|
||||
case Inactive:
|
||||
return torrent->isInactive();
|
||||
case Stalled:
|
||||
return (torrent->state() == BitTorrent::TorrentState::StalledUploading)
|
||||
|| (torrent->state() == BitTorrent::TorrentState::StalledDownloading);
|
||||
case StalledUploading:
|
||||
return torrent->state() == BitTorrent::TorrentState::StalledUploading;
|
||||
case StalledDownloading:
|
||||
return torrent->state() == BitTorrent::TorrentState::StalledDownloading;
|
||||
case Errored:
|
||||
return torrent->isErrored();
|
||||
default: // All
|
||||
|
@ -52,6 +52,9 @@ public:
|
||||
Paused,
|
||||
Active,
|
||||
Inactive,
|
||||
Stalled,
|
||||
StalledUploading,
|
||||
StalledDownloading,
|
||||
Errored
|
||||
};
|
||||
|
||||
@ -67,6 +70,9 @@ public:
|
||||
static const TorrentFilter ResumedTorrent;
|
||||
static const TorrentFilter ActiveTorrent;
|
||||
static const TorrentFilter InactiveTorrent;
|
||||
static const TorrentFilter StalledTorrent;
|
||||
static const TorrentFilter StalledUploadingTorrent;
|
||||
static const TorrentFilter StalledDownloadingTorrent;
|
||||
static const TorrentFilter ErroredTorrent;
|
||||
|
||||
TorrentFilter();
|
||||
|
@ -186,6 +186,15 @@ StatusFilterWidget::StatusFilterWidget(QWidget *parent, TransferListWidget *tran
|
||||
auto *inactive = new QListWidgetItem(this);
|
||||
inactive->setData(Qt::DisplayRole, tr("Inactive (0)"));
|
||||
inactive->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterinactive.svg"));
|
||||
auto *stalled = new QListWidgetItem(this);
|
||||
stalled->setData(Qt::DisplayRole, tr("Stalled (0)"));
|
||||
stalled->setData(Qt::DecorationRole, QIcon(":/icons/skin/filterstalled.svg"));
|
||||
auto *stalledUploading = new QListWidgetItem(this);
|
||||
stalledUploading->setData(Qt::DisplayRole, tr("Stalled Uploading (0)"));
|
||||
stalledUploading->setData(Qt::DecorationRole, QIcon(":/icons/skin/stalledUP.svg"));
|
||||
auto *stalledDownloading = new QListWidgetItem(this);
|
||||
stalledDownloading->setData(Qt::DisplayRole, tr("Stalled Downloading (0)"));
|
||||
stalledDownloading->setData(Qt::DecorationRole, QIcon(":/icons/skin/stalledDL.svg"));
|
||||
auto *errored = new QListWidgetItem(this);
|
||||
errored->setData(Qt::DisplayRole, tr("Errored (0)"));
|
||||
errored->setData(Qt::DecorationRole, QIcon(":/icons/skin/error.svg"));
|
||||
@ -209,6 +218,9 @@ void StatusFilterWidget::updateTorrentNumbers()
|
||||
int nbPaused = 0;
|
||||
int nbActive = 0;
|
||||
int nbInactive = 0;
|
||||
int nbStalled = 0;
|
||||
int nbStalledUploading = 0;
|
||||
int nbStalledDownloading = 0;
|
||||
int nbErrored = 0;
|
||||
|
||||
const QHash<BitTorrent::InfoHash, BitTorrent::TorrentHandle *> torrents = BitTorrent::Session::instance()->torrents();
|
||||
@ -227,10 +239,16 @@ void StatusFilterWidget::updateTorrentNumbers()
|
||||
++nbActive;
|
||||
if (torrent->isInactive())
|
||||
++nbInactive;
|
||||
if (torrent->state() == BitTorrent::TorrentState::StalledUploading)
|
||||
++nbStalledUploading;
|
||||
if (torrent->state() == BitTorrent::TorrentState::StalledDownloading)
|
||||
++nbStalledDownloading;
|
||||
if (torrent->isErrored())
|
||||
++nbErrored;
|
||||
}
|
||||
|
||||
nbStalled = nbStalledUploading + nbStalledDownloading;
|
||||
|
||||
item(TorrentFilter::All)->setData(Qt::DisplayRole, tr("All (%1)").arg(torrents.count()));
|
||||
item(TorrentFilter::Downloading)->setData(Qt::DisplayRole, tr("Downloading (%1)").arg(nbDownloading));
|
||||
item(TorrentFilter::Seeding)->setData(Qt::DisplayRole, tr("Seeding (%1)").arg(nbSeeding));
|
||||
@ -239,6 +257,9 @@ void StatusFilterWidget::updateTorrentNumbers()
|
||||
item(TorrentFilter::Paused)->setData(Qt::DisplayRole, tr("Paused (%1)").arg(nbPaused));
|
||||
item(TorrentFilter::Active)->setData(Qt::DisplayRole, tr("Active (%1)").arg(nbActive));
|
||||
item(TorrentFilter::Inactive)->setData(Qt::DisplayRole, tr("Inactive (%1)").arg(nbInactive));
|
||||
item(TorrentFilter::Stalled)->setData(Qt::DisplayRole, tr("Stalled (%1)").arg(nbStalled));
|
||||
item(TorrentFilter::StalledUploading)->setData(Qt::DisplayRole, tr("Stalled Uploading (%1)").arg(nbStalledUploading));
|
||||
item(TorrentFilter::StalledDownloading)->setData(Qt::DisplayRole, tr("Stalled Downloading (%1)").arg(nbStalledDownloading));
|
||||
item(TorrentFilter::Errored)->setData(Qt::DisplayRole, tr("Errored (%1)").arg(nbErrored));
|
||||
}
|
||||
|
||||
|
@ -349,6 +349,7 @@
|
||||
<file>skin/filteractive.svg</file>
|
||||
<file>skin/filterall.svg</file>
|
||||
<file>skin/filterinactive.svg</file>
|
||||
<file>skin/filterstalled.svg</file>
|
||||
<file>skin/firewalled.svg</file>
|
||||
<file>skin/handle-icon-horizontal.gif</file>
|
||||
<file>skin/handle-icon.gif</file>
|
||||
|
3
src/icons/skin/filterstalled.svg
Normal file
3
src/icons/skin/filterstalled.svg
Normal file
@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21.781139 25.6" width="21.781" height="25.6">
|
||||
<path d="M21.5 3.7l-7.6 7.5v11.4c0 .5-.2.7-.6.9-.1.1-.3.1-.4.1-.3 0-.6-.1-.7-.3l-4-4c-.2-.2-.3-.5-.3-.7v-7.5L.4 3.7C0 3.3-.1 2.9.1 2.6.3 2.2.6 2 1 2h19.7c.5 0 .7.3.9.6.3.4.2.7-.1 1.1z" fill="#686868"/>
|
||||
</svg>
|
After Width: | Height: | Size: 310 B |
@ -231,7 +231,7 @@ namespace
|
||||
// - "force_start": Torrent force start state
|
||||
// - "category": Torrent category
|
||||
// GET params:
|
||||
// - filter (string): all, downloading, seeding, completed, paused, resumed, active, inactive
|
||||
// - filter (string): all, downloading, seeding, completed, paused, resumed, active, inactive, stalled, stalled_uploading, stalled_downloading
|
||||
// - category (string): torrent category for filtering by it (empty string means "uncategorized"; no "category" param presented means "any category")
|
||||
// - hashes (string): filter by hashes, can contain multiple hashes separated by |
|
||||
// - sort (string): name of column for sorting by its value
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "base/utils/net.h"
|
||||
#include "base/utils/version.h"
|
||||
|
||||
constexpr Utils::Version<int, 3, 2> API_VERSION {2, 4, 0};
|
||||
constexpr Utils::Version<int, 3, 2> API_VERSION {2, 4, 1};
|
||||
|
||||
class APIController;
|
||||
class WebApplication;
|
||||
|
@ -184,6 +184,9 @@ window.addEvent('load', function() {
|
||||
$("resumed_filter").removeClass("selectedFilter");
|
||||
$("active_filter").removeClass("selectedFilter");
|
||||
$("inactive_filter").removeClass("selectedFilter");
|
||||
$("stalled_filter").removeClass("selectedFilter");
|
||||
$("stalled_uploading_filter").removeClass("selectedFilter");
|
||||
$("stalled_downloading_filter").removeClass("selectedFilter");
|
||||
$("errored_filter").removeClass("selectedFilter");
|
||||
$(f + "_filter").addClass("selectedFilter");
|
||||
selected_filter = f;
|
||||
@ -344,6 +347,9 @@ window.addEvent('load', function() {
|
||||
updateFilter('paused', 'QBT_TR(Paused (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
|
||||
updateFilter('active', 'QBT_TR(Active (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
|
||||
updateFilter('inactive', 'QBT_TR(Inactive (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
|
||||
updateFilter('stalled', 'QBT_TR(Stalled (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
|
||||
updateFilter('stalled_uploading', 'QBT_TR(Stalled Uploading (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
|
||||
updateFilter('stalled_downloading', 'QBT_TR(Stalled Downloading (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
|
||||
updateFilter('errored', 'QBT_TR(Errored (%1))QBT_TR[CONTEXT=StatusFilterWidget]');
|
||||
};
|
||||
|
||||
|
@ -1225,6 +1225,18 @@ window.qBittorrent.DynamicTable = (function() {
|
||||
if (state.indexOf('paused') > -1)
|
||||
return false;
|
||||
break;
|
||||
case 'stalled':
|
||||
if ((state != 'stalledUP') && (state != 'stalledDL'))
|
||||
return false;
|
||||
break;
|
||||
case 'stalled_uploading':
|
||||
if (state != 'stalledUP')
|
||||
return false;
|
||||
break;
|
||||
case 'stalled_downloading':
|
||||
if (state != 'stalledDL')
|
||||
return false;
|
||||
break;
|
||||
case 'inactive':
|
||||
inactive = true;
|
||||
// fallthrough
|
||||
|
@ -11,6 +11,9 @@
|
||||
<li id="paused_filter"><a href="#" onclick="setFilter('paused');return false;"><img src="images/skin/paused.svg" alt="Paused" />QBT_TR(Paused (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
|
||||
<li id="active_filter"><a href="#" onclick="setFilter('active');return false;"><img src="images/skin/filteractive.svg" alt="Active" />QBT_TR(Active (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
|
||||
<li id="inactive_filter"><a href="#" onclick="setFilter('inactive');return false;"><img src="images/skin/filterinactive.svg" alt="Inactive" />QBT_TR(Inactive (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
|
||||
<li id="stalled_filter"><a href="#" onclick="setFilter('stalled');return false;"><img src="images/skin/filterstalled.svg" alt="Stalled" />QBT_TR(Stalled (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
|
||||
<li id="stalled_uploading_filter"><a href="#" onclick="setFilter('stalled_uploading');return false;"><img src="images/skin/stalledUP.svg" alt="Stalled Uploading" />QBT_TR(Stalled Uploading (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
|
||||
<li id="stalled_downloading_filter"><a href="#" onclick="setFilter('stalled_downloading');return false;"><img src="images/skin/stalledDL.svg" alt="Stalled Downloading" />QBT_TR(Stalled Downloading (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
|
||||
<li id="errored_filter"><a href="#" onclick="setFilter('errored');return false;"><img src="images/skin/error.svg" alt="Errored" />QBT_TR(Errored (0))QBT_TR[CONTEXT=StatusFilterWidget]</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user