Add checkbox for "Excluded file names"

PR #17206.
This commit is contained in:
thalieht
2022-06-15 08:16:01 +03:00
committed by GitHub
parent 7faa8b7a02
commit d1515456bc
8 changed files with 83 additions and 30 deletions

View File

@@ -976,20 +976,23 @@ void AddNewTorrentDialog::setupTreeview()
m_ui->contentTreeView->setExpanded(currentIndex, true);
}
// Check file name blacklist for torrents that are manually added
QVector<BitTorrent::DownloadPriority> priorities = m_contentModel->model()->getFilePriorities();
Q_ASSERT(priorities.size() == m_torrentInfo.filesCount());
for (int i = 0; i < priorities.size(); ++i)
if (BitTorrent::Session::instance()->isExcludedFileNamesEnabled())
{
if (priorities[i] == BitTorrent::DownloadPriority::Ignored)
continue;
// Check file name blacklist for torrents that are manually added
QVector<BitTorrent::DownloadPriority> priorities = m_contentModel->model()->getFilePriorities();
Q_ASSERT(priorities.size() == m_torrentInfo.filesCount());
if (BitTorrent::Session::instance()->isFilenameExcluded(m_torrentInfo.filePath(i).filename()))
priorities[i] = BitTorrent::DownloadPriority::Ignored;
for (int i = 0; i < priorities.size(); ++i)
{
if (priorities[i] == BitTorrent::DownloadPriority::Ignored)
continue;
if (BitTorrent::Session::instance()->isFilenameExcluded(m_torrentInfo.filePath(i).filename()))
priorities[i] = BitTorrent::DownloadPriority::Ignored;
}
m_contentModel->model()->updateFilesPriorities(priorities);
}
m_contentModel->model()->updateFilesPriorities(priorities);
}
updateDiskSpaceLabel();

View File

@@ -375,6 +375,7 @@ OptionsDialog::OptionsDialog(QWidget *parent)
connect(m_ui->checkUseDownloadPath, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->checkUseDownloadPath, &QAbstractButton::toggled, m_ui->textDownloadPath, &QWidget::setEnabled);
connect(m_ui->addWatchedFolderButton, &QAbstractButton::clicked, this, &ThisType::enableApplyButton);
connect(m_ui->groupExcludedFileNames, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
connect(m_ui->textExcludedFileNames, &QPlainTextEdit::textChanged, this, &ThisType::enableApplyButton);
connect(m_ui->removeWatchedFolderButton, &QAbstractButton::clicked, this, &ThisType::enableApplyButton);
connect(m_ui->groupMailNotification, &QGroupBox::toggled, this, &ThisType::enableApplyButton);
@@ -758,6 +759,7 @@ void OptionsDialog::saveOptions()
session->setTorrentContentLayout(static_cast<BitTorrent::TorrentContentLayout>(m_ui->contentLayoutComboBox->currentIndex()));
auto watchedFoldersModel = static_cast<WatchedFoldersModel *>(m_ui->scanFoldersView->model());
watchedFoldersModel->apply();
session->setExcludedFileNamesEnabled(m_ui->groupExcludedFileNames->isChecked());
session->setExcludedFileNames(m_ui->textExcludedFileNames->toPlainText().split(u'\n', Qt::SkipEmptyParts));
session->setTorrentExportDirectory(getTorrentExportDir());
session->setFinishedTorrentExportDirectory(getFinishedTorrentExportDir());
@@ -1018,6 +1020,7 @@ void OptionsDialog::loadOptions()
m_ui->checkAppendqB->setChecked(session->isAppendExtensionEnabled());
m_ui->checkPreallocateAll->setChecked(session->isPreallocationEnabled());
m_ui->checkRecursiveDownload->setChecked(!pref->recursiveDownloadDisabled());
m_ui->groupExcludedFileNames->setChecked(session->isExcludedFileNamesEnabled());
m_ui->textExcludedFileNames->setPlainText(session->excludedFileNames().join(u'\n'));
if (session->torrentExportDirectory().isEmpty())

View File

@@ -1112,12 +1112,12 @@ Manual: Various torrent properties (e.g. save path) must be assigned manually</s
</item>
<item>
<widget class="QCheckBox" name="checkUseCategoryPaths">
<property name="text">
<string>Use Category paths in Manual Mode</string>
</property>
<property name="toolTip">
<string>Resolve relative Save Path against appropriate Category path instead of Default one</string>
</property>
<property name="text">
<string>Use Category paths in Manual Mode</string>
</property>
</widget>
</item>
<item>
@@ -1266,14 +1266,13 @@ Manual: Various torrent properties (e.g. save path) must be assigned manually</s
<property name="title">
<string>Excluded file names</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_311">
<item>
<widget class="QLabel" name="label_1">
<property name="text">
<string>Filters:</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="textExcludedFileNames">
<property name="toolTip">