From b77fd165d7423f561f13c05c7b070bc2370ca25c Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Tue, 23 Apr 2024 11:23:06 +0200 Subject: [PATCH] PICARD-2873: Fetch Search dialog cover art images after it was resized - create a new `resized` signal emitted every second - call `AlbumSearchDialog.fetch_coverarts()` when it happens --- picard/ui/searchdialog/album.py | 1 + picard/ui/tablebaseddialog.py | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/picard/ui/searchdialog/album.py b/picard/ui/searchdialog/album.py index 85b5aedbc92..23eba9b03b2 100644 --- a/picard/ui/searchdialog/album.py +++ b/picard/ui/searchdialog/album.py @@ -168,6 +168,7 @@ def __init__(self, parent, force_advanced_search=None, existing_album=None): self.cover_cells = [] self.fetching = False self.scrolled.connect(self.fetch_coverarts) + self.resized.connect(self.fetch_coverarts) @staticmethod def show_releasegroup_search(releasegroup_id, existing_album=None): diff --git a/picard/ui/tablebaseddialog.py b/picard/ui/tablebaseddialog.py index 0c899b6ceb6..3cf54baba6e 100644 --- a/picard/ui/tablebaseddialog.py +++ b/picard/ui/tablebaseddialog.py @@ -52,6 +52,7 @@ class ResultTable(QtWidgets.QTableWidget): def __init__(self, parent): super().__init__(parent) + self._parent_dialog = parent self.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection) self.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows) self.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers) @@ -73,6 +74,14 @@ def prepare(self, headers): self.setRowCount(0) self.setSortingEnabled(False) + @throttle(1000) # only emit resized signal once per second + def emit_resized(self): + self._parent_dialog.resized.emit() + + def resizeEvent(self, event): + self.emit_resized() + super().resizeEvent(event) + class SortableTableWidgetItem(QtWidgets.QTableWidgetItem): @@ -88,6 +97,7 @@ class TableBasedDialog(PicardDialog): defaultsize = QtCore.QSize(720, 360) scrolled = pyqtSignal() + resized = pyqtSignal() def __init__(self, parent): super().__init__(parent)