mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 12:48:04 -06:00
Clean up 'recursive download' related code
Don't load .torrent files too early, otherwise qbt might emit a dubious error log message if the .torrent file is invalid.
This commit is contained in:
@@ -885,27 +885,33 @@ void MainWindow::displayExecutionLogTab()
|
||||
|
||||
// End of keyboard shortcuts slots
|
||||
|
||||
void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *const torrent)
|
||||
void MainWindow::askRecursiveTorrentDownloadConfirmation(const BitTorrent::Torrent *torrent)
|
||||
{
|
||||
Preferences *const pref = Preferences::instance();
|
||||
if (pref->recursiveDownloadDisabled()) return;
|
||||
if (!Preferences::instance()->isRecursiveDownloadEnabled())
|
||||
return;
|
||||
|
||||
const auto torrentID = torrent->id();
|
||||
|
||||
QMessageBox *confirmBox = new QMessageBox(QMessageBox::Question, tr("Recursive download confirmation")
|
||||
, tr("The torrent '%1' contains torrent files, do you want to proceed with their download?").arg(torrent->name())
|
||||
, QMessageBox::NoButton, this);
|
||||
, tr("The torrent '%1' contains .torrent files, do you want to proceed with their downloads?").arg(torrent->name())
|
||||
, (QMessageBox::Yes | QMessageBox::No | QMessageBox::NoToAll), this);
|
||||
confirmBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
const QPushButton *yes = confirmBox->addButton(tr("Yes"), QMessageBox::YesRole);
|
||||
/*QPushButton *no = */ confirmBox->addButton(tr("No"), QMessageBox::NoRole);
|
||||
const QPushButton *never = confirmBox->addButton(tr("Never"), QMessageBox::NoRole);
|
||||
connect(confirmBox, &QMessageBox::buttonClicked, this, [torrentID, yes, never](const QAbstractButton *button)
|
||||
const QAbstractButton *yesButton = confirmBox->button(QMessageBox::Yes);
|
||||
QAbstractButton *neverButton = confirmBox->button(QMessageBox::NoToAll);
|
||||
neverButton->setText(tr("Never"));
|
||||
|
||||
connect(confirmBox, &QMessageBox::buttonClicked, this
|
||||
, [torrentID, yesButton, neverButton](const QAbstractButton *button)
|
||||
{
|
||||
if (button == yes)
|
||||
if (button == yesButton)
|
||||
{
|
||||
BitTorrent::Session::instance()->recursiveTorrentDownload(torrentID);
|
||||
if (button == never)
|
||||
Preferences::instance()->disableRecursiveDownload();
|
||||
}
|
||||
else if (button == neverButton)
|
||||
{
|
||||
Preferences::instance()->setRecursiveDownloadEnabled(false);
|
||||
}
|
||||
});
|
||||
confirmBox->open();
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ private slots:
|
||||
void reloadSessionStats();
|
||||
void reloadTorrentStats(const QVector<BitTorrent::Torrent *> &torrents);
|
||||
void loadPreferences();
|
||||
void askRecursiveTorrentDownloadConfirmation(BitTorrent::Torrent *const torrent);
|
||||
void askRecursiveTorrentDownloadConfirmation(const BitTorrent::Torrent *torrent);
|
||||
void optionsSaved();
|
||||
void toggleAlternativeSpeeds();
|
||||
|
||||
|
||||
@@ -546,7 +546,7 @@ void OptionsDialog::loadDownloadsTabOptions()
|
||||
|
||||
m_ui->checkPreallocateAll->setChecked(session->isPreallocationEnabled());
|
||||
m_ui->checkAppendqB->setChecked(session->isAppendExtensionEnabled());
|
||||
m_ui->checkRecursiveDownload->setChecked(!pref->recursiveDownloadDisabled());
|
||||
m_ui->checkRecursiveDownload->setChecked(pref->isRecursiveDownloadEnabled());
|
||||
|
||||
m_ui->comboSavingMode->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
|
||||
m_ui->comboTorrentCategoryChanged->setCurrentIndex(session->isDisableAutoTMMWhenCategoryChanged());
|
||||
@@ -698,7 +698,7 @@ void OptionsDialog::saveDownloadsTabOptions() const
|
||||
|
||||
session->setPreallocationEnabled(preAllocateAllFiles());
|
||||
session->setAppendExtensionEnabled(m_ui->checkAppendqB->isChecked());
|
||||
pref->disableRecursiveDownload(!m_ui->checkRecursiveDownload->isChecked());
|
||||
pref->setRecursiveDownloadEnabled(m_ui->checkRecursiveDownload->isChecked());
|
||||
|
||||
session->setAutoTMMDisabledByDefault(m_ui->comboSavingMode->currentIndex() == 0);
|
||||
session->setDisableAutoTMMWhenCategoryChanged(m_ui->comboTorrentCategoryChanged->currentIndex() == 1);
|
||||
|
||||
Reference in New Issue
Block a user