Fix bug in Valentina.

Each QGaphicsItem should make accepted mouse press event if it accept an event.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-10-31 10:31:50 +02:00
parent 790e276102
commit e9abab4eb2
13 changed files with 39 additions and 19 deletions

View File

@ -321,7 +321,7 @@ void VAbstractSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
*/
void VAbstractSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
if (IsSelectedByReleaseEvent(this, event))
{
emit ChoosedTool(m_id, sceneType);
}

View File

@ -323,6 +323,7 @@ void VToolBasePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
event->accept();
}
}
VToolSinglePoint::mousePressEvent(event);

View File

@ -184,9 +184,10 @@ void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
else
{
if (event->button() == Qt::LeftButton)
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
PointChoosed();
event->accept();
}
}
}
@ -239,7 +240,7 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (selectionType == SelectionType::ByMouseRelease)
{
if (event->button() == Qt::LeftButton && contains(event->pos()))
if (IsSelectedByReleaseEvent(this, event))
{
PointChoosed();
}

View File

@ -226,7 +226,7 @@ void VNodePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
*/
void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
if (IsSelectedByReleaseEvent(this, event))
{
emit ChoosedTool(m_id, SceneObject::Point);
}

View File

@ -1107,6 +1107,7 @@ void VToolSeamAllowance::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
doc->SelectedDetail(m_id);
emit ChoosedTool(m_id, SceneObject::Detail);
event->accept();
}
}
}
@ -1121,7 +1122,7 @@ void VToolSeamAllowance::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if (selectionType == SelectionType::ByMouseRelease)
{
if (event->button() == Qt::LeftButton && contains(event->pos()))
if (IsSelectedByReleaseEvent(this, event))
{
doc->SelectedDetail(m_id);
emit ChoosedTool(m_id, SceneObject::Detail);

View File

@ -31,6 +31,7 @@
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
static const qreal defPointRadiusPixel = (2./*mm*/ / 25.4) * PrintDPI;
@ -168,3 +169,11 @@ void GraphicsItemHighlightSelected(const QRectF &boundingRect, qreal itemPenWidt
painter->setBrush(Qt::NoBrush);
painter->drawRect(boundingRect.adjusted(pad, pad, -pad, -pad));
}
//---------------------------------------------------------------------------------------------------------------------
bool IsSelectedByReleaseEvent(QGraphicsItem *item, QGraphicsSceneMouseEvent *event)
{
SCASSERT(item != nullptr)
return event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick
&& item->contains(event->pos());
}

View File

@ -44,6 +44,9 @@ class QColor;
class QRectF;
class QPainterPath;
class QPen;
class QGraphicsSceneMouseEvent;
bool IsSelectedByReleaseEvent(QGraphicsItem *item, QGraphicsSceneMouseEvent *event);
qreal SceneScale(QGraphicsScene *scene);

View File

@ -217,6 +217,7 @@ void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (freeAngle || freeLength)
{
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
event->accept();
}
// Somehow clicking on notselectable object do not clean previous selections.

View File

@ -280,6 +280,8 @@ void VGrainlineItem::mousePressEvent(QGraphicsSceneMouseEvent* pME)
return;
}
pME->accept();
m_ptStartPos = pos();
m_ptStartMove = pME->scenePos();
m_dStartLength = m_dLength;

View File

@ -259,6 +259,7 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
event->accept();
}
}
if (selectionType == SelectionType::ByMouseRelease)
@ -267,7 +268,11 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
else
{
emit PointChoosed();
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
emit PointChoosed();
event->accept();
}
}
}
@ -282,7 +287,7 @@ void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
if (selectionType == SelectionType::ByMouseRelease && contains(event->pos()))
if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event))
{
emit PointChoosed();
}

View File

@ -104,9 +104,10 @@ void VSimpleCurve::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
else
{
if (event->button() == Qt::LeftButton)
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
emit Choosed(id);
event->accept();
}
}
}
@ -114,12 +115,9 @@ void VSimpleCurve::mousePressEvent(QGraphicsSceneMouseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
void VSimpleCurve::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (selectionType == SelectionType::ByMouseRelease)
if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event))
{
if (event->button() == Qt::LeftButton && contains(event->pos()))
{
emit Choosed(id);
}
emit Choosed(id);
}
QGraphicsPathItem::mouseReleaseEvent(event);
}

View File

@ -162,9 +162,10 @@ void VSimplePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
}
else
{
if (event->button() == Qt::LeftButton)
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
{
emit Choosed(id);
event->accept();
}
}
}
@ -175,12 +176,9 @@ void VSimplePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (not m_visualizationMode)
{
if (selectionType == SelectionType::ByMouseRelease)
if (selectionType == SelectionType::ByMouseRelease && IsSelectedByReleaseEvent(this, event))
{
if (event->button() == Qt::LeftButton && contains(event->pos()))
{
emit Choosed(id);
}
emit Choosed(id);
}
VScenePoint::mouseReleaseEvent(event);
}

View File

@ -384,6 +384,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
return;
}
pME->accept();
// record the parameters of the mouse press. Specially record the position
// of the press as the origin for the following operations
m_ptStartPos = pos();