diff --git a/src/base/bittorrent/sessionimpl.cpp b/src/base/bittorrent/sessionimpl.cpp index 5ac91e319..ff57f6646 100644 --- a/src/base/bittorrent/sessionimpl.cpp +++ b/src/base/bittorrent/sessionimpl.cpp @@ -2749,6 +2749,14 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr if (hasMetadata) { + // Torrent that is being added with metadata is considered to be added as stopped + // if "metadata received" stop condition is set for it. + if (loadTorrentParams.stopCondition == Torrent::StopCondition::MetadataReceived) + { + loadTorrentParams.stopped = true; + loadTorrentParams.stopCondition = Torrent::StopCondition::None; + } + const TorrentInfo &torrentInfo = *source.info(); Q_ASSERT(addTorrentParams.filePaths.isEmpty() || (addTorrentParams.filePaths.size() == torrentInfo.filesCount())); diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 5a02d3df7..a6f82288d 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -304,18 +304,28 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::TorrentDescriptor &to m_ui->downloadPath->setMaxVisibleItems(20); m_ui->addToQueueTopCheckBox->setChecked(m_torrentParams.addToQueueTop.value_or(session->isAddTorrentToQueueTop())); - m_ui->startTorrentCheckBox->setChecked(!m_torrentParams.addPaused.value_or(session->isAddTorrentPaused())); + m_ui->stopConditionComboBox->setToolTip( u"
" + tr("None") + u" - " + tr("No stop condition is set.") + u"
" + tr("Metadata received") + u" - " + tr("Torrent will stop after metadata is received.") + - u" " + tr("Torrents that have metadata initially aren't affected.") + u"
" + + u" " + tr("Torrents that have metadata initially will be added as stopped.") + u"
" + tr("Files checked") + u" - " + tr("Torrent will stop after files are initially checked.") + u" " + tr("This will also download metadata if it wasn't there initially.") + u"
"); - m_ui->stopConditionComboBox->setItemData(0, QVariant::fromValue(BitTorrent::Torrent::StopCondition::None)); - m_ui->stopConditionComboBox->setItemData(1, QVariant::fromValue(BitTorrent::Torrent::StopCondition::MetadataReceived)); - m_ui->stopConditionComboBox->setItemData(2, QVariant::fromValue(BitTorrent::Torrent::StopCondition::FilesChecked)); - m_ui->stopConditionComboBox->setCurrentIndex(m_ui->stopConditionComboBox->findData( - QVariant::fromValue(m_torrentParams.stopCondition.value_or(session->torrentStopCondition())))); + m_ui->stopConditionComboBox->addItem(tr("None"), QVariant::fromValue(BitTorrent::Torrent::StopCondition::None)); + if (!hasMetadata()) + m_ui->stopConditionComboBox->addItem(tr("Metadata received"), QVariant::fromValue(BitTorrent::Torrent::StopCondition::MetadataReceived)); + m_ui->stopConditionComboBox->addItem(tr("Files checked"), QVariant::fromValue(BitTorrent::Torrent::StopCondition::FilesChecked)); + const auto stopCondition = m_torrentParams.stopCondition.value_or(session->torrentStopCondition()); + if (hasMetadata() && (stopCondition == BitTorrent::Torrent::StopCondition::MetadataReceived)) + { + m_ui->startTorrentCheckBox->setChecked(false); + m_ui->stopConditionComboBox->setCurrentIndex(m_ui->stopConditionComboBox->findData(QVariant::fromValue(BitTorrent::Torrent::StopCondition::None))); + } + else + { + m_ui->startTorrentCheckBox->setChecked(!m_torrentParams.addPaused.value_or(session->isAddTorrentPaused())); + m_ui->stopConditionComboBox->setCurrentIndex(m_ui->stopConditionComboBox->findData(QVariant::fromValue(stopCondition))); + } m_ui->stopConditionLabel->setEnabled(m_ui->startTorrentCheckBox->isChecked()); m_ui->stopConditionComboBox->setEnabled(m_ui->startTorrentCheckBox->isChecked()); connect(m_ui->startTorrentCheckBox, &QCheckBox::toggled, this, [this](const bool checked) @@ -744,14 +754,22 @@ void AddNewTorrentDialog::updateMetadata(const BitTorrent::TorrentInfo &metadata m_torrentDescr.setTorrentInfo(metadata); setMetadataProgressIndicator(true, tr("Parsing metadata...")); - const auto stopCondition = m_ui->stopConditionComboBox->currentData().value" + tr("None") + u" - " + tr("No stop condition is set.") + u"
" + tr("Metadata received") + u" - " + tr("Torrent will stop after metadata is received.") + - u" " + tr("Torrents that have metadata initially aren't affected.") + u"
" + + u" " + tr("Torrents that have metadata initially will be added as stopped.") + u"
" + tr("Files checked") + u" - " + tr("Torrent will stop after files are initially checked.") + u" " + tr("This will also download metadata if it wasn't there initially.") + u"
"); m_ui->stopConditionComboBox->setItemData(0, QVariant::fromValue(BitTorrent::Torrent::StopCondition::None));