mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
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.
This commit is contained in:
parent
0607050ecc
commit
7ed0cd0c35
@ -101,16 +101,6 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, const BitTorrent::Torr
|
||||
|
||||
// Restore dialog state
|
||||
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()
|
||||
@ -161,13 +151,21 @@ void PreviewSelectDialog::loadWindowState()
|
||||
|
||||
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
|
||||
// Set Name column width to 60% of TreeView
|
||||
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_headerStateInitialized = true;
|
||||
}
|
||||
|
||||
// Only one file, no choice
|
||||
if (m_previewListModel->rowCount() <= 1)
|
||||
previewButtonClicked();
|
||||
}
|
||||
|
@ -506,6 +506,7 @@ void TransferListWidget::previewSelectedTorrents()
|
||||
auto *dialog = new PreviewSelectDialog(this, torrent);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(dialog, &PreviewSelectDialog::readyToPreviewFile, this, &TransferListWidget::previewFile);
|
||||
dialog->show();
|
||||
}
|
||||
else {
|
||||
QMessageBox::critical(this, tr("Unable to preview"), tr("The selected torrent does not contain previewable files"));
|
||||
|
Loading…
Reference in New Issue
Block a user