diff --git a/editor/parttext.cpp b/editor/parttext.cpp index a7f180b77..19f00fba9 100644 --- a/editor/parttext.cpp +++ b/editor/parttext.cpp @@ -17,6 +17,7 @@ */ #include "parttext.h" #include "texteditor.h" +#include "editorcommands.h" #include "elementscene.h" #include "qetapp.h" @@ -126,6 +127,18 @@ QPointF PartText::margin() const { */ void PartText::focusOutEvent(QFocusEvent *e) { QGraphicsTextItem::focusOutEvent(e); + if (previous_text != toPlainText()) { + undoStack().push( + new ChangePartCommand( + TextEditor::tr("texte") + " " + name(), + this, + "text", + previous_text, + toPlainText() + ) + ); + previous_text = toPlainText(); + } setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); } @@ -136,6 +149,7 @@ void PartText::focusOutEvent(QFocusEvent *e) { void PartText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) { setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable); setTextInteractionFlags(Qt::TextEditorInteraction); + previous_text = toPlainText(); QGraphicsTextItem::mouseDoubleClickEvent(e); setFocus(Qt::MouseFocusReason); } diff --git a/editor/parttext.h b/editor/parttext.h index 5053f225b..97cbbcfea 100644 --- a/editor/parttext.h +++ b/editor/parttext.h @@ -63,5 +63,6 @@ class PartText : public QGraphicsTextItem, public CustomElementPart { private: QPointF margin() const; + QString previous_text; }; #endif diff --git a/editor/parttextfield.cpp b/editor/parttextfield.cpp index 2b1d342ce..80c012a2a 100644 --- a/editor/parttextfield.cpp +++ b/editor/parttextfield.cpp @@ -17,6 +17,7 @@ */ #include "parttextfield.h" #include "textfieldeditor.h" +#include "editorcommands.h" #include "qetapp.h" /** @@ -144,6 +145,18 @@ QPointF PartTextField::margin() const { */ void PartTextField::focusOutEvent(QFocusEvent *e) { QGraphicsTextItem::focusOutEvent(e); + if (previous_text != toPlainText()) { + undoStack().push( + new ChangePartCommand( + TextFieldEditor::tr("texte") + " " + name(), + this, + "text", + previous_text, + toPlainText() + ) + ); + previous_text = toPlainText(); + } setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); } @@ -154,6 +167,7 @@ void PartTextField::focusOutEvent(QFocusEvent *e) { void PartTextField::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) { setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable); setTextInteractionFlags(Qt::TextEditorInteraction); + previous_text = toPlainText(); QGraphicsTextItem::mouseDoubleClickEvent(e); setFocus(Qt::MouseFocusReason); } diff --git a/editor/parttextfield.h b/editor/parttextfield.h index a2c2e9fb5..9fc407230 100644 --- a/editor/parttextfield.h +++ b/editor/parttextfield.h @@ -69,5 +69,6 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart { private: QPointF margin() const; + QString previous_text; }; #endif diff --git a/editor/qetelementeditor.cpp b/editor/qetelementeditor.cpp index 21537691a..e00e2e353 100644 --- a/editor/qetelementeditor.cpp +++ b/editor/qetelementeditor.cpp @@ -239,6 +239,7 @@ void QETElementEditor::setupActions() { connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateMenus())); connect(&(ce_scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(slot_updateMenus())); connect(&(ce_scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(slot_updateTitle())); + connect(&(ce_scene -> undoStack()), SIGNAL(indexChanged(int)), this, SLOT(slot_updatePartsList())); } /**