From 4ba9990f3a48c5f35a20a817a1406a1fb18644d9 Mon Sep 17 00:00:00 2001 From: pax Date: Fri, 10 Apr 2026 20:21:58 -0500 Subject: [PATCH] pixmap-aware double-click and dynamic cursor on hover --- booru_viewer/gui/grid.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/booru_viewer/gui/grid.py b/booru_viewer/gui/grid.py index 8d3e76c..e40806f 100644 --- a/booru_viewer/gui/grid.py +++ b/booru_viewer/gui/grid.py @@ -96,7 +96,6 @@ class ThumbnailWidget(QWidget): self._hover_color = self._selection_color.lighter(150) self._idle_color = pal.color(QPalette.ColorRole.Mid) self.setFixedSize(THUMB_SIZE, THUMB_SIZE) - self.setCursor(Qt.CursorShape.PointingHandCursor) self.setMouseTracking(True) def set_pixmap(self, pixmap: QPixmap) -> None: @@ -281,10 +280,11 @@ class ThumbnailWidget(QWidget): self.update() def mouseMoveEvent(self, event) -> None: - # Update hover based on whether cursor is over the pixmap + # Update hover and cursor based on whether cursor is over the pixmap over = self._hit_pixmap(event.position().toPoint()) if self._pixmap else False if over != self._hover: self._hover = over + self.setCursor(Qt.CursorShape.PointingHandCursor if over else Qt.CursorShape.ArrowCursor) self.update() if (self._drag_start and self._cached_path and (event.position().toPoint() - self._drag_start).manhattanLength() > 10): @@ -296,7 +296,7 @@ class ThumbnailWidget(QWidget): drag.setPixmap(self._pixmap.scaled(64, 64, Qt.AspectRatioMode.KeepAspectRatio)) drag.exec(Qt.DropAction.CopyAction) self._drag_start = None - self.setCursor(Qt.CursorShape.PointingHandCursor) + self.setCursor(Qt.CursorShape.ArrowCursor) return def _hit_pixmap(self, pos) -> bool: @@ -323,6 +323,9 @@ class ThumbnailWidget(QWidget): def mouseDoubleClickEvent(self, event) -> None: self._drag_start = None if event.button() == Qt.MouseButton.LeftButton: + if not self._hit_pixmap(event.position().toPoint()): + event.ignore() + return self.double_clicked.emit(self.index)