Skip to content

Commit

Permalink
PICARD-2873: Fetch Search dialog cover art images after it was resized
Browse files Browse the repository at this point in the history
- create a new `resized` signal emitted every second
- call `AlbumSearchDialog.fetch_coverarts()` when it happens
  • Loading branch information
zas committed Apr 23, 2024
1 parent 5cea1f2 commit b77fd16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions picard/ui/searchdialog/album.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 10 additions & 0 deletions picard/ui/tablebaseddialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):

Expand All @@ -88,6 +97,7 @@ class TableBasedDialog(PicardDialog):

defaultsize = QtCore.QSize(720, 360)
scrolled = pyqtSignal()
resized = pyqtSignal()

def __init__(self, parent):
super().__init__(parent)
Expand Down

0 comments on commit b77fd16

Please sign in to comment.