fixup: qt client nicer torrent add handling (#1427)

* refactor: omit unnecessary #include

* refactor: make the onDuplicatesTimer slot private.

* feat: show dupe torrents in dialog's detailText

* fix: a stupid bug that I introduced.
This commit is contained in:
Charles Kerr 2020-09-07 10:20:48 -05:00 committed by GitHub
parent fdaad67def
commit 90ce7efc09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View File

@ -1145,7 +1145,7 @@ void Session::onDuplicatesTimer()
duplicates.swap(duplicates_);
QStringList lines;
for (auto it : duplicates_)
for (auto it : duplicates)
{
lines.push_back(tr("%1 (copy of %2)")
.arg(it.first)
@ -1155,11 +1155,18 @@ void Session::onDuplicatesTimer()
if (!lines.empty())
{
lines.sort(Qt::CaseInsensitive);
auto* d = new QMessageBox(QMessageBox::Warning,
tr("Unable to add Duplicate Torrent(s)", "", lines.size()),
lines.join(QStringLiteral("\n")),
QMessageBox::Close,
qApp->activeWindow());
auto const title = tr("Duplicate Torrent(s)", "", lines.size());
auto const detail = lines.join(QStringLiteral("\n"));
auto const detail_text = tr("Unable to add %n duplicate torrent(s)", "", lines.size());
auto const use_detail = lines.size() > 1;
auto const text = use_detail ? detail_text : detail;
auto* d = new QMessageBox(QMessageBox::Warning, title, text, QMessageBox::Close, qApp->activeWindow());
if (use_detail)
{
d->setDetailedText(detail);
}
QObject::connect(d, &QMessageBox::rejected, d, &QMessageBox::deleteLater);
d->show();
}

View File

@ -25,7 +25,6 @@
#include "RpcQueue.h"
#include "Torrent.h"
#include "Typedefs.h"
#include "Utils.h" // std::hash<QString>
class AddData;
class Prefs;
@ -122,7 +121,6 @@ public:
public slots:
void addTorrent(AddData const& addme);
void launchWebInterface();
void onDuplicatesTimer();
void queueMoveBottom(torrent_ids_t const& torrentIds = {});
void queueMoveDown(torrent_ids_t const& torrentIds = {});
void queueMoveTop(torrent_ids_t const& torrentIds = {});
@ -182,4 +180,7 @@ private:
std::map<QString, QString> duplicates_;
QTimer duplicates_timer_;
private slots:
void onDuplicatesTimer();
};