Element editor : Add animation for some undo/redo

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4060 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-07-20 21:06:00 +00:00
parent 50d98b2167
commit 012ba2ccd7
17 changed files with 278 additions and 39 deletions

View File

@@ -17,7 +17,7 @@
*/
#include "customelementgraphicpart.h"
#include "elementscene.h"
#include "editorcommands.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
/**
* @brief CustomElementGraphicPart::CustomElementGraphicPart
@@ -40,7 +40,6 @@ CustomElementGraphicPart::CustomElementGraphicPart(QETElementEditor *editor, QGr
#if QT_VERSION >= 0x040600
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
#endif
setAcceptedMouseButtons(Qt::LeftButton);
setAcceptHoverEvents(true);
}
@@ -462,7 +461,12 @@ void CustomElementGraphicPart::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
void CustomElementGraphicPart::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if((event->button() & Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable) && m_origin_pos != pos())
elementScene()->stackAction(new MovePartsCommand(pos() - m_origin_pos, 0, QList<QGraphicsItem*>{this}));
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(this, "pos", QVariant(m_origin_pos), QVariant(pos()));
undo->setText(tr("Déplacer une primitive"));
undo->enableAnimation();
elementScene()->undoStack().push(undo);
}
QGraphicsObject::mouseReleaseEvent(event);
}