r23415 by jghali - Group undo actions when moving line points on canvas

scribus-commit scribus-commit at lists.scribus.net
Tue Dec 10 09:18:50 UTC 2019


Author: jghali
Date: Tue Dec 10 09:18:50 2019
New Revision: 23415

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23415
Log:
Group undo actions when moving line points on canvas

Modified:
    trunk/Scribus/scribus/canvasgesture_linemove.cpp
    trunk/Scribus/scribus/canvasgesture_linemove.h

Modified: trunk/Scribus/scribus/canvasgesture_linemove.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23415&path=/trunk/Scribus/scribus/canvasgesture_linemove.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_linemove.cpp	(original)
+++ trunk/Scribus/scribus/canvasgesture_linemove.cpp	Tue Dec 10 09:18:50 2019
@@ -24,12 +24,17 @@
 #include "pageitem_line.h"
 #include "scribusview.h"
 #include "selection.h"
+#include "undomanager.h"
 #include "util_math.h"
 
-
 void LineMove::clear()
 {
 	m_haveLineItem = false;
+	if (m_transaction.isStarted())
+	{
+		m_transaction.cancel();
+		m_transaction.reset();
+	}
 }
 
 
@@ -100,10 +105,11 @@
 
 
 
-void LineMove::deactivate(bool flag)
+void LineMove::deactivate(bool forGesture)
 {
 //	qDebug() << "LineMove::deactivate" << flag;
-	m_haveLineItem = false;
+	if (!forGesture)
+		clear();
 }
 
 
@@ -139,6 +145,12 @@
 	}
 	if (m_haveLineItem)
 	{
+		if (!m_transaction)
+		{
+			QString targetName = line->getUName();
+			QPixmap* targetIcon = line->getUPixmap();
+			m_transaction = Um::instance()->beginTransaction(targetName, targetIcon, Um::Resize, "", Um::IResize);
+		}	
 		adjustBounds(m, false);
 		m_initialBounds = m_bounds;
 		m->accept();
@@ -171,6 +183,11 @@
 		m_view->resetMousePressed();
 		m_line->checkChanges();
 		m_line->update();
+	}
+	if (m_transaction.isStarted())
+	{
+		m_transaction.commit();
+		m_transaction.reset();
 	}
 	m->accept();
 	m_canvas->update();

Modified: trunk/Scribus/scribus/canvasgesture_linemove.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23415&path=/trunk/Scribus/scribus/canvasgesture_linemove.h
==============================================================================
--- trunk/Scribus/scribus/canvasgesture_linemove.h	(original)
+++ trunk/Scribus/scribus/canvasgesture_linemove.h	Tue Dec 10 09:18:50 2019
@@ -23,6 +23,7 @@
 #include "scribusapi.h"
 #include "canvasgesture.h"
 #include "canvasmode.h"
+#include "undotransaction.h"
 
 class QDragEnterEvent;
 class QDragMoveEvent;
@@ -89,6 +90,8 @@
 	QRectF    m_bounds;
 	QRectF    m_initialBounds;
 	PageItem* m_line;
+	UndoTransaction m_transaction;
+
 	void adjustBounds(QMouseEvent* m, bool updateCanvas = true);
 	void doResize();
 	void setRotation(double rot);




More information about the scribus-commit mailing list