Add warning when previewing torrents with many files

- Implemented confirmation dialog for torrents with >100 files
- Fixes #23072
This commit is contained in:
Code-Explorer-Dev 2025-08-11 07:39:54 +10:00
commit 4ca7ae88c3

View file

@ -610,17 +610,29 @@ void TransferListWidget::openSelectedTorrentsFolder() const
void TransferListWidget::previewSelectedTorrents() void TransferListWidget::previewSelectedTorrents()
{ {
const int FILE_COUNT_THRESHOLD = 100;
for (const BitTorrent::Torrent *torrent : asConst(getSelectedTorrents())) for (const BitTorrent::Torrent *torrent : asConst(getSelectedTorrents()))
{ {
if (torrentContainsPreviewableFiles(torrent)) if (!torrentContainsPreviewableFiles(torrent))
{
openPreviewSelectDialog(torrent);
}
else
{ {
QMessageBox::critical(this, tr("Unable to preview"), tr("The selected torrent \"%1\" does not contain previewable files") QMessageBox::critical(this, tr("Unable to preview"), tr("The selected torrent \"%1\" does not contain previewable files")
.arg(torrent->name())); .arg(torrent->name()));
continue;
} }
const int fileCount = torrent->filesCount();
if (fileCount > FILE_COUNT_THRESHOLD)
{
QMessageBox::StandardButton reply = QMessageBox::question(this, tr("Preview confirmation"),
tr("The torrent \"%1\" has a large number of files (%2). Previewing may take a long time. Do you want to continue?")
.arg(torrent->name()).arg(fileCount),
QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::No)
continue;
}
openPreviewSelectDialog(torrent);
} }
} }