mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Don't close preview dialog if selected file failed to open
User may have made a mis-selection and this should not close the dialog (only when the torrent has multiple previewable files).
This commit is contained in:
parent
7ed0cd0c35
commit
6a462edb72
@ -112,21 +112,26 @@ PreviewSelectDialog::~PreviewSelectDialog()
|
||||
|
||||
void PreviewSelectDialog::previewButtonClicked()
|
||||
{
|
||||
QModelIndexList selectedIndexes = m_ui->previewList->selectionModel()->selectedRows(FILE_INDEX);
|
||||
const QModelIndexList selectedIndexes = m_ui->previewList->selectionModel()->selectedRows(FILE_INDEX);
|
||||
if (selectedIndexes.isEmpty()) return;
|
||||
|
||||
// Flush data
|
||||
m_torrent->flushCache();
|
||||
|
||||
QStringList absolutePaths(m_torrent->absoluteFilePaths());
|
||||
const QStringList absolutePaths = m_torrent->absoluteFilePaths();
|
||||
// Only one file should be selected
|
||||
QString path = absolutePaths.at(selectedIndexes.at(0).data().toInt());
|
||||
const QString path = absolutePaths.at(selectedIndexes.at(0).data().toInt());
|
||||
// File
|
||||
if (QFile::exists(path))
|
||||
emit readyToPreviewFile(path);
|
||||
else
|
||||
QMessageBox::critical(this->parentWidget(), tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
||||
if (!QFile::exists(path)) {
|
||||
const bool isSingleFile = (m_previewListModel->rowCount() == 1);
|
||||
QWidget *parent = isSingleFile ? this->parentWidget() : this;
|
||||
QMessageBox::critical(parent, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
||||
if (isSingleFile)
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
emit readyToPreviewFile(path);
|
||||
accept();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user