grid: replace _source_pixmap with _source_path
Store the on-disk thumbnail path instead of a second decoded QPixmap per ThumbnailWidget. Saves ~90 KB per widget in decoded pixel memory. The source pixmap was only needed for the settings thumbnail-resize path, which now re-decodes from disk (rare operation). behavior change: thumbnail resize in settings re-reads from disk instead of scaling from a held pixmap. No visual difference.
This commit is contained in:
parent
3d288a909f
commit
738ece9cd5
@ -74,7 +74,7 @@ class ThumbnailWidget(QWidget):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.index = index
|
self.index = index
|
||||||
self._pixmap: QPixmap | None = None
|
self._pixmap: QPixmap | None = None
|
||||||
self._source_pixmap: QPixmap | None = None # original, for re-scaling on size change
|
self._source_path: str | None = None # on-disk path, for re-scaling on size change
|
||||||
self._selected = False
|
self._selected = False
|
||||||
self._multi_selected = False
|
self._multi_selected = False
|
||||||
self._bookmarked = False
|
self._bookmarked = False
|
||||||
@ -97,8 +97,9 @@ class ThumbnailWidget(QWidget):
|
|||||||
self.setFixedSize(THUMB_SIZE, THUMB_SIZE)
|
self.setFixedSize(THUMB_SIZE, THUMB_SIZE)
|
||||||
self.setMouseTracking(True)
|
self.setMouseTracking(True)
|
||||||
|
|
||||||
def set_pixmap(self, pixmap: QPixmap) -> None:
|
def set_pixmap(self, pixmap: QPixmap, path: str | None = None) -> None:
|
||||||
self._source_pixmap = pixmap
|
if path is not None:
|
||||||
|
self._source_path = path
|
||||||
self._pixmap = pixmap.scaled(
|
self._pixmap = pixmap.scaled(
|
||||||
THUMB_SIZE - 4, THUMB_SIZE - 4,
|
THUMB_SIZE - 4, THUMB_SIZE - 4,
|
||||||
Qt.AspectRatioMode.KeepAspectRatio,
|
Qt.AspectRatioMode.KeepAspectRatio,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user