From e5943b64c1cb803c52f69e1e837d73fd3f8b7281 Mon Sep 17 00:00:00 2001 From: AbeniMatteo <634710+AbeniMatteo@users.noreply.github.com> Date: Fri, 16 Jul 2021 13:08:10 +0200 Subject: [PATCH] Add filter "Checking" to side panel (#15166) --- src/base/torrentfilter.cpp | 7 +++++++ src/base/torrentfilter.h | 2 ++ src/gui/transferlistfilterswidget.cpp | 7 +++++++ src/webui/www/private/scripts/client.js | 2 ++ src/webui/www/private/scripts/dynamicTable.js | 4 ++++ src/webui/www/private/views/filters.html | 1 + 6 files changed, 23 insertions(+) diff --git a/src/base/torrentfilter.cpp b/src/base/torrentfilter.cpp index 58a7b7d89..928f38807 100644 --- a/src/base/torrentfilter.cpp +++ b/src/base/torrentfilter.cpp @@ -45,6 +45,7 @@ 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::CheckingTorrent(TorrentFilter::Checking); const TorrentFilter TorrentFilter::ErroredTorrent(TorrentFilter::Errored); using BitTorrent::Torrent; @@ -101,6 +102,8 @@ bool TorrentFilter::setTypeByName(const QString &filter) type = StalledUploading; else if (filter == "stalled_downloading") type = StalledDownloading; + else if (filter == "checking") + type = Checking; else if (filter == "errored") type = Errored; @@ -180,6 +183,10 @@ bool TorrentFilter::matchState(const BitTorrent::Torrent *const torrent) const return torrent->state() == BitTorrent::TorrentState::StalledUploading; case StalledDownloading: return torrent->state() == BitTorrent::TorrentState::StalledDownloading; + case Checking: + return (torrent->state() == BitTorrent::TorrentState::CheckingUploading) + || (torrent->state() == BitTorrent::TorrentState::CheckingDownloading) + || (torrent->state() == BitTorrent::TorrentState::CheckingResumeData); case Errored: return torrent->isErrored(); default: // All diff --git a/src/base/torrentfilter.h b/src/base/torrentfilter.h index 08364144c..f1a01e3fe 100644 --- a/src/base/torrentfilter.h +++ b/src/base/torrentfilter.h @@ -56,6 +56,7 @@ public: Stalled, StalledUploading, StalledDownloading, + Checking, Errored }; @@ -74,6 +75,7 @@ public: static const TorrentFilter StalledTorrent; static const TorrentFilter StalledUploadingTorrent; static const TorrentFilter StalledDownloadingTorrent; + static const TorrentFilter CheckingTorrent; static const TorrentFilter ErroredTorrent; TorrentFilter() = default; diff --git a/src/gui/transferlistfilterswidget.cpp b/src/gui/transferlistfilterswidget.cpp index fc457241c..7210fcef5 100644 --- a/src/gui/transferlistfilterswidget.cpp +++ b/src/gui/transferlistfilterswidget.cpp @@ -212,6 +212,9 @@ StatusFilterWidget::StatusFilterWidget(QWidget *parent, TransferListWidget *tran auto *stalledDownloading = new QListWidgetItem(this); stalledDownloading->setData(Qt::DisplayRole, tr("Stalled Downloading (0)")); stalledDownloading->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("stalledDL"))); + auto *checking = new QListWidgetItem(this); + checking->setData(Qt::DisplayRole, tr("Checking (0)")); + checking->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("checking"))); auto *errored = new QListWidgetItem(this); errored->setData(Qt::DisplayRole, tr("Errored (0)")); errored->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(QLatin1String("error"))); @@ -238,6 +241,7 @@ void StatusFilterWidget::updateTorrentNumbers() int nbStalled = 0; int nbStalledUploading = 0; int nbStalledDownloading = 0; + int nbChecking = 0; int nbErrored = 0; const QVector torrents = BitTorrent::Session::instance()->torrents(); @@ -261,6 +265,8 @@ void StatusFilterWidget::updateTorrentNumbers() ++nbStalledUploading; if (torrent->state() == BitTorrent::TorrentState::StalledDownloading) ++nbStalledDownloading; + if (torrent->isChecking()) + ++nbChecking; if (torrent->isErrored()) ++nbErrored; } @@ -278,6 +284,7 @@ void StatusFilterWidget::updateTorrentNumbers() 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::Checking)->setData(Qt::DisplayRole, tr("Checking (%1)").arg(nbChecking)); item(TorrentFilter::Errored)->setData(Qt::DisplayRole, tr("Errored (%1)").arg(nbErrored)); } diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js index c6c7bf038..997fa78bb 100644 --- a/src/webui/www/private/scripts/client.js +++ b/src/webui/www/private/scripts/client.js @@ -225,6 +225,7 @@ window.addEvent('load', function() { $("stalled_filter").removeClass("selectedFilter"); $("stalled_uploading_filter").removeClass("selectedFilter"); $("stalled_downloading_filter").removeClass("selectedFilter"); + $("checking_filter").removeClass("selectedFilter"); $("errored_filter").removeClass("selectedFilter"); $(f + "_filter").addClass("selectedFilter"); selected_filter = f; @@ -383,6 +384,7 @@ window.addEvent('load', function() { 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('checking', 'QBT_TR(Checking (%1))QBT_TR[CONTEXT=StatusFilterWidget]'); updateFilter('errored', 'QBT_TR(Errored (%1))QBT_TR[CONTEXT=StatusFilterWidget]'); }; diff --git a/src/webui/www/private/scripts/dynamicTable.js b/src/webui/www/private/scripts/dynamicTable.js index 742bdaa1e..34a458232 100644 --- a/src/webui/www/private/scripts/dynamicTable.js +++ b/src/webui/www/private/scripts/dynamicTable.js @@ -1314,6 +1314,10 @@ window.qBittorrent.DynamicTable = (function() { if (r == inactive) return false; break; + case 'checking': + if (state !== 'checkingUP' && state !== 'checkingDL' && state !== 'checkingResumeData') + return false; + break; case 'errored': if (state != 'error' && state != "unknown" && state != "missingFiles") return false; diff --git a/src/webui/www/private/views/filters.html b/src/webui/www/private/views/filters.html index ce62f87c0..8551e2fe0 100644 --- a/src/webui/www/private/views/filters.html +++ b/src/webui/www/private/views/filters.html @@ -14,6 +14,7 @@
  • StalledQBT_TR(Stalled (0))QBT_TR[CONTEXT=StatusFilterWidget]
  • Stalled UploadingQBT_TR(Stalled Uploading (0))QBT_TR[CONTEXT=StatusFilterWidget]
  • Stalled DownloadingQBT_TR(Stalled Downloading (0))QBT_TR[CONTEXT=StatusFilterWidget]
  • +
  • CheckingQBT_TR(Checking (0))QBT_TR[CONTEXT=StatusFilterWidget]
  • ErroredQBT_TR(Errored (0))QBT_TR[CONTEXT=StatusFilterWidget]