From e28ae6f4af4750063db4b8a399b1feb6551d3cb0 Mon Sep 17 00:00:00 2001 From: pax Date: Fri, 10 Apr 2026 20:15:50 -0500 Subject: [PATCH] Reapply "only select cell when clicking the pixmap, not the surrounding padding" This reverts commit 6aa8677a2d28af2eb00961fb16169128df72d2fc. --- booru_viewer/gui/grid.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/booru_viewer/gui/grid.py b/booru_viewer/gui/grid.py index c2e20db..c7aa309 100644 --- a/booru_viewer/gui/grid.py +++ b/booru_viewer/gui/grid.py @@ -278,8 +278,19 @@ class ThumbnailWidget(QWidget): self._hover = False self.update() + def _hit_pixmap(self, pos) -> bool: + """True if pos is within the drawn pixmap area.""" + if not self._pixmap: + return False + px = (self.width() - self._pixmap.width()) // 2 + py = (self.height() - self._pixmap.height()) // 2 + return QRect(px, py, self._pixmap.width(), self._pixmap.height()).contains(pos) + def mousePressEvent(self, event) -> None: if event.button() == Qt.MouseButton.LeftButton: + if not self._hit_pixmap(event.position().toPoint()): + event.ignore() + return self._drag_start = event.position().toPoint() self.clicked.emit(self.index, event) elif event.button() == Qt.MouseButton.RightButton: