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:
parent
790e276102
commit
e9abab4eb2
|
@ -321,7 +321,7 @@ void VAbstractSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
*/
|
*/
|
||||||
void VAbstractSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void VAbstractSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton)
|
if (IsSelectedByReleaseEvent(this, event))
|
||||||
{
|
{
|
||||||
emit ChoosedTool(m_id, sceneType);
|
emit ChoosedTool(m_id, sceneType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,6 +323,7 @@ void VToolBasePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||||
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VToolSinglePoint::mousePressEvent(event);
|
VToolSinglePoint::mousePressEvent(event);
|
||||||
|
|
|
@ -184,9 +184,10 @@ void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
PointChoosed();
|
PointChoosed();
|
||||||
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,7 +240,7 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (selectionType == SelectionType::ByMouseRelease)
|
if (selectionType == SelectionType::ByMouseRelease)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && contains(event->pos()))
|
if (IsSelectedByReleaseEvent(this, event))
|
||||||
{
|
{
|
||||||
PointChoosed();
|
PointChoosed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,7 +226,7 @@ void VNodePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
*/
|
*/
|
||||||
void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton)
|
if (IsSelectedByReleaseEvent(this, event))
|
||||||
{
|
{
|
||||||
emit ChoosedTool(m_id, SceneObject::Point);
|
emit ChoosedTool(m_id, SceneObject::Point);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1107,6 +1107,7 @@ void VToolSeamAllowance::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
doc->SelectedDetail(m_id);
|
doc->SelectedDetail(m_id);
|
||||||
emit ChoosedTool(m_id, SceneObject::Detail);
|
emit ChoosedTool(m_id, SceneObject::Detail);
|
||||||
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1121,7 +1122,7 @@ void VToolSeamAllowance::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
|
||||||
if (selectionType == SelectionType::ByMouseRelease)
|
if (selectionType == SelectionType::ByMouseRelease)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && contains(event->pos()))
|
if (IsSelectedByReleaseEvent(this, event))
|
||||||
{
|
{
|
||||||
doc->SelectedDetail(m_id);
|
doc->SelectedDetail(m_id);
|
||||||
emit ChoosedTool(m_id, SceneObject::Detail);
|
emit ChoosedTool(m_id, SceneObject::Detail);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
|
|
||||||
static const qreal defPointRadiusPixel = (2./*mm*/ / 25.4) * PrintDPI;
|
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->setBrush(Qt::NoBrush);
|
||||||
painter->drawRect(boundingRect.adjusted(pad, pad, -pad, -pad));
|
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());
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,9 @@ class QColor;
|
||||||
class QRectF;
|
class QRectF;
|
||||||
class QPainterPath;
|
class QPainterPath;
|
||||||
class QPen;
|
class QPen;
|
||||||
|
class QGraphicsSceneMouseEvent;
|
||||||
|
|
||||||
|
bool IsSelectedByReleaseEvent(QGraphicsItem *item, QGraphicsSceneMouseEvent *event);
|
||||||
|
|
||||||
qreal SceneScale(QGraphicsScene *scene);
|
qreal SceneScale(QGraphicsScene *scene);
|
||||||
|
|
||||||
|
|
|
@ -217,6 +217,7 @@ void VControlPointSpline::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (freeAngle || freeLength)
|
if (freeAngle || freeLength)
|
||||||
{
|
{
|
||||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||||
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Somehow clicking on notselectable object do not clean previous selections.
|
// Somehow clicking on notselectable object do not clean previous selections.
|
||||||
|
|
|
@ -280,6 +280,8 @@ void VGrainlineItem::mousePressEvent(QGraphicsSceneMouseEvent* pME)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pME->accept();
|
||||||
|
|
||||||
m_ptStartPos = pos();
|
m_ptStartPos = pos();
|
||||||
m_ptStartMove = pME->scenePos();
|
m_ptStartMove = pME->scenePos();
|
||||||
m_dStartLength = m_dLength;
|
m_dStartLength = m_dLength;
|
||||||
|
|
|
@ -259,6 +259,7 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
SetItemOverrideCursor(this, cursorArrowCloseHand, 1, 1);
|
||||||
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selectionType == SelectionType::ByMouseRelease)
|
if (selectionType == SelectionType::ByMouseRelease)
|
||||||
|
@ -266,8 +267,12 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
event->accept(); // This help for not selectable items still receive mouseReleaseEvent events
|
event->accept(); // This help for not selectable items still receive mouseReleaseEvent events
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
emit PointChoosed();
|
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();
|
emit PointChoosed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,9 +104,10 @@ void VSimpleCurve::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
emit Choosed(id);
|
emit Choosed(id);
|
||||||
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,13 +115,10 @@ void VSimpleCurve::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSimpleCurve::mouseReleaseEvent(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);
|
QGraphicsPathItem::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,9 +162,10 @@ void VSimplePoint::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick)
|
||||||
{
|
{
|
||||||
emit Choosed(id);
|
emit Choosed(id);
|
||||||
|
event->accept();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,13 +176,10 @@ void VSimplePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (not m_visualizationMode)
|
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);
|
VScenePoint::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,6 +384,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pME->accept();
|
||||||
// record the parameters of the mouse press. Specially record the position
|
// record the parameters of the mouse press. Specially record the position
|
||||||
// of the press as the origin for the following operations
|
// of the press as the origin for the following operations
|
||||||
m_ptStartPos = pos();
|
m_ptStartPos = pos();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user