Browse Source

Fix "preview file" action not working

Root cause is the PreviewSelectDialog::readyToPreviewFile signal is
emitted before it is connected to a slot.
Only single-file torrents are affected.

Closes #11315.
adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
7ed0cd0c35
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 22
      src/gui/previewselectdialog.cpp
  2. 1
      src/gui/transferlistwidget.cpp

22
src/gui/previewselectdialog.cpp

@ -101,16 +101,6 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
// Restore dialog state // Restore dialog state
loadWindowState(); loadWindowState();
if (m_previewListModel->rowCount() == 1) {
qDebug("Torrent file only contains one file, no need to display selection dialog before preview");
// Only one file : no choice
previewButtonClicked();
}
else {
qDebug("Displaying media file selection dialog for preview");
show();
}
} }
PreviewSelectDialog::~PreviewSelectDialog() PreviewSelectDialog::~PreviewSelectDialog()
@ -161,13 +151,21 @@ void PreviewSelectDialog::loadWindowState()
void PreviewSelectDialog::showEvent(QShowEvent *event) void PreviewSelectDialog::showEvent(QShowEvent *event)
{ {
Q_UNUSED(event); // event originated from system
if (event->spontaneous()) {
QDialog::showEvent(event);
return;
}
// Default size, have to be called after show(), because width is needed // Default size, have to be called after show(), because width is needed
// Set Name column width to 60% of TreeView // Set Name column width to 60% of TreeView
if (!m_headerStateInitialized) { if (!m_headerStateInitialized) {
int nameSize = (m_ui->previewList->size().width() * 0.6); const int nameSize = (m_ui->previewList->size().width() * 0.6);
m_ui->previewList->header()->resizeSection(0, nameSize); m_ui->previewList->header()->resizeSection(0, nameSize);
m_headerStateInitialized = true; m_headerStateInitialized = true;
} }
// Only one file, no choice
if (m_previewListModel->rowCount() <= 1)
previewButtonClicked();
} }

1
src/gui/transferlistwidget.cpp

@ -506,6 +506,7 @@ void TransferListWidget::previewSelectedTorrents()
auto *dialog = new PreviewSelectDialog(this, torrent); auto *dialog = new PreviewSelectDialog(this, torrent);
dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->setAttribute(Qt::WA_DeleteOnClose);
connect(dialog, &PreviewSelectDialog::readyToPreviewFile, this, &TransferListWidget::previewFile); connect(dialog, &PreviewSelectDialog::readyToPreviewFile, this, &TransferListWidget::previewFile);
dialog->show();
} }
else { else {
QMessageBox::critical(this, tr("Unable to preview"), tr("The selected torrent does not contain previewable files")); QMessageBox::critical(this, tr("Unable to preview"), tr("The selected torrent does not contain previewable files"));

Loading…
Cancel
Save