From cd6a973fe72a0f030595d4e5eed93d637f1beb9b Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Mon, 9 Apr 2018 08:32:02 +0800 Subject: [PATCH] Fix repeat(no-further-actions) snapshot --- src/skeletondocument.cpp | 4 ++-- src/skeletondocument.h | 8 ++++++++ src/skeletongraphicswidget.cpp | 13 +++++++++---- src/skeletongraphicswidget.h | 1 + 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/skeletondocument.cpp b/src/skeletondocument.cpp index 56221e87..544cf7ec 100644 --- a/src/skeletondocument.cpp +++ b/src/skeletondocument.cpp @@ -343,7 +343,7 @@ void SkeletonDocument::scaleNodeByAddRadius(QUuid nodeId, float amount) } if (isPartReadonly(it->second.partId)) return; - it->second.radius += amount; + it->second.setRadius(it->second.radius + amount); emit nodeRadiusChanged(nodeId); emit skeletonChanged(); } @@ -399,7 +399,7 @@ void SkeletonDocument::setNodeRadius(QUuid nodeId, float radius) } if (isPartReadonly(it->second.partId)) return; - it->second.radius = radius; + it->second.setRadius(radius); emit nodeRadiusChanged(nodeId); emit skeletonChanged(); } diff --git a/src/skeletondocument.h b/src/skeletondocument.h index f87e6f8c..0b0b331c 100644 --- a/src/skeletondocument.h +++ b/src/skeletondocument.h @@ -33,6 +33,14 @@ public: { id = withId.isNull() ? QUuid::createUuid() : withId; } + void setRadius(float toRadius) + { + if (toRadius < 0.01) + toRadius = 0.01; + else if (toRadius > 1) + toRadius = 1; + radius = toRadius; + } QUuid id; QUuid partId; QString name; diff --git a/src/skeletongraphicswidget.cpp b/src/skeletongraphicswidget.cpp index fa21596a..83481928 100644 --- a/src/skeletongraphicswidget.cpp +++ b/src/skeletongraphicswidget.cpp @@ -307,6 +307,7 @@ bool SkeletonGraphicsWidget::mouseMove(QMouseEvent *event) } } m_lastScenePos = mouseScenePos; + m_moveHappened = true; return true; } } @@ -381,7 +382,8 @@ bool SkeletonGraphicsWidget::mouseRelease(QMouseEvent *event) } if (m_moveStarted) { m_moveStarted = false; - emit groupOperationAdded(); + if (m_moveHappened) + emit groupOperationAdded(); } if (m_rangeSelectionStarted) { m_selectionItem->hide(); @@ -477,9 +479,12 @@ bool SkeletonGraphicsWidget::mousePress(QMouseEvent *event) } if (!m_rangeSelectionSet.empty()) { if (!QGuiApplication::queryKeyboardModifiers().testFlag(Qt::ControlModifier)) { - m_moveStarted = true; - m_lastScenePos = mouseEventScenePos(event); - processed = true; + if (!m_moveStarted) { + m_moveStarted = true; + m_lastScenePos = mouseEventScenePos(event); + m_moveHappened = false; + processed = true; + } } } if (processed) { diff --git a/src/skeletongraphicswidget.h b/src/skeletongraphicswidget.h index 21a07eba..7096e3ae 100644 --- a/src/skeletongraphicswidget.h +++ b/src/skeletongraphicswidget.h @@ -331,6 +331,7 @@ private: bool m_rangeSelectionStarted; std::set m_rangeSelectionSet; bool m_mouseEventFromSelf; + bool m_moveHappened; }; class SkeletonGraphicsContainerWidget : public QWidget