Trace crop pointer state when a drag loses its button

This commit is contained in:
evgeny committed 2026-10-27 12:23:12 +01:00
1 parent 59458f3b7c
commit bb8b0f146a
2 files changed
+6

No files matched your search

+3
View File
@@ -67,13 +67,16 @@ protected:
offset *= zoom/previous; clamp(); update(); e->accept();
}
void mousePressEvent(QMouseEvent* e) override {
DEBUG_TRACE(DEBUG_CATEGORY_MEDIA, "avatar crop press: button=%x image=%d", unsigned(e->button()), !image.isNull());
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());
if (!(e->buttons() & Qt::LeftButton)) { dragging = false; setCursor(Qt::OpenHandCursor); }
if (dragging) { offset += e->pos()-last; last = e->pos(); clamp(); update(); }
}
void mouseReleaseEvent(QMouseEvent* e) override {
DEBUG_TRACE(DEBUG_CATEGORY_MEDIA, "avatar crop release: button=%x dragging=%d", unsigned(e->button()), dragging);
if (e->button() == Qt::LeftButton) { dragging = false; setCursor(Qt::OpenHandCursor); }
}
private:
+3
View File
@@ -7,6 +7,7 @@
#include <QTemporaryDir>
#include <QWheelEvent>
#include <QMouseEvent>
#include <QScopeGuard>
#include <functional>
#include <cmath>
extern "C" {
@@ -106,6 +107,8 @@ private slots:
}
void lostLeftButtonStopsDrag() {
debug_set_category_level(DEBUG_CATEGORY_MEDIA, DEBUG_LEVEL_TRACE);
auto restore = qScopeGuard([] { debug_set_category_level(DEBUG_CATEGORY_MEDIA, DEBUG_LEVEL_WARN); });
QTemporaryDir directory; QVERIFY(directory.isValid());
const QString path = directory.filePath("source.png"); QImage image(800, 400, QImage::Format_RGB32); image.fill(Qt::blue);
QVERIFY(image.save(path)); QRectF crop;