mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-22 01:10:53 +01:00
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:
@@ -16,7 +16,8 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "partpolygon.h"
|
||||
#include "editorcommands.h"
|
||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||
#include "elementscene.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -29,13 +30,16 @@ PartPolygon::PartPolygon(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
CustomElementGraphicPart(editor, parent),
|
||||
m_closed(false),
|
||||
m_handler(10),
|
||||
m_handler_index(-1)
|
||||
m_handler_index(-1),
|
||||
m_undo_command(nullptr)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief PartPolygon::~PartPolygon
|
||||
*/
|
||||
PartPolygon::~PartPolygon() {}
|
||||
PartPolygon::~PartPolygon() {
|
||||
if(m_undo_command) delete m_undo_command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief PartPolygon::paint
|
||||
@@ -247,7 +251,10 @@ void PartPolygon::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
m_handler_index = m_handler.pointIsHoverHandler(event->pos(), m_polygon);
|
||||
|
||||
if(m_handler_index >= 0) //User click on an handler
|
||||
m_undo_command = new ChangePartCommand(tr("Polygone"), this, "polygon", QVariant(m_polygon));
|
||||
{
|
||||
m_undo_command = new QPropertyUndoCommand(this, "polygon", QVariant(m_polygon));
|
||||
m_undo_command->setText(tr("Modifier un polygone"));
|
||||
}
|
||||
else
|
||||
CustomElementGraphicPart::mousePressEvent(event);
|
||||
}
|
||||
@@ -282,7 +289,7 @@ void PartPolygon::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
if (m_handler_index >= 0)
|
||||
{
|
||||
m_undo_command->setNewValue(QVariant(m_polygon));
|
||||
elementScene()->stackAction(m_undo_command);
|
||||
elementScene()->undoStack().push(m_undo_command);
|
||||
m_undo_command = nullptr;
|
||||
m_handler_index = -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user