Skip to content

Commit

Permalink
[TD]fix multiple dimension drag
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Aug 10, 2022
1 parent 730b143 commit cb96332
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/Mod/TechDraw/Gui/QGIViewDimension.cpp
Expand Up @@ -95,7 +95,14 @@ enum SnapMode{
HorizontalSnap
};

QGIDatumLabel::QGIDatumLabel()
enum DragState {
NoDrag,
DragStarted,
Dragging };


QGIDatumLabel::QGIDatumLabel() :
m_dragState(NoDrag)
{
verticalSep = false;
posX = 0;
Expand Down Expand Up @@ -136,10 +143,16 @@ QVariant QGIDatumLabel::itemChange(GraphicsItemChange change, const QVariant &va
setPrettySel();
} else {
setPrettyNormal();
if (m_dragState == Dragging) {
//stop the drag if we are no longer selected.
m_dragState = NoDrag;
Q_EMIT dragFinished();
}
}
update();

} else if(change == ItemPositionHasChanged && scene()) {
setLabelCenter();
m_dragState = Dragging;
Q_EMIT dragging(m_ctrl);
}

Expand All @@ -164,11 +177,9 @@ void QGIDatumLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
{
// Base::Console().Message("QGIDL::mouseReleaseEvent()\n");
m_ctrl = false;
if (QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton))
.length() > 0) {
if (scene() && this == scene()->mouseGrabberItem()) {
Q_EMIT dragFinished();
}
if (m_dragState == Dragging) {
m_dragState = NoDrag;
Q_EMIT dragFinished();
}

QGraphicsItem::mouseReleaseEvent(event);
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/TechDraw/Gui/QGIViewDimension.h
Expand Up @@ -136,6 +136,8 @@ Q_OBJECT

bool m_isFramed;
double m_lineWidth;

int m_dragState;

private:
};
Expand Down

0 comments on commit cb96332

Please sign in to comment.