mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 08:48:07 -06:00
committed by
GitHub
parent
facfa26eed
commit
dd1bd8ad10
@@ -93,12 +93,12 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
|
||||
const QVector<qreal> fp = torrent->filesProgress();
|
||||
for (int i = 0; i < torrent->filesCount(); ++i)
|
||||
{
|
||||
const QString fileName = Utils::Fs::fileName(torrent->filePath(i));
|
||||
if (Utils::Misc::isPreviewable(fileName))
|
||||
const Path filePath = torrent->filePath(i);
|
||||
if (Utils::Misc::isPreviewable(filePath))
|
||||
{
|
||||
int row = m_previewListModel->rowCount();
|
||||
m_previewListModel->insertRow(row);
|
||||
m_previewListModel->setData(m_previewListModel->index(row, NAME), fileName);
|
||||
m_previewListModel->setData(m_previewListModel->index(row, NAME), filePath.filename());
|
||||
m_previewListModel->setData(m_previewListModel->index(row, SIZE), torrent->fileSize(i));
|
||||
m_previewListModel->setData(m_previewListModel->index(row, PROGRESS), fp[i]);
|
||||
m_previewListModel->setData(m_previewListModel->index(row, FILE_INDEX), i);
|
||||
@@ -133,14 +133,14 @@ void PreviewSelectDialog::previewButtonClicked()
|
||||
|
||||
// Only one file should be selected
|
||||
const int fileIndex = selectedIndexes.at(0).data().toInt();
|
||||
const QString path = QDir(m_torrent->actualStorageLocation()).absoluteFilePath(m_torrent->actualFilePath(fileIndex));
|
||||
const Path path = m_torrent->actualStorageLocation() / m_torrent->actualFilePath(fileIndex);
|
||||
// File
|
||||
if (!QFile::exists(path))
|
||||
if (!path.exists())
|
||||
{
|
||||
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: \"%1\".").arg(Utils::Fs::toNativePath(path)));
|
||||
, tr("Sorry, we can't preview this file: \"%1\".").arg(path.toString()));
|
||||
if (isSingleFile)
|
||||
reject();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user