From f54aa17e55d2fe46118cbed9bf08cae28cda9a73 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 27 Oct 2026 12:25:03 +0100 Subject: [PATCH] Observe buttonless pointer moves to cancel interrupted crop drags --- tools/chatgui/src/avatars/avatarcrop.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/chatgui/src/avatars/avatarcrop.cpp b/tools/chatgui/src/avatars/avatarcrop.cpp index 8a4e986a..74cb8fb2 100644 --- a/tools/chatgui/src/avatars/avatarcrop.cpp +++ b/tools/chatgui/src/avatars/avatarcrop.cpp @@ -26,7 +26,9 @@ class CropView : public QWidget { public: QImage image; QSize originalSize; - explicit CropView(QWidget* parent) : QWidget(parent) { setMinimumSize(320, 320); setCursor(Qt::OpenHandCursor); } + explicit CropView(QWidget* parent) : QWidget(parent) { + setMinimumSize(320, 320); setMouseTracking(true); setCursor(Qt::OpenHandCursor); + } QRectF frame() const { const double side = qMin(width(), height()) * 0.8; return {(width()-side)/2, (height()-side)/2, side, side}; } double scale() const { return qMax(frame().width()/originalSize.width(), frame().height()/originalSize.height()) * zoom; } void clamp() { @@ -71,7 +73,8 @@ protected: if (e->button() == Qt::LeftButton && !image.isNull()) { last = e->pos(); dragging = true; setCursor(Qt::ClosedHandCursor); } } void mouseMoveEvent(QMouseEvent* e) override { - DEBUG_TRACE(DEBUG_CATEGORY_MEDIA, "avatar crop move: dragging=%d buttons=%x x=%d y=%d", dragging, unsigned(e->buttons()), e->pos().x(), e->pos().y()); + DEBUG_TRACE(DEBUG_CATEGORY_MEDIA, "avatar crop move: dragging=%d buttons=%x x=%d y=%d", + dragging, unsigned(e->buttons()), e->pos().x(), e->pos().y()); if (!(e->buttons() & Qt::LeftButton)) { dragging = false; setCursor(Qt::OpenHandCursor); } if (dragging) { offset += e->pos()-last; last = e->pos(); clamp(); update(); } }