Primitive part : Change the cursor shape, according to the current available behavior

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4084 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-08-03 17:26:57 +00:00
parent 3c327009a5
commit 54ac875330
12 changed files with 209 additions and 63 deletions

View File

@@ -145,7 +145,7 @@ QPainterPath PartEllipse::shape() const
shape.addEllipse(m_rect);
QPainterPathStroker pps;
pps.setWidth(penWeight());
pps.setWidth(m_hovered? penWeight()+SHADOWS_HEIGHT : penWeight());
shape = pps.createStroke(shape);
if (isSelected())
@@ -166,6 +166,29 @@ QPainterPath PartEllipse::shadowShape() const
return (pps.createStroke(shape));
}
void PartEllipse::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
if (!isSelected())
{
CustomElementGraphicPart::hoverMoveEvent(event);
return;
}
int handler = m_handler.pointIsHoverHandler(event->pos(), m_handler.pointsForRect(m_rect));
if (handler >= 0)
{
if (handler == 0 || handler == 2 || handler == 5 || handler == 7)
setCursor(Qt::SizeAllCursor);
else if (handler == 1 || handler == 6)
setCursor(Qt::SizeVerCursor);
else if (handler == 3 || handler == 4)
setCursor(Qt::SizeHorCursor);
}
else
CustomElementGraphicPart::hoverMoveEvent(event);
}
/**
* @brief PartEllipse::mousePressEvent
* Handle mouse press event
@@ -173,21 +196,24 @@ QPainterPath PartEllipse::shadowShape() const
*/
void PartEllipse::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (isSelected() && event->button() == Qt::LeftButton)
if (event->button() == Qt::LeftButton)
{
m_handler_index = m_handler.pointIsHoverHandler(event->pos(), m_handler.pointsForRect(m_rect));
if(m_handler_index >= 0 && m_handler_index <= 7) //User click on an handler
setCursor(Qt::ClosedHandCursor);
if (isSelected())
{
m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
m_undo_command->setText(tr("Modifier une ellipse"));
m_undo_command->enableAnimation();
m_handler_index = m_handler.pointIsHoverHandler(event->pos(), m_handler.pointsForRect(m_rect));
if(m_handler_index >= 0 && m_handler_index <= 7) //User click on an handler
{
m_undo_command = new QPropertyUndoCommand(this, "rect", QVariant(m_rect));
m_undo_command->setText(tr("Modifier une ellipse"));
m_undo_command->enableAnimation();
return;
}
}
else
CustomElementGraphicPart::mousePressEvent(event);
}
else
CustomElementGraphicPart::mousePressEvent(event);
CustomElementGraphicPart::mousePressEvent(event);
}
/**
@@ -196,7 +222,7 @@ void PartEllipse::mousePressEvent(QGraphicsSceneMouseEvent *event)
* @param event
*/
void PartEllipse::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
{
if(m_handler_index >= 0 && m_handler_index <= 7)
{
QPointF pos_ = event->modifiers() == Qt::ControlModifier ? event->pos() : mapFromScene(elementScene()->snapToGrid(event->scenePos()));
@@ -214,6 +240,9 @@ void PartEllipse::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
*/
void PartEllipse::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
setCursor(Qt::OpenHandCursor);
if (m_handler_index >= 0 && m_handler_index <= 7)
{
if (!m_rect.isValid())