mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-06-27 17:09:53 -04:00
Fix preview not opening on Wayland
Deferring the opening of the preview slightly gives the preview select dialog time to close and for focus to shift back to the main window. PR #22608. Closes #22607. --------- Co-authored-by: Vladimir Golovnev <glassez@yandex.ru>
This commit is contained in:
parent
70822e8942
commit
45babc336d
2 changed files with 13 additions and 8 deletions
|
@ -312,10 +312,7 @@ void TransferListWidget::torrentDoubleClicked()
|
|||
case PREVIEW_FILE:
|
||||
if (torrentContainsPreviewableFiles(torrent))
|
||||
{
|
||||
auto *dialog = new PreviewSelectDialog(this, torrent);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(dialog, &PreviewSelectDialog::readyToPreviewFile, this, &TransferListWidget::previewFile);
|
||||
dialog->show();
|
||||
openPreviewSelectDialog(torrent);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -617,10 +614,7 @@ void TransferListWidget::previewSelectedTorrents()
|
|||
{
|
||||
if (torrentContainsPreviewableFiles(torrent))
|
||||
{
|
||||
auto *dialog = new PreviewSelectDialog(this, torrent);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(dialog, &PreviewSelectDialog::readyToPreviewFile, this, &TransferListWidget::previewFile);
|
||||
dialog->show();
|
||||
openPreviewSelectDialog(torrent);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1449,3 +1443,13 @@ void TransferListWidget::wheelEvent(QWheelEvent *event)
|
|||
|
||||
QTreeView::wheelEvent(event); // event delegated to base class
|
||||
}
|
||||
|
||||
void TransferListWidget::openPreviewSelectDialog(const BitTorrent::Torrent *torrent)
|
||||
{
|
||||
auto *dialog = new PreviewSelectDialog(this, torrent);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
// Qt::QueuedConnection is required to prevent a bug on wayland compositors where the preview won't open.
|
||||
// It occurs when the window focus shifts immediately after TransferListWidget::previewFile has been called.
|
||||
connect(dialog, &PreviewSelectDialog::readyToPreviewFile, this, &TransferListWidget::previewFile, Qt::QueuedConnection);
|
||||
dialog->show();
|
||||
}
|
||||
|
|
|
@ -123,6 +123,7 @@ private:
|
|||
void dragMoveEvent(QDragMoveEvent *event) override;
|
||||
void dropEvent(QDropEvent *event) override;
|
||||
void wheelEvent(QWheelEvent *event) override;
|
||||
void openPreviewSelectDialog(const BitTorrent::Torrent *torrent);
|
||||
QModelIndex mapToSource(const QModelIndex &index) const;
|
||||
QModelIndexList mapToSource(const QModelIndexList &indexes) const;
|
||||
QModelIndex mapFromSource(const QModelIndex &index) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue