mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-11 07:46:17 -07:00
Change "metadata received" stop condition behavior
PR #20283. Closes #20122.
This commit is contained in:
parent
05572a7317
commit
8ec3db1807
4 changed files with 37 additions and 29 deletions
|
@ -2749,6 +2749,14 @@ bool SessionImpl::addTorrent_impl(const TorrentDescriptor &source, const AddTorr
|
||||||
|
|
||||||
if (hasMetadata)
|
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();
|
const TorrentInfo &torrentInfo = *source.info();
|
||||||
|
|
||||||
Q_ASSERT(addTorrentParams.filePaths.isEmpty() || (addTorrentParams.filePaths.size() == torrentInfo.filesCount()));
|
Q_ASSERT(addTorrentParams.filePaths.isEmpty() || (addTorrentParams.filePaths.size() == torrentInfo.filesCount()));
|
||||||
|
|
|
@ -304,18 +304,28 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::TorrentDescriptor &to
|
||||||
m_ui->downloadPath->setMaxVisibleItems(20);
|
m_ui->downloadPath->setMaxVisibleItems(20);
|
||||||
|
|
||||||
m_ui->addToQueueTopCheckBox->setChecked(m_torrentParams.addToQueueTop.value_or(session->isAddTorrentToQueueTop()));
|
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(
|
m_ui->stopConditionComboBox->setToolTip(
|
||||||
u"<html><body><p><b>" + tr("None") + u"</b> - " + tr("No stop condition is set.") + u"</p><p><b>" +
|
u"<html><body><p><b>" + tr("None") + u"</b> - " + tr("No stop condition is set.") + u"</p><p><b>" +
|
||||||
tr("Metadata received") + u"</b> - " + tr("Torrent will stop after metadata is received.") +
|
tr("Metadata received") + u"</b> - " + tr("Torrent will stop after metadata is received.") +
|
||||||
u" <em>" + tr("Torrents that have metadata initially aren't affected.") + u"</em></p><p><b>" +
|
u" <em>" + tr("Torrents that have metadata initially will be added as stopped.") + u"</em></p><p><b>" +
|
||||||
tr("Files checked") + u"</b> - " + tr("Torrent will stop after files are initially checked.") +
|
tr("Files checked") + u"</b> - " + tr("Torrent will stop after files are initially checked.") +
|
||||||
u" <em>" + tr("This will also download metadata if it wasn't there initially.") + u"</em></p></body></html>");
|
u" <em>" + tr("This will also download metadata if it wasn't there initially.") + u"</em></p></body></html>");
|
||||||
m_ui->stopConditionComboBox->setItemData(0, QVariant::fromValue(BitTorrent::Torrent::StopCondition::None));
|
m_ui->stopConditionComboBox->addItem(tr("None"), QVariant::fromValue(BitTorrent::Torrent::StopCondition::None));
|
||||||
m_ui->stopConditionComboBox->setItemData(1, QVariant::fromValue(BitTorrent::Torrent::StopCondition::MetadataReceived));
|
if (!hasMetadata())
|
||||||
m_ui->stopConditionComboBox->setItemData(2, QVariant::fromValue(BitTorrent::Torrent::StopCondition::FilesChecked));
|
m_ui->stopConditionComboBox->addItem(tr("Metadata received"), QVariant::fromValue(BitTorrent::Torrent::StopCondition::MetadataReceived));
|
||||||
m_ui->stopConditionComboBox->setCurrentIndex(m_ui->stopConditionComboBox->findData(
|
m_ui->stopConditionComboBox->addItem(tr("Files checked"), QVariant::fromValue(BitTorrent::Torrent::StopCondition::FilesChecked));
|
||||||
QVariant::fromValue(m_torrentParams.stopCondition.value_or(session->torrentStopCondition()))));
|
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->stopConditionLabel->setEnabled(m_ui->startTorrentCheckBox->isChecked());
|
||||||
m_ui->stopConditionComboBox->setEnabled(m_ui->startTorrentCheckBox->isChecked());
|
m_ui->stopConditionComboBox->setEnabled(m_ui->startTorrentCheckBox->isChecked());
|
||||||
connect(m_ui->startTorrentCheckBox, &QCheckBox::toggled, this, [this](const bool checked)
|
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);
|
m_torrentDescr.setTorrentInfo(metadata);
|
||||||
setMetadataProgressIndicator(true, tr("Parsing metadata..."));
|
setMetadataProgressIndicator(true, tr("Parsing metadata..."));
|
||||||
const auto stopCondition = m_ui->stopConditionComboBox->currentData().value<BitTorrent::Torrent::StopCondition>();
|
|
||||||
if (stopCondition == BitTorrent::Torrent::StopCondition::MetadataReceived)
|
|
||||||
m_ui->startTorrentCheckBox->setChecked(false);
|
|
||||||
|
|
||||||
// Update UI
|
// Update UI
|
||||||
setupTreeview();
|
setupTreeview();
|
||||||
setMetadataProgressIndicator(false, tr("Metadata retrieval complete"));
|
setMetadataProgressIndicator(false, tr("Metadata retrieval complete"));
|
||||||
|
|
||||||
|
if (const auto stopCondition = m_ui->stopConditionComboBox->currentData().value<BitTorrent::Torrent::StopCondition>()
|
||||||
|
; stopCondition == BitTorrent::Torrent::StopCondition::MetadataReceived)
|
||||||
|
{
|
||||||
|
m_ui->startTorrentCheckBox->setChecked(false);
|
||||||
|
|
||||||
|
const auto index = m_ui->stopConditionComboBox->currentIndex();
|
||||||
|
m_ui->stopConditionComboBox->setCurrentIndex(m_ui->stopConditionComboBox->findData(
|
||||||
|
QVariant::fromValue(BitTorrent::Torrent::StopCondition::None)));
|
||||||
|
m_ui->stopConditionComboBox->removeItem(index);
|
||||||
|
}
|
||||||
|
|
||||||
m_ui->buttonSave->setVisible(true);
|
m_ui->buttonSave->setVisible(true);
|
||||||
if (m_torrentDescr.infoHash().v2().isValid())
|
if (m_torrentDescr.infoHash().v2().isValid())
|
||||||
{
|
{
|
||||||
|
|
|
@ -261,24 +261,6 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="stopConditionComboBox">
|
<widget class="QComboBox" name="stopConditionComboBox">
|
||||||
<property name="currentIndex">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>None</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Metadata received</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Files checked</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -523,7 +523,7 @@ void OptionsDialog::loadDownloadsTabOptions()
|
||||||
m_ui->stopConditionComboBox->setToolTip(
|
m_ui->stopConditionComboBox->setToolTip(
|
||||||
u"<html><body><p><b>" + tr("None") + u"</b> - " + tr("No stop condition is set.") + u"</p><p><b>" +
|
u"<html><body><p><b>" + tr("None") + u"</b> - " + tr("No stop condition is set.") + u"</p><p><b>" +
|
||||||
tr("Metadata received") + u"</b> - " + tr("Torrent will stop after metadata is received.") +
|
tr("Metadata received") + u"</b> - " + tr("Torrent will stop after metadata is received.") +
|
||||||
u" <em>" + tr("Torrents that have metadata initially aren't affected.") + u"</em></p><p><b>" +
|
u" <em>" + tr("Torrents that have metadata initially will be added as stopped.") + u"</em></p><p><b>" +
|
||||||
tr("Files checked") + u"</b> - " + tr("Torrent will stop after files are initially checked.") +
|
tr("Files checked") + u"</b> - " + tr("Torrent will stop after files are initially checked.") +
|
||||||
u" <em>" + tr("This will also download metadata if it wasn't there initially.") + u"</em></p></body></html>");
|
u" <em>" + tr("This will also download metadata if it wasn't there initially.") + u"</em></p></body></html>");
|
||||||
m_ui->stopConditionComboBox->setItemData(0, QVariant::fromValue(BitTorrent::Torrent::StopCondition::None));
|
m_ui->stopConditionComboBox->setItemData(0, QVariant::fromValue(BitTorrent::Torrent::StopCondition::None));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue