Improve structure of AddNewTorrentDialog code

Restructures the code to separate the basic logic from the logic that depends on the parameters and properties of the torrent being added.
Also fixes "Never show again" checkbox functionality.

PR #20848.
This commit is contained in:
Vladimir Golovnev
2024-05-18 10:38:49 +03:00
committed by GitHub
parent e09a871ca3
commit b8a774f1fb
4 changed files with 309 additions and 230 deletions

View File

@@ -226,14 +226,16 @@ bool GUIAddTorrentManager::processTorrent(const QString &source, const BitTorren
dlg->setAttribute(Qt::WA_DeleteOnClose);
m_dialogs[infoHash] = dlg;
connect(dlg, &QDialog::finished, this, [this, source, infoHash, dlg](int result)
connect(dlg, &AddNewTorrentDialog::torrentAccepted, this
, [this, source](const BitTorrent::TorrentDescriptor &torrentDescr, const BitTorrent::AddTorrentParams &addTorrentParams)
{
addTorrentToSession(source, torrentDescr, addTorrentParams);
});
connect(dlg, &QDialog::finished, this, [this, source, infoHash, dlg]
{
if (dlg->isDoNotDeleteTorrentChecked())
releaseTorrentFileGuard(source);
if (result == QDialog::Accepted)
addTorrentToSession(source, dlg->torrentDescriptor(), dlg->addTorrentParams());
m_dialogs.remove(infoHash);
});