Browse Source

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).
adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
6a462edb72
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 19
      src/gui/previewselectdialog.cpp

19
src/gui/previewselectdialog.cpp

@ -112,21 +112,26 @@ PreviewSelectDialog::~PreviewSelectDialog() @@ -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…
Cancel
Save