View Issue Details

IDProjectCategoryView StatusLast Update
0010978ScribusUsabilitypublic2013-08-09 06:37
ReporterChelen Assigned ToChelen  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Target Version1.5.0svnFixed in Version1.5.0svn 
Summary0010978: [PATCH] Snap to Item functionnality and other features
DescriptionFix save flag issue in edit mode (Bug 10865)
Snap to Item feature
Cleaning up of undo work to avoid multiple creation and deletion of undostate
bug 10861 : return to last save issue
bug 10759 : Fix default value for image scaling
bug 10943 : Fix of bezier crash issue
bug 10944 : improve image import
bug 10719 : first fix of behaviour between guides and ruler.
bug 10951
bug 10171 : default step for zooming
TagsNo tags attached.
Patch

Relationships

related to 0010861 closedChelen On Revert_to_Saved undo history is not clear 
related to 0010759 closedChelen Image size properties should be locked initially 
related to 0010943 closedChelen Leaving the Bezier tool without drawing anything crashes scribus 
related to 0010944 closedChelen Improve multiple image import 
related to 0010719 closedChelen Guides Manager doesn't follow coordinate origin change 
related to 0010951 closedChelen snap for resize : only effective possibilites should draw green lines 
related to 0010171 confirmed Default zoom stepping to big 
related to 0010865 closedChelen Usage of cmd / alt / ctrl / shift keys causes a change in file 

Activities

Chelen

2012-07-31 10:58

reporter  

snap.diff (158,105 bytes)   
Index: scribus/scribus.h
===================================================================
--- scribus/scribus.h	(révision 17743)
+++ scribus/scribus.h	(copie de travail)
@@ -478,6 +478,7 @@
 	void ToggleGuides();
 	void ToggleBase();
 	void ToggleUGuides();
+	void ToggleUElements();
 	void EditTabs();
 	void SearchText();
 	void imageEditorExited(int, QProcess::ExitStatus);
Index: scribus/canvasmode.h
===================================================================
--- scribus/canvasmode.h	(révision 17743)
+++ scribus/canvasmode.h	(copie de travail)
@@ -123,6 +123,8 @@
 	/** Draws the regular selection marker */
 	void drawSelection(QPainter* psx, bool drawHandles);
 	/** Draws an outline of selected items */
+	void drawSnapLine(QPainter* psx);
+	/** Draws an outline of selected items */
 	void drawOutline(QPainter* p, double scalex=1.0, double scaley=1.0, double deltax=0.0, double deltay=0.0);
 #ifdef GESTURE_FRAME_PREVIEW
 	// I don’t know why the methods above have been implemented here and left non-virtual.
@@ -146,6 +148,7 @@
 	Canvas * const m_canvas;
 	ScribusDoc * const m_doc;
 	PanGesture * m_panGesture;
+	double xSnap,ySnap;
 	
 	void setResizeCursor(int how, double rot = 0.0);
 	bool commonMouseMove(QMouseEvent *m);
Index: scribus/canvasmode_editweldpoint.cpp
===================================================================
--- scribus/canvasmode_editweldpoint.cpp	(révision 17743)
+++ scribus/canvasmode_editweldpoint.cpp	(copie de travail)
@@ -349,7 +349,7 @@
 	FPoint npfN;
 	double nx = mousePointDoc.x();
 	double ny = mousePointDoc.y();
-	if (!m_doc->ApplyGuides(&nx, &ny))
+	if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 		npfN = m_doc->ApplyGridF(FPoint(nx, ny));
 	else
 		npfN = FPoint(nx, ny);
Index: scribus/canvasmode_imageimport.cpp
===================================================================
--- scribus/canvasmode_imageimport.cpp	(révision 17743)
+++ scribus/canvasmode_imageimport.cpp	(copie de travail)
@@ -52,8 +52,12 @@
 		while(!(m_doc->m_Selection->itemAt(0)->isImageFrame()))
 			m_doc->m_Selection->removeFirst();
 		if(!m_doc->m_Selection->isEmpty())
+		{
 			setImage(m_doc->m_Selection->itemAt(0));
-		m_view->requestMode(submodePaintingDone);
+			m_view->requestMode(submodePaintingDone);
+		}
+		else
+			newToolTip(l.first());
 	}
 	else
 		newToolTip(l.first());
@@ -71,7 +75,6 @@
 	{
 		thumb = thumb.scaled(80,80,Qt::KeepAspectRatio);
 		p.drawImage((80 - thumb.width()) / 2, (80 - thumb.height()) / 2, thumb);
-		p.end();
 		QBuffer buffer;
 		buffer.open(QIODevice::WriteOnly);
 		pm.save(&buffer, "PNG");
@@ -113,6 +116,9 @@
 		case Qt::Key_Backtab:
 			imageList.append(imageList.takeFirst());
 			break;
+		case Qt::Key_Backspace:
+			imageList.removeFirst();
+			break;
 		case Qt::Key_Escape:
 			imageList.clear();
 			break;
@@ -162,6 +168,17 @@
 	QToolTip::showText(m->globalPos(), tipText, qApp->activeWindow());
 	QToolTip::showText(m->globalPos(), tipText + "<b></b>", qApp->activeWindow());
 	m->accept();
+	PageItem *item;
+	if((item = m_canvas->itemUnderCursor(m->globalPos())) != NULL)
+	{
+		PageItem_ImageFrame *currItem;
+		if((currItem = item->asImageFrame()) != NULL)
+			qApp->changeOverrideCursor(QCursor(loadIcon("DrawImageFrame.xpm")));
+		else
+			qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
+	}
+	else
+		qApp->changeOverrideCursor(QCursor(loadIcon("DrawImageFrame.xpm")));
 	if (commonMouseMove(m))
 		return;
 }
Index: scribus/canvasmode_edit.cpp
===================================================================
--- scribus/canvasmode_edit.cpp	(révision 17743)
+++ scribus/canvasmode_edit.cpp	(copie de travail)
@@ -728,7 +728,7 @@
 				m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
 				double nx = gx;
 				double ny = gy;
-				if (!m_doc->ApplyGuides(&nx, &ny))
+				if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 				{
 					FPoint npx = m_doc->ApplyGridF(FPoint(gx, gy));
 					FPoint npw = m_doc->ApplyGridF(FPoint(gx+gw, gy+gh));
@@ -746,7 +746,7 @@
 				m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
 				nx = gx+gw;
 				ny = gy+gh;
-				if (m_doc->ApplyGuides(&nx, &ny))
+				if (m_doc->ApplyGuides(&nx, &ny) || m_doc->ApplyGuides(&nx,&ny,true))
 					m_doc->moveGroup(nx-(gx+gw), ny-(gy+gh), false);
 				m_doc->m_Selection->setGroupRect();
 			}
@@ -757,7 +757,7 @@
 				{
 					double nx = currItem->xPos();
 					double ny = currItem->yPos();
-					if (!m_doc->ApplyGuides(&nx, &ny))
+					if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 					{
 						m_doc->m_Selection->setGroupRect();
 						double gx, gy, gh, gw;
Index: scribus/plugins/fileloader/scribus13format/scribus13format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus13format/scribus13format.cpp	(révision 17743)
+++ scribus/plugins/fileloader/scribus13format/scribus13format.cpp	(copie de travail)
@@ -402,10 +402,10 @@
 		m_Doc->itemToolPrefs().shapeFillColorShade     = dc.attribute("BRUSHSHADE", "100").toInt();
 		m_Doc->opToolPrefs().magMin     = dc.attribute("MAGMIN", "1").toInt();
 		m_Doc->opToolPrefs().magMax     = dc.attribute("MAGMAX", "3200").toInt();
-		m_Doc->opToolPrefs().magStep    = dc.attribute("MAGSTEP", "200").toInt();
+		m_Doc->opToolPrefs().magStep    = dc.attribute("MAGSTEP", "125").toInt();
 		//CB Reset doc zoom step value to 200% instead of old values.
 		if (m_Doc->opToolPrefs().magStep <= 100)
-			m_Doc->opToolPrefs().magStep = 200;
+			m_Doc->opToolPrefs().magStep = 125;
 		m_Doc->itemToolPrefs().textTabFillChar = dc.attribute("TabFill","");
 		m_Doc->itemToolPrefs().textTabWidth   = ScCLocale::toDoubleC(dc.attribute("TabWidth"), 36.0);
 		if (dc.hasAttribute("CPICT"))
Index: scribus/plugins/fileloader/scribus150format/scribus150format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(révision 17743)
+++ scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(copie de travail)
@@ -1938,6 +1938,7 @@
 	m_Doc->rulerXoffset = attrs.valueAsDouble("rulerXoffset", 0.0);
 	m_Doc->rulerYoffset = attrs.valueAsDouble("rulerYoffset", 0.0);
 	m_Doc->SnapGuides   = attrs.valueAsBool("SnapToGuides", false);
+	m_Doc->SnapElement  = attrs.valueAsBool("SnapToElement", false);
 	m_Doc->useRaster    = attrs.valueAsBool("SnapToGrid", false);
 	
 	m_Doc->setAutoSave(attrs.valueAsBool("AutoSave", false));
@@ -2127,13 +2128,13 @@
 	doc->itemToolPrefs().calligrapicPenStyle = static_cast<Qt::PenStyle>(attrs.valueAsInt("calligrapicPenStyle"));
 	doc->opToolPrefs().magMin      = attrs.valueAsInt("MAGMIN", 1);
 	doc->opToolPrefs().magMax      = attrs.valueAsInt("MAGMAX", 3200);
-	doc->opToolPrefs().magStep     = attrs.valueAsInt("MAGSTEP", 200);
+	doc->opToolPrefs().magStep     = attrs.valueAsInt("MAGSTEP", 125);
 	doc->opToolPrefs().dispX       = attrs.valueAsDouble("dispX", 10.0);
 	doc->opToolPrefs().dispY       = attrs.valueAsDouble("dispY", 10.0);
 	doc->opToolPrefs().constrain   = attrs.valueAsDouble("constrain", 15.0);
 	//CB Reset doc zoom step value to 200% instead of old values.
 	if (doc->opToolPrefs().magStep <= 100)
-		doc->opToolPrefs().magStep = 200;
+		doc->opToolPrefs().magStep = 125;
 	doc->itemToolPrefs().textTabFillChar = attrs.valueAsString("TabFill","");
 	doc->itemToolPrefs().textTabWidth   = attrs.valueAsDouble("TabWidth", 36.0);
 	if (attrs.hasAttribute("CPICT"))
@@ -3643,8 +3644,10 @@
 	uint itemCount1 = m_Doc->Items->count();
 	bool savedAlignGrid = m_Doc->useRaster;
 	bool savedAlignGuides = m_Doc->SnapGuides;
+	bool savedAlignElement = m_Doc->SnapElement;
 	m_Doc->useRaster = false;
 	m_Doc->SnapGuides = false;
+	m_Doc->SnapElement = false;
 
 	QStringRef tagName = reader.name();
 	while(!reader.atEnd() && !reader.hasError())
@@ -3709,6 +3712,7 @@
 
 	doc->useRaster  = savedAlignGrid;
 	doc->SnapGuides = savedAlignGuides;
+	doc->SnapElement = savedAlignElement;
 	if (!success)
 	{
 		return false;
Index: scribus/plugins/fileloader/scribus134format/scribus134format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(révision 17743)
+++ scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(copie de travail)
@@ -1018,13 +1018,13 @@
 	doc->itemToolPrefs().shapeFillColorShade      = attrs.valueAsInt("BRUSHSHADE", 100);
 	doc->opToolPrefs().magMin      = attrs.valueAsInt("MAGMIN", 1);
 	doc->opToolPrefs().magMax      = attrs.valueAsInt("MAGMAX", 3200);
-	doc->opToolPrefs().magStep     = attrs.valueAsInt("MAGSTEP", 200);
+	doc->opToolPrefs().magStep     = attrs.valueAsInt("MAGSTEP", 125);
 	doc->opToolPrefs().dispX       = attrs.valueAsDouble("dispX", 10.0);
 	doc->opToolPrefs().dispY       = attrs.valueAsDouble("dispY", 10.0);
 	doc->opToolPrefs().constrain   = attrs.valueAsDouble("constrain", 15.0);
 	//CB Reset doc zoom step value to 200% instead of old values.
 	if (doc->opToolPrefs().magStep <= 100)
-		doc->opToolPrefs().magStep = 200;
+		doc->opToolPrefs().magStep = 125;
 	doc->itemToolPrefs().textTabFillChar = attrs.valueAsString("TabFill","");
 	doc->itemToolPrefs().textTabWidth   = attrs.valueAsDouble("TabWidth", 36.0);
 	if (attrs.hasAttribute("CPICT"))
Index: scribus/undomanager.h
===================================================================
--- scribus/undomanager.h	(révision 17743)
+++ scribus/undomanager.h	(copie de travail)
@@ -536,6 +536,7 @@
 	static QString SetFontEffect;
 	static QString ImageFrame;
 	static QString TextFrame;
+	static QString Layer;
 	static QString LatexFrame;
 	static QString ResTyp;
 	static QString Polygon;
Index: scribus/canvasgesture_linemove.cpp
===================================================================
--- scribus/canvasgesture_linemove.cpp	(révision 17743)
+++ scribus/canvasgesture_linemove.cpp	(copie de travail)
@@ -218,6 +218,7 @@
 	double nx = np2.x();
 	double ny = np2.y();
 	m_doc->ApplyGuides(&nx, &ny);
+	m_doc->ApplyGuides(&nx, &ny,true);
 	newX = nx;
 	newY = ny;
 	//>>#8099
Index: scribus/canvasmode_editmeshgradient.cpp
===================================================================
--- scribus/canvasmode_editmeshgradient.cpp	(révision 17743)
+++ scribus/canvasmode_editmeshgradient.cpp	(copie de travail)
@@ -576,7 +576,7 @@
 		FPoint npfN;
 		double nx = mousePointDoc.x();
 		double ny = mousePointDoc.y();
-		if (!m_doc->ApplyGuides(&nx, &ny))
+		if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 			npfN = m_doc->ApplyGridF(FPoint(nx, ny));
 		else
 			npfN = FPoint(nx, ny);
Index: scribus/pageitem.cpp
===================================================================
--- scribus/pageitem.cpp	(révision 17743)
+++ scribus/pageitem.cpp	(copie de travail)
@@ -1033,11 +1033,14 @@
 {
 	if(LocalRot == newRotation)
 		return;
-	SimpleState *ss = new SimpleState(Um::Rotate,"",Um::IRotate);
-	ss->set("IMAGE_ROTATION","image_rotation");
-	ss->set("OLD_ROT",LocalRot);
-	ss->set("NEW_ROT",newRotation);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::Rotate,"",Um::IRotate);
+		ss->set("IMAGE_ROTATION","image_rotation");
+		ss->set("OLD_ROT",LocalRot);
+		ss->set("NEW_ROT",newRotation);
+		undoManager->action(this,ss);
+	}
 	LocalRot = newRotation;
 	if (m_Doc->isLoading())
 		return;
@@ -1233,12 +1236,12 @@
 	}
 	if (UndoManager::undoEnabled() && createUndo) //addPARESEP is false only if linking is invoked from undo action for unlinkWithText
 	{
-		ScItemState<std::pair<PageItem*, PageItem*> > *is = new ScItemState<std::pair<PageItem*, PageItem*> >(UndoManager::LinkTextFrame);
+		ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::LinkTextFrame);
 		is->set("LINK_TEXT_FRAME", "linkTextFrame");
 		is->set("FIRST", first);
 		is->set("JOIN_POS", textLen);
 		is->set("ADDPARSEP", addPARSEP);
-		is->setItem(std::pair<PageItem*, PageItem*>(this, NextBox));
+		is->setItem(qMakePair(this, NextBox));
 		undoManager->action(this, is);
 	}
 }
@@ -1287,9 +1290,9 @@
 		NextBox = NULL;
 		if (UndoManager::undoEnabled() && createUndo)
 		{
-			ScItemState<std::pair<PageItem*, PageItem*> > *is = new ScItemState<std::pair<PageItem*, PageItem*> >(UndoManager::UnlinkTextFrame);
+			ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::UnlinkTextFrame);
 			is->set("UNLINK_TEXT_FRAME", "unlinkTextFrame");
-			is->setItem(std::pair<PageItem*, PageItem*>(this, undoNextBox));
+			is->setItem(qMakePair(this, undoNextBox));
 			undoManager->action(this, is);
 		}
 	}
@@ -1376,10 +1379,10 @@
 	}
 	if (UndoManager::undoEnabled())
 	{
-		ScItemState<std::pair<PageItem*, PageItem*> > *is = new ScItemState<std::pair<PageItem*, PageItem*> >(UndoManager::UnlinkTextFrame);
+		ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >(Um::UnlinkTextFrame);
 		is->set("UNLINK_TEXT_FRAME", "unlinkTextFrame");
 		is->set("CUT_TEXT", cutText);
-		is->setItem(std::pair<PageItem*, PageItem*>(Prev, Next));
+		is->setItem(qMakePair(Prev, Next));
 		undoManager->action(this, is);
 	}
 }
@@ -1526,7 +1529,8 @@
 {
 	if(Cols==n)
 		return;
-	if(UndoManager::undoEnabled()){
+	if(UndoManager::undoEnabled())
+	{
 		SimpleState *ss = new SimpleState(Um::Columns, "", Um::IBorder);
 		ss->set("COLUMNS", "columns");
 		ss->set("OLD_COLUMNS", Cols);
@@ -1553,23 +1557,20 @@
 {
 	if(RadRect==newRadius)
 		return;
-	SimpleState *state = new SimpleState(Um::RoundCorner,"",Um::IBorder);
-	state->set("CORNER_RADIUS","corner_radius");
-	state->set("OLD_RADIUS",RadRect);
-	state->set("NEW_RADIUS",newRadius);
-	undoManager->action(this,state);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *state = new SimpleState(Um::RoundCorner,"",Um::IBorder);
+		state->set("CORNER_RADIUS","corner_radius");
+		state->set("OLD_RADIUS",RadRect);
+		state->set("NEW_RADIUS",newRadius);
+		undoManager->action(this,state);
+	}
 	RadRect=newRadius;
 	//emit cornerRadius(RadRect);
 }
 
 
 
-
-
-
-
-
-
 /** Paints the item.
     CHANGE: cullingArea is in doc coordinates!
  */
@@ -2718,30 +2719,39 @@
 void PageItem::setMaskGradient(VGradient grad){
 	if(mask_gradient==grad)
 		return;
-	ScItemState<QPair<VGradient,VGradient> > *is = new ScItemState<QPair<VGradient,VGradient> >(Um::GradVal);
-	is->set("MASK_GRAD","mask_grad");
-	is->setItem(qMakePair(mask_gradient,grad));
-	undoManager->action(this,is);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<VGradient,VGradient> > *is = new ScItemState<QPair<VGradient,VGradient> >(Um::GradVal);
+		is->set("MASK_GRAD","mask_grad");
+		is->setItem(qMakePair(mask_gradient,grad));
+		undoManager->action(this,is);
+	}
 	mask_gradient=grad;
 }
 
 void PageItem::setFillGradient(VGradient grad){
 	if(fill_gradient==grad)
 		return;
-	ScItemState<QPair<VGradient,VGradient> > *is = new ScItemState<QPair<VGradient,VGradient> >(Um::GradVal);
-	is->set("FILL_GRAD","fill_grad");
-	is->setItem(qMakePair(fill_gradient,grad));
-	undoManager->action(this,is);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<VGradient,VGradient> > *is = new ScItemState<QPair<VGradient,VGradient> >(Um::GradVal);
+		is->set("FILL_GRAD","fill_grad");
+		is->setItem(qMakePair(fill_gradient,grad));
+		undoManager->action(this,is);
+	}
 	fill_gradient=grad;
 }
 
 void PageItem::setStrokeGradient(VGradient grad){
 	if(stroke_gradient==grad)
 		return;
-	ScItemState<QPair<VGradient,VGradient> > *is = new ScItemState<QPair<VGradient,VGradient> >(Um::GradVal);
-	is->set("STROKE_GRAD","STROKE_grad");
-	is->setItem(qMakePair(stroke_gradient,grad));
-	undoManager->action(this,is);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<VGradient,VGradient> > *is = new ScItemState<QPair<VGradient,VGradient> >(Um::GradVal);
+		is->set("STROKE_GRAD","STROKE_grad");
+		is->setItem(qMakePair(stroke_gradient,grad));
+		undoManager->action(this,is);
+	}
 	stroke_gradient=grad;
 }
 
@@ -2770,28 +2780,44 @@
 
 void PageItem::set4ColorTransparency(double t1, double t2, double t3, double t4)
 {
-	UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
+	UndoTransaction *trans = NULL;
+	if(UndoManager::undoEnabled())
+		trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
 	setGradientTransp1(t1);
 	setGradientTransp2(t2);
 	setGradientTransp3(t3);
 	setGradientTransp4(t4);
-	trans.commit();
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 }
 
 void PageItem::set4ColorShade(int t1, int t2, int t3, int t4)
 {
-	UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
+	UndoTransaction *trans = NULL;
+	if(UndoManager::undoEnabled())
+		trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
 	setGradientShade1(t1);
 	setGradientShade2(t2);
 	setGradientShade3(t3);
 	setGradientShade4(t4);
-	trans.commit();
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 }
 
 void PageItem::set4ColorColors(QString col1, QString col2, QString col3, QString col4)
 {
 	QColor tmp;
-	UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
+	UndoTransaction *trans = NULL;
+	if(UndoManager::undoEnabled())
+		trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
 	setGradientCol1(col1);
 	if (GrColorP1 != CommonStrings::None)
 	{
@@ -2948,7 +2974,12 @@
 		VisionDefectColor defect;
 		setGradientColor4(defect.convertDefect(GrColorP4QColor, m_Doc->previewVisual));
 	}
-	trans.commit();
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 }
 
 void PageItem::get4ColorGeometry(FPoint &c1, FPoint &c2, FPoint &c3, FPoint &c4)
@@ -3019,12 +3050,6 @@
 	meshPoint *mp;
 	if (forPatch)
 	{
-		UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
-		ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
-		ss->set("GRAD_MESH_COLOR","grad_mesh_color");
-		ss->set("X",x);
-		ss->set("Y",y);
-		ss->set("PATCH",true);
 		meshGradientPatch *patch = &meshGradientPatches[x];
 		switch (y)
 		{
@@ -3041,18 +3066,29 @@
 				mp = &(patch->BL);
 				break;
 		}
-		ss->set("OLD_COLOR_NAME",mp->colorName);
-		ss->set("NEW_COLOR_NAME",MColor);
-		ss->setItem(qMakePair(mp->color,MQColor));
-		ss->set("OLD_SHADE",mp->shade);
-		ss->set("NEW_SHADE",shade);
-		ss->set("OLD_TRANSP",mp->transparency);
-		ss->set("NEW_TRANSP",transparency);
+
+		UndoTransaction *trans = NULL;
+		if(UndoManager::undoEnabled())
+		{
+			trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
+			ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
+			ss->set("GRAD_MESH_COLOR","grad_mesh_color");
+			ss->set("X",x);
+			ss->set("Y",y);
+			ss->set("PATCH",true);
+			ss->set("OLD_COLOR_NAME",mp->colorName);
+			ss->set("NEW_COLOR_NAME",MColor);
+			ss->setItem(qMakePair(mp->color,MQColor));
+			ss->set("OLD_SHADE",mp->shade);
+			ss->set("NEW_SHADE",shade);
+			ss->set("OLD_TRANSP",mp->transparency);
+			ss->set("NEW_TRANSP",transparency);
+			undoManager->action(this,ss);
+		}
 		mp->colorName = MColor;
 		mp->color = MQColor;
 		mp->shade = shade;
 		mp->transparency = transparency;
-		undoManager->action(this,ss);
 		FPoint xx = mp->gridPoint;
 		for (int col = 0; col < meshGradientPatches.count(); col++)
 		{
@@ -3060,114 +3096,134 @@
 			{
 				if (meshGradientPatches[col].TL.gridPoint == xx)
 				{
-					ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
-					ss->set("GRAD_MESH_COLOR","grad_mesh_color");
-					ss->set("X",col);
-					ss->set("Y",1);
-					ss->set("PATCH",true);
 					mp = &(meshGradientPatches[col].TL);
-					ss->set("OLD_COLOR_NAME",mp->colorName);
-					ss->set("NEW_COLOR_NAME",MColor);
-					ss->setItem(qMakePair(mp->color,MQColor));
-					ss->set("OLD_SHADE",mp->shade);
-					ss->set("NEW_SHADE",shade);
-					ss->set("OLD_TRANSP",mp->transparency);
-					ss->set("NEW_TRANSP",transparency);
+					if(UndoManager::undoEnabled())
+					{
+						ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
+						ss->set("GRAD_MESH_COLOR","grad_mesh_color");
+						ss->set("X",col);
+						ss->set("Y",1);
+						ss->set("PATCH",true);
+						ss->set("OLD_COLOR_NAME",mp->colorName);
+						ss->set("NEW_COLOR_NAME",MColor);
+						ss->setItem(qMakePair(mp->color,MQColor));
+						ss->set("OLD_SHADE",mp->shade);
+						ss->set("NEW_SHADE",shade);
+						ss->set("OLD_TRANSP",mp->transparency);
+						ss->set("NEW_TRANSP",transparency);
+						undoManager->action(this,ss);
+					}
 					mp->colorName = MColor;
 					mp->color = MQColor;
 					mp->shade = shade;
 					mp->transparency = transparency;
-					undoManager->action(this,ss);
 				}
 				if (meshGradientPatches[col].TR.gridPoint == xx)
 				{
-					ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
-					ss->set("GRAD_MESH_COLOR","grad_mesh_color");
-					ss->set("X",col);
-					ss->set("Y",2);
-					ss->set("PATCH",true);
 					mp = &(meshGradientPatches[col].TR);
-					ss->set("OLD_COLOR_NAME",mp->colorName);
-					ss->set("NEW_COLOR_NAME",MColor);
-					ss->setItem(qMakePair(mp->color,MQColor));
-					ss->set("OLD_SHADE",mp->shade);
-					ss->set("NEW_SHADE",shade);
-					ss->set("OLD_TRANSP",mp->transparency);
-					ss->set("NEW_TRANSP",transparency);
+					if(UndoManager::undoEnabled())
+					{
+						ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
+						ss->set("GRAD_MESH_COLOR","grad_mesh_color");
+						ss->set("X",col);
+						ss->set("Y",2);
+						ss->set("PATCH",true);
+						ss->set("OLD_COLOR_NAME",mp->colorName);
+						ss->set("NEW_COLOR_NAME",MColor);
+						ss->setItem(qMakePair(mp->color,MQColor));
+						ss->set("OLD_SHADE",mp->shade);
+						ss->set("NEW_SHADE",shade);
+						ss->set("OLD_TRANSP",mp->transparency);
+						ss->set("NEW_TRANSP",transparency);
+						undoManager->action(this,ss);
+					}
 					mp->colorName = MColor;
 					mp->color = MQColor;
 					mp->shade = shade;
 					mp->transparency = transparency;
-					undoManager->action(this,ss);
 				}
 				if (meshGradientPatches[col].BR.gridPoint == xx)
 				{
-					ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
-					ss->set("GRAD_MESH_COLOR","grad_mesh_color");
-					ss->set("X",col);
-					ss->set("Y",3);
-					ss->set("PATCH",true);
 					mp = &(meshGradientPatches[col].BR);
-					ss->set("OLD_COLOR_NAME",mp->colorName);
-					ss->set("NEW_COLOR_NAME",MColor);
-					ss->setItem(qMakePair(mp->color,MQColor));
-					ss->set("OLD_SHADE",mp->shade);
-					ss->set("NEW_SHADE",shade);
-					ss->set("OLD_TRANSP",mp->transparency);
-					ss->set("NEW_TRANSP",transparency);
+					if(UndoManager::undoEnabled())
+					{
+						ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
+						ss->set("GRAD_MESH_COLOR","grad_mesh_color");
+						ss->set("X",col);
+						ss->set("Y",3);
+						ss->set("PATCH",true);
+						ss->set("OLD_COLOR_NAME",mp->colorName);
+						ss->set("NEW_COLOR_NAME",MColor);
+						ss->setItem(qMakePair(mp->color,MQColor));
+						ss->set("OLD_SHADE",mp->shade);
+						ss->set("NEW_SHADE",shade);
+						ss->set("OLD_TRANSP",mp->transparency);
+						ss->set("NEW_TRANSP",transparency);
+						undoManager->action(this,ss);
+					}
 					mp->colorName = MColor;
 					mp->color = MQColor;
 					mp->shade = shade;
 					mp->transparency = transparency;
-					undoManager->action(this,ss);
 				}
 				if (meshGradientPatches[col].BL.gridPoint == xx)
 				{
-					ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
-					ss->set("GRAD_MESH_COLOR","grad_mesh_color");
-					ss->set("X",col);
-					ss->set("Y",4);
-					ss->set("PATCH",true);
 					mp = &(meshGradientPatches[col].BL);
-					ss->set("OLD_COLOR_NAME",mp->colorName);
-					ss->set("NEW_COLOR_NAME",MColor);
-					ss->setItem(qMakePair(mp->color,MQColor));
-					ss->set("OLD_SHADE",mp->shade);
-					ss->set("NEW_SHADE",shade);
-					ss->set("OLD_TRANSP",mp->transparency);
-					ss->set("NEW_TRANSP",transparency);
+					if(UndoManager::undoEnabled())
+					{
+						ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
+						ss->set("GRAD_MESH_COLOR","grad_mesh_color");
+						ss->set("X",col);
+						ss->set("Y",4);
+						ss->set("PATCH",true);
+						ss->set("OLD_COLOR_NAME",mp->colorName);
+						ss->set("NEW_COLOR_NAME",MColor);
+						ss->setItem(qMakePair(mp->color,MQColor));
+						ss->set("OLD_SHADE",mp->shade);
+						ss->set("NEW_SHADE",shade);
+						ss->set("OLD_TRANSP",mp->transparency);
+						ss->set("NEW_TRANSP",transparency);
+						undoManager->action(this,ss);
+					}
 					mp->colorName = MColor;
 					mp->color = MQColor;
 					mp->shade = shade;
 					mp->transparency = transparency;
-					undoManager->action(this,ss);
 				}
 			}
 		}
-		trans.commit();
+		if(trans)
+		{
+			trans->commit();
+			delete trans;
+			trans = NULL;
+		}
 	}
 	else
 	{
 		if ((x > -1) && (y > -1))
 		{
-			ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
-			ss->set("GRAD_MESH_COLOR","grad_mesh_color");
-			ss->set("X",x);
-			ss->set("Y",y);
-			ss->set("PATCH",false);
 			mp = &(meshGradientArray[x][y]);
-			ss->set("OLD_COLOR_NAME",mp->colorName);
-			ss->set("NEW_COLOR_NAME",MColor);
-			ss->setItem(qMakePair(mp->color,MQColor));
-			ss->set("OLD_SHADE",mp->shade);
-			ss->set("NEW_SHADE",shade);
-			ss->set("OLD_TRANSP",mp->transparency);
-			ss->set("NEW_TRANSP",transparency);
+			if(UndoManager::undoEnabled())
+			{
+				ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradVal);
+				ss->set("GRAD_MESH_COLOR","grad_mesh_color");
+				ss->set("X",x);
+				ss->set("Y",y);
+				ss->set("PATCH",false);
+				ss->set("OLD_COLOR_NAME",mp->colorName);
+				ss->set("NEW_COLOR_NAME",MColor);
+				ss->setItem(qMakePair(mp->color,MQColor));
+				ss->set("OLD_SHADE",mp->shade);
+				ss->set("NEW_SHADE",shade);
+				ss->set("OLD_TRANSP",mp->transparency);
+				ss->set("NEW_TRANSP",transparency);
+				undoManager->action(this,ss);
+			}
 			mp->colorName = MColor;
 			mp->color = MQColor;
 			mp->shade = shade;
 			mp->transparency = transparency;
-			undoManager->action(this,ss);
 		}
 	}
 }
@@ -3213,12 +3269,15 @@
 		VisionDefectColor defect;
 		MQColor = defect.convertDefect(MQColor, m_Doc->previewVisual);
 	}
-	ScItemState<QList<QList<meshPoint> > > *is = new ScItemState<QList<QList<meshPoint> > >(Um::MeshGradient);
-	is->set("CREATE_MESH_GRAD","create_mesh_grad");
-	is->set("ROW",rows);
-	is->set("COL",cols);
-	is->setItem(meshGradientArray);
-	undoManager->action(this,is);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QList<QList<meshPoint> > > *is = new ScItemState<QList<QList<meshPoint> > >(Um::MeshGradient);
+		is->set("CREATE_MESH_GRAD","create_mesh_grad");
+		is->set("ROW",rows);
+		is->set("COL",cols);
+		is->setItem(meshGradientArray);
+		undoManager->action(this,is);
+	}
 	meshGradientArray.clear();
 	double xoffs = Width / static_cast<double>(cols);
 	double yoffs = Height / static_cast<double>(rows);
@@ -3243,10 +3302,13 @@
 {
 	int rows = meshGradientArray.count();
 	int cols = meshGradientArray[0].count();
-	ScItemState<QList<QList<meshPoint> > > *is = new ScItemState<QList<QList<meshPoint> > >(Um::ResetControlPoints);
-	is->set("RESET_MESH_GRAD","reset_mesh_grad");
-	is->setItem(meshGradientArray);
-	undoManager->action(this,is);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QList<QList<meshPoint> > > *is = new ScItemState<QList<QList<meshPoint> > >(Um::ResetControlPoints);
+		is->set("RESET_MESH_GRAD","reset_mesh_grad");
+		is->setItem(meshGradientArray);
+		undoManager->action(this,is);
+	}
 	double xoffs = Width / static_cast<double>(cols-1);
 	double yoffs = Height / static_cast<double>(rows-1);
 	for (int x = 0; x < rows; x++)
@@ -3290,15 +3352,18 @@
 								meshGradientArray[m-1][0].gridPoint.x(), meshGradientArray[m-1][0].gridPoint.y());
 	}
 	
-	UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::ChangeMeshGradient,"",Um::IFill));
-	ScItemState<QPair<QList<QList<meshPoint> >,FPointArray> > *ism = new ScItemState<QPair<QList<QList<meshPoint> >,FPointArray> >(Um::ChangeMeshGradient, "",Um::IFill);
-	ism->set("MOVE_MESH_GRAD", "move_mesh_grad");
-	ism->setItem(qMakePair(meshGradientArray,PoLine));
-	ism->set("OLDB",OldB2);
-	ism->set("OLDH",OldH2);
-	ism->set("FRAME_TYPE",FrameType);
-	undoManager->action(this, ism);
-
+	UndoTransaction *trans =  NULL;
+	if(UndoManager::undoEnabled())
+	{
+		trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::ChangeMeshGradient,"",Um::IFill));
+		ScItemState<QPair<QList<QList<meshPoint> >,FPointArray> > *ism = new ScItemState<QPair<QList<QList<meshPoint> >,FPointArray> >(Um::ChangeMeshGradient, "",Um::IFill);
+		ism->set("MOVE_MESH_GRAD", "move_mesh_grad");
+		ism->setItem(qMakePair(meshGradientArray,PoLine));
+		ism->set("OLDB",OldB2);
+		ism->set("OLDH",OldH2);
+		ism->set("FRAME_TYPE",FrameType);
+		undoManager->action(this, ism);
+	}
 	QList<QList<meshPoint> > meshGradientArrayOld = meshGradientArray;
 	PoLine = Coords.copy();
 	double oldX = Xpos;
@@ -3317,12 +3382,20 @@
 	for (int x = 0; x < rows+1; x++)
 		for (int y = 0; y < cols+1; y++)
 			meshGradientArray[x][y].moveRel(dx, dy);
-	ScItemState<FPointArray> *is = new ScItemState<FPointArray>(Um::ResetContourLine, "",Um::IBorder);
-	is->set("RESET_CONTOUR", "reset_contour");
-	is->setItem(ContourLine);
-	undoManager->action(this, is);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<FPointArray> *is = new ScItemState<FPointArray>(Um::ResetContourLine, "",Um::IBorder);
+		is->set("RESET_CONTOUR", "reset_contour");
+		is->setItem(ContourLine);
+		undoManager->action(this, is);
+	}
 	ContourLine = PoLine.copy();
-	trans.commit();
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 }
 
 void PageItem::createConicalMesh()
@@ -3606,11 +3679,14 @@
 {
 	if(GrMask==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradTypeMask,"",Um::IFill);
-	ss->set("MASKTYPE","masktype");
-	ss->set("NEW",val);
-	ss->set("OLD",GrMask);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradTypeMask,"",Um::IFill);
+		ss->set("MASKTYPE","masktype");
+		ss->set("NEW",val);
+		ss->set("OLD",GrMask);
+		undoManager->action(this,ss);
+	}
 	GrMask = val;
 }
 
@@ -4133,11 +4209,14 @@
 {
 	if (m_startArrowScale == newScale)
 		return; // nothing to do -> return
-	SimpleState *ss = new SimpleState(Um::StartArrowScale,"",Um::IArrow);
-	ss->set("START_ARROWSCALE","start_arrowscale");
-	ss->set("OLD_SCALE",m_startArrowScale);
-	ss->set("NEW_SCALE",newScale);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::StartArrowScale,"",Um::IArrow);
+		ss->set("START_ARROWSCALE","start_arrowscale");
+		ss->set("OLD_SCALE",m_startArrowScale);
+		ss->set("NEW_SCALE",newScale);
+		undoManager->action(this,ss);
+	}
 	m_startArrowScale = newScale;
 }
 
@@ -4145,11 +4224,14 @@
 {
 	if (m_endArrowScale == newScale)
 		return; // nothing to do -> return
-	SimpleState *ss = new SimpleState(Um::EndArrowScale,"",Um::IArrow);
-	ss->set("END_ARROWSCALE","end_arrowscale");
-	ss->set("OLD_SCALE",m_endArrowScale);
-	ss->set("NEW_SCALE",newScale);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::EndArrowScale,"",Um::IArrow);
+		ss->set("END_ARROWSCALE","end_arrowscale");
+		ss->set("OLD_SCALE",m_endArrowScale);
+		ss->set("NEW_SCALE",newScale);
+		undoManager->action(this,ss);
+	}
 	m_endArrowScale = newScale;
 }
 
@@ -4639,6 +4721,8 @@
 {
 	bool useRasterBackup = m_Doc->useRaster;
 	bool SnapGuidesBackup = m_Doc->SnapGuides;
+	bool SnapElementBackup = m_Doc->SnapElement;
+	m_Doc->SnapElement = false;
 	m_Doc->useRaster = false;
 	m_Doc->SnapGuides = false;
 	SimpleState *ss = dynamic_cast<SimpleState*>(state);
@@ -4797,8 +4881,6 @@
 			restoreArrow(ss, isUndo, true);
 		else if (ss->contains("END_ARROW"))
 			restoreArrow(ss, isUndo, false);
-		else if (ss->contains("PSTYLE"))
-			restorePStyle(ss, isUndo);
 		else if (ss->contains("CONVERT"))
 			restoreType(ss, isUndo);
 		else if (ss->contains("TEXTFLOW_OLDMODE"))
@@ -4871,6 +4953,7 @@
 	if (!OnMasterPage.isEmpty())
 		m_Doc->setCurrentPage(oldCurrentPage);
 	m_Doc->setMasterPageMode(oldMPMode);
+	m_Doc->SnapElement = SnapElementBackup;
 	m_Doc->useRaster = useRasterBackup;
 	m_Doc->SnapGuides = SnapGuidesBackup;
 }
@@ -6452,17 +6535,6 @@
 		setEndArrowIndex(i);
 }
 
-
-void PageItem::restorePStyle(SimpleState *state, bool isUndo)
-{
-	int styleid = state->getInt("OLD_STYLE");
-	if (!isUndo)
-		styleid = state->getInt("NEW_STYLE");
-	//will be done later with other text-undo:
-	//	m_Doc->chAbStyle(this, styleid);
-}
-
-
 // FIXME: This must go into class ScribusDoc!
 // For now we'll just make it independent of 'this' -- AV
 void PageItem::restoreType(SimpleState *state, bool isUndo)
@@ -6615,7 +6687,7 @@
 	{
 		unlink(false);
 		//restore properly text if frame was linked at beginning of chain
-		ScItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ScItemState<std::pair<PageItem*, PageItem*> >*>(state);
+		ScItemState<QPair<PageItem*, PageItem*> > *is = dynamic_cast<ScItemState<QPair<PageItem*, PageItem*> >*>(state);
 		int joinPos = is->getInt("JOIN_POS");
 		int ParSep = is->getBool("ADDPARSEP")?1:0;
 		if (is->getBool("FIRST"))
@@ -6650,7 +6722,7 @@
 	}
 	else
 	{
-		ScItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ScItemState<std::pair<PageItem*, PageItem*> >*>(state);
+		ScItemState<QPair<PageItem*, PageItem*> > *is = dynamic_cast<ScItemState<QPair<PageItem*, PageItem*> >*>(state);
 		asTextFrame()->link(is->getItem().second->asTextFrame());
 	}
 }
@@ -6659,7 +6731,7 @@
 {
 	if (!isTextFrame())
 		return;
-	ScItemState<std::pair<PageItem*, PageItem*> > *is = dynamic_cast<ScItemState<std::pair<PageItem*, PageItem*> >*>(state);
+	ScItemState<QPair<PageItem*, PageItem*> > *is = dynamic_cast<ScItemState<QPair<PageItem*, PageItem*> >*>(state);
 	if (is->contains("CUT_TEXT"))
 	{
 		bool cutText = is->getBool("CUT_TEXT");
@@ -7289,11 +7361,14 @@
 {
 	if(GrType==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradType,"",Um::IFill);
-	ss->set("GRAD_TYPE","grad_type");
-	ss->set("OLD",GrType);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradType,"",Um::IFill);
+		ss->set("GRAD_TYPE","grad_type");
+		ss->set("OLD",GrType);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrType = val;
 }
 
@@ -7301,11 +7376,14 @@
 {
 	if(GrTypeStroke==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradTypeStroke,"",Um::ILineStyle);
-	ss->set("GRAD_TYPESTROKE","grad_typestroke");
-	ss->set("OLD",GrTypeStroke);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradTypeStroke,"",Um::ILineStyle);
+		ss->set("GRAD_TYPESTROKE","grad_typestroke");
+		ss->set("OLD",GrTypeStroke);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrTypeStroke = val;
 }
 
@@ -7313,11 +7391,14 @@
 {
 	if(GrColorP1==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_COL1","grad_col1");
-	ss->set("OLD",GrColorP1);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_COL1","grad_col1");
+		ss->set("OLD",GrColorP1);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrColorP1 = val;
 }
 
@@ -7325,11 +7406,14 @@
 {
 	if(GrColorP2==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_COL2","grad_col2");
-	ss->set("OLD",GrColorP2);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_COL2","grad_col2");
+		ss->set("OLD",GrColorP2);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrColorP2 = val;
 }
 
@@ -7337,11 +7421,14 @@
 {
 	if(GrColorP3==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_COL3","grad_col3");
-	ss->set("OLD",GrColorP3);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_COL3","grad_col3");
+		ss->set("OLD",GrColorP3);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrColorP3 = val;
 }
 
@@ -7349,11 +7436,14 @@
 {
 	if(GrColorP4==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_COL4","grad_col4");
-	ss->set("OLD",GrColorP4);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_COL4","grad_col4");
+		ss->set("OLD",GrColorP4);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrColorP4 = val;
 }
 
@@ -7361,11 +7451,14 @@
 {
 	if(GrCol1Shade==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_SHADE1","grad_shade1");
-	ss->set("OLD",GrCol1Shade);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_SHADE1","grad_shade1");
+		ss->set("OLD",GrCol1Shade);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrCol1Shade = val;
 }
 
@@ -7373,11 +7466,14 @@
 {
 	if(GrCol1Shade==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_SHADE2","grad_shade2");
-	ss->set("OLD",GrCol2Shade);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_SHADE2","grad_shade2");
+		ss->set("OLD",GrCol2Shade);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrCol2Shade = val;
 }
 
@@ -7385,11 +7481,14 @@
 {
 	if(GrCol1Shade==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_SHADE3","grad_shade3");
-	ss->set("OLD",GrCol3Shade);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_SHADE3","grad_shade3");
+		ss->set("OLD",GrCol3Shade);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrCol3Shade = val;
 }
 
@@ -7397,11 +7496,14 @@
 {
 	if(GrCol1Shade==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_SHADE4","grad_shade4");
-	ss->set("OLD",GrCol4Shade);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_SHADE4","grad_shade4");
+		ss->set("OLD",GrCol4Shade);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrCol4Shade = val;
 }
 
@@ -7409,11 +7511,14 @@
 {
 	if(GrCol1transp==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_TRANSP1","grad_transp1");
-	ss->set("OLD",GrCol1transp);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_TRANSP1","grad_transp1");
+		ss->set("OLD",GrCol1transp);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrCol1transp = val;
 }
 
@@ -7421,11 +7526,14 @@
 {
 	if(GrCol2transp==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_TRANSP2","grad_transp2");
-	ss->set("OLD",GrCol2transp);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_TRANSP2","grad_transp2");
+		ss->set("OLD",GrCol2transp);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrCol2transp = val;
 }
 
@@ -7433,11 +7541,14 @@
 {
 	if(GrCol3transp==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_TRANSP3","grad_transp3");
-	ss->set("OLD",GrCol3transp);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_TRANSP3","grad_transp3");
+		ss->set("OLD",GrCol3transp);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrCol3transp = val;
 }
 
@@ -7445,11 +7556,14 @@
 {
 	if(GrCol4transp==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_TRANSP4","grad_transp4");
-	ss->set("OLD",GrCol4transp);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_TRANSP4","grad_transp4");
+		ss->set("OLD",GrCol4transp);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrCol4transp = val;
 }
 
@@ -7457,10 +7571,13 @@
 {
 	if(GrColorP1QColor ==val)
 		return;
-	ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_QCOLOR1","grad_qcolor1");
-	ss->setItem(qMakePair(GrColorP1QColor,val));
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_QCOLOR1","grad_qcolor1");
+		ss->setItem(qMakePair(GrColorP1QColor,val));
+		undoManager->action(this,ss);
+	}
 	GrColorP1QColor = val;
 }
 
@@ -7468,10 +7585,13 @@
 {
 	if(GrColorP2QColor ==val)
 		return;
-	ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_QCOLOR2","grad_qcolor2");
-	ss->setItem(qMakePair(GrColorP2QColor,val));
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_QCOLOR2","grad_qcolor2");
+		ss->setItem(qMakePair(GrColorP2QColor,val));
+		undoManager->action(this,ss);
+	}
 	GrColorP2QColor = val;
 }
 
@@ -7479,10 +7599,13 @@
 {
 	if(GrColorP3QColor ==val)
 		return;
-	ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_QCOLOR3","grad_qcolor3");
-	ss->setItem(qMakePair(GrColorP3QColor,val));
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_QCOLOR3","grad_qcolor3");
+		ss->setItem(qMakePair(GrColorP3QColor,val));
+		undoManager->action(this,ss);
+	}
 	GrColorP3QColor = val;
 }
 
@@ -7490,10 +7613,13 @@
 {
 	if(GrColorP4QColor ==val)
 		return;
-	ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradCol,"",Um::IFill);
-	ss->set("GRAD_QCOLOR4","grad_qcolor4");
-	ss->setItem(qMakePair(GrColorP4QColor,val));
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<QColor,QColor> > *ss = new ScItemState<QPair<QColor,QColor> >(Um::GradCol,"",Um::IFill);
+		ss->set("GRAD_QCOLOR4","grad_qcolor4");
+		ss->setItem(qMakePair(GrColorP4QColor,val));
+		undoManager->action(this,ss);
+	}
 	GrColorP4QColor = val;
 }
 
@@ -7501,324 +7627,414 @@
 {
 	if(snapToPatchGrid ==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("SNAP_TO_PATCH","snap_to_patch");
-	ss->set("OLD",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("SNAP_TO_PATCH","snap_to_patch");
+		ss->set("OLD",val);
+		undoManager->action(this,ss);
+	}
 	snapToPatchGrid = val;
 }
 
 void PageItem::setGradientStartX(double val){
 	if(GrStartX==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_STARTX","grad_startx");
-	ss->set("OLD",GrStartX);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_STARTX","grad_startx");
+		ss->set("OLD",GrStartX);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrStartX = val;
 }
 
 void PageItem::setGradientStartY(double val){
 	if(GrStartY==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_STARTY","grad_starty");
-	ss->set("OLD",GrStartY);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_STARTY","grad_starty");
+		ss->set("OLD",GrStartY);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrStartY = val;
 }
 
 void PageItem::setGradientEndX(double val){
 	if(GrEndX==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_ENDX","grad_endx");
-	ss->set("OLD",GrEndX);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_ENDX","grad_endx");
+		ss->set("OLD",GrEndX);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrEndX = val;
 }
 
 void PageItem::setGradientEndY(double val){
 	if(GrEndY==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_ENDY","grad_endy");
-	ss->set("OLD",GrEndY);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_ENDY","grad_endy");
+		ss->set("OLD",GrEndY);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrEndY = val;
 }
 
 void PageItem::setGradientFocalX(double val){
 	if(GrFocalX==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_FOCALX","grad_focalx");
-	ss->set("OLD",GrFocalX);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_FOCALX","grad_focalx");
+		ss->set("OLD",GrFocalX);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrFocalX = val;
 }
 
 void PageItem::setGradientFocalY(double val){
 	if(GrFocalY==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_FOCALY","grad_focaly");
-	ss->set("OLD",GrFocalY);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_FOCALY","grad_focaly");
+		ss->set("OLD",GrFocalY);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrFocalY = val;
 }
 
 void PageItem::setGradientScale(double val){
 	if(GrScale==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_SCALE","grad_scale");
-	ss->set("OLD",GrScale);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_SCALE","grad_scale");
+		ss->set("OLD",GrScale);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrScale = val;
 }
 
 void PageItem::setGradientSkew(double val){
 	if(GrSkew==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_SKEW","grad_skew");
-	ss->set("OLD",GrSkew);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_SKEW","grad_skew");
+		ss->set("OLD",GrSkew);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrSkew = val;
 }
 
 void PageItem::setGradientMaskStartX(double val){
 	if(GrMaskStartX==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_MASKSTARTX","grad_maskstartx");
-	ss->set("OLD",GrMaskStartX);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_MASKSTARTX","grad_maskstartx");
+		ss->set("OLD",GrMaskStartX);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrMaskStartX = val;
 }
 
 void PageItem::setGradientMaskStartY(double val){
 	if(GrMaskStartY==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_MASKSTARTY","grad_maskstarty");
-	ss->set("OLD",GrMaskStartY);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_MASKSTARTY","grad_maskstarty");
+		ss->set("OLD",GrMaskStartY);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrMaskStartY = val;
 }
 
 void PageItem::setGradientMaskEndX(double val){
 	if(GrMaskEndX==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_MASKENDX","grad_maskendx");
-	ss->set("OLD",GrMaskEndX);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_MASKENDX","grad_maskendx");
+		ss->set("OLD",GrMaskEndX);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrMaskEndX = val;
 }
 
 void PageItem::setGradientMaskEndY(double val){
 	if(GrMaskEndY==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_MASKENDY","grad_maskendy");
-	ss->set("OLD",GrMaskEndY);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_MASKENDY","grad_maskendy");
+		ss->set("OLD",GrMaskEndY);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrMaskEndY = val;
 }
 
 void PageItem::setGradientMaskFocalX(double val){
 	if(GrMaskFocalX==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_MASKFOCALX","grad_maskfocalx");
-	ss->set("OLD",GrMaskFocalX);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_MASKFOCALX","grad_maskfocalx");
+		ss->set("OLD",GrMaskFocalX);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrMaskFocalX = val;
 }
 
 void PageItem::setGradientMaskFocalY(double val){
 	if(GrMaskFocalY==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_MASKFOCALY","grad_maskfocaly");
-	ss->set("OLD",GrMaskFocalY);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_MASKFOCALY","grad_maskfocaly");
+		ss->set("OLD",GrMaskFocalY);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrMaskFocalY = val;
 }
 
 void PageItem::setGradientMaskScale(double val){
 	if(GrMaskScale==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_MASKSCALE","grad_maskscale");
-	ss->set("OLD",GrMaskScale);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_MASKSCALE","grad_maskscale");
+		ss->set("OLD",GrMaskScale);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrMaskScale = val;
 }
 
 void PageItem::setGradientMaskSkew(double val){
 	if(GrMaskSkew==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_MASKSKEW","grad_maskskew");
-	ss->set("OLD",GrMaskSkew);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_MASKSKEW","grad_maskskew");
+		ss->set("OLD",GrMaskSkew);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrMaskSkew = val;
 }
 
 void PageItem::setGradientControl1(FPoint val){
 	if(GrControl1==val)
 		return;
-	ScItemState<QPair<FPoint,FPoint> > *ss = new ScItemState<QPair<FPoint,FPoint> >(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_CONTROL1","grad_control1");
-	ss->setItem(qMakePair(GrControl1,val));
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<FPoint,FPoint> > *ss = new ScItemState<QPair<FPoint,FPoint> >(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_CONTROL1","grad_control1");
+		ss->setItem(qMakePair(GrControl1,val));
+		undoManager->action(this,ss);
+	}
 	GrControl1 = val;
 }
 
 void PageItem::setGradientControl2(FPoint val){
 	if(GrControl2==val)
 		return;
-	ScItemState<QPair<FPoint,FPoint> > *ss = new ScItemState<QPair<FPoint,FPoint> >(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_CONTROL2","grad_control2");
-	ss->setItem(qMakePair(GrControl2,val));
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<FPoint,FPoint> > *ss = new ScItemState<QPair<FPoint,FPoint> >(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_CONTROL2","grad_control2");
+		ss->setItem(qMakePair(GrControl2,val));
+		undoManager->action(this,ss);
+	}
 	GrControl2 = val;
 }
 
 void PageItem::setGradientControl3(FPoint val){
 	if(GrControl3==val)
 		return;
-	ScItemState<QPair<FPoint,FPoint> > *ss = new ScItemState<QPair<FPoint,FPoint> >(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_CONTROL3","grad_control3");
-	ss->setItem(qMakePair(GrControl3,val));
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<FPoint,FPoint> > *ss = new ScItemState<QPair<FPoint,FPoint> >(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_CONTROL3","grad_control3");
+		ss->setItem(qMakePair(GrControl3,val));
+		undoManager->action(this,ss);
+	}
 	GrControl3 = val;
 }
 
 void PageItem::setGradientControl4(FPoint val){
 	if(GrControl4==val)
 		return;
-	ScItemState<QPair<FPoint,FPoint> > *ss = new ScItemState<QPair<FPoint,FPoint> >(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_CONTROL4","grad_control4");
-	ss->setItem(qMakePair(GrControl4,val));
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<FPoint,FPoint> > *ss = new ScItemState<QPair<FPoint,FPoint> >(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_CONTROL4","grad_control4");
+		ss->setItem(qMakePair(GrControl4,val));
+		undoManager->action(this,ss);
+	}
 	GrControl4 = val;
 }
 
 void PageItem::setGradientControl5(FPoint val){
 	if(GrControl5==val)
 		return;
-	ScItemState<QPair<FPoint,FPoint> > *ss = new ScItemState<QPair<FPoint,FPoint> >(Um::GradPos,"",Um::IFill);
-	ss->set("GRAD_CONTROL5","grad_control5");
-	ss->setItem(qMakePair(GrControl5,val));
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<FPoint,FPoint> > *ss = new ScItemState<QPair<FPoint,FPoint> >(Um::GradPos,"",Um::IFill);
+		ss->set("GRAD_CONTROL5","grad_control5");
+		ss->setItem(qMakePair(GrControl5,val));
+		undoManager->action(this,ss);
+	}
 	GrControl5 = val;
 }
 
 void PageItem::setGradientStrokeScale(double val){
 	if(GrStrokeScale==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
-	ss->set("GRADSTROKE_SCALE","gradstroke_scale");
-	ss->set("OLD",GrStrokeScale);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
+		ss->set("GRADSTROKE_SCALE","gradstroke_scale");
+		ss->set("OLD",GrStrokeScale);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrStrokeScale = val;
 }
 
 void PageItem::setGradientStrokeSkew(double val){
 	if(GrStrokeSkew==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
-	ss->set("GRADSTROKE_SKEW","gradstroke_skew");
-	ss->set("OLD",GrStrokeSkew);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
+		ss->set("GRADSTROKE_SKEW","gradstroke_skew");
+		ss->set("OLD",GrStrokeSkew);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrStrokeSkew = val;
 }
 
 void PageItem::setGradientStrokeFocalX(double val){
 	if(GrStrokeFocalX==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
-	ss->set("GRADSTROKE_FOCALX","gradstroke_focalx");
-	ss->set("OLD",GrStrokeFocalX);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
+		ss->set("GRADSTROKE_FOCALX","gradstroke_focalx");
+		ss->set("OLD",GrStrokeFocalX);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrStrokeFocalX = val;
 }
 
 void PageItem::setGradientStrokeFocalY(double val){
 	if(GrStrokeFocalY==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
-	ss->set("GRADSTROKE_FOCALY","gradstroke_focaly");
-	ss->set("OLD",GrStrokeFocalY);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
+		ss->set("GRADSTROKE_FOCALY","gradstroke_focaly");
+		ss->set("OLD",GrStrokeFocalY);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrStrokeFocalY = val;
 }
 
 void PageItem::setGradientStrokeStartX(double val){
 	if(GrStrokeStartX==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
-	ss->set("GRADSTROKE_STARTX","gradstroke_startx");
-	ss->set("OLD",GrStrokeStartX);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
+		ss->set("GRADSTROKE_STARTX","gradstroke_startx");
+		ss->set("OLD",GrStrokeStartX);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrStrokeStartX = val;
 }
 
 void PageItem::setGradientStrokeStartY(double val){
 	if(GrStrokeStartY==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
-	ss->set("GRADSTROKE_STARTY","gradstroke_starty");
-	ss->set("OLD",GrStrokeStartY);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
+		ss->set("GRADSTROKE_STARTY","gradstroke_starty");
+		ss->set("OLD",GrStrokeStartY);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrStrokeStartY = val;
 }
 
 void PageItem::setGradientStrokeEndX(double val){
 	if(GrStrokeEndX==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
-	ss->set("GRADSTROKE_ENDX","gradstroke_endx");
-	ss->set("OLD",GrStrokeEndX);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
+		ss->set("GRADSTROKE_ENDX","gradstroke_endx");
+		ss->set("OLD",GrStrokeEndX);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrStrokeEndX = val;
 }
 
 void PageItem::setGradientStrokeEndY(double val){
 	if(GrStrokeEndY==val)
 		return;
-	SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
-	ss->set("GRADSTROKE_ENDY","gradstroke_endy");
-	ss->set("OLD",GrStrokeEndY);
-	ss->set("NEW",val);
-	undoManager->action(this,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::GradPos,"",Um::ILine);
+		ss->set("GRADSTROKE_ENDY","gradstroke_endy");
+		ss->set("OLD",GrStrokeEndY);
+		ss->set("NEW",val);
+		undoManager->action(this,ss);
+	}
 	GrStrokeEndY = val;
 }
 
@@ -9768,7 +9984,7 @@
 		{
 			ScItemState<QPair<FirstLineOffsetPolicy,FirstLineOffsetPolicy> > *is = new ScItemState<QPair <FirstLineOffsetPolicy,FirstLineOffsetPolicy> >(Um::FirstLineOffset);
 			is->set("FIRSTLINEOFFSET", "fisrtlineoffset");
-			is->setItem(QPair<FirstLineOffsetPolicy,FirstLineOffsetPolicy>(firstLineOffsetP, flop));
+			is->setItem(qMakePair(firstLineOffsetP, flop));
 			undoManager->action(this, is);
 		}
 		firstLineOffsetP = flop;
Index: scribus/scribusdoc.h
===================================================================
--- scribus/scribusdoc.h	(révision 17743)
+++ scribus/scribusdoc.h	(copie de travail)
@@ -1130,10 +1130,12 @@
 	bool hasTOCSetup() { return !docPrefsData.tocPrefs.defaultToCSetups.empty(); }
 	//! \brief Get the closest guide to the given point
 	void getClosestGuides(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM, ScPage* refPage = NULL);
+	//! \brief Get the closest border of another element to the given point
+	void getClosestElementBorder(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM, ScPage* refPage = NULL);
 	//! \brief Snap an item to the guides
 	void SnapToGuides(PageItem *currItem);
-	bool ApplyGuides(double *x, double *y);
-	bool ApplyGuides(FPoint* point);
+	bool ApplyGuides(double *x, double *y, bool elementSnap = false);
+	bool ApplyGuides(FPoint* point, bool elementSnap = false);
 	bool MoveItem(double newX, double newY, PageItem* ite, bool fromMP = false);
 	void RotateItem(double win, PageItem *currItem);
 	void MoveRotated(PageItem *currItem, FPoint npv, bool fromMP = false);
@@ -1198,6 +1200,7 @@
 	int viewCount;
 	int viewID;
 	bool SnapGuides;
+	bool SnapElement;
 	bool GuideLock;
 	bool dontResize;
 	/** \brief Minimum and Maximum Points of Document */
Index: scribus/canvas.cpp
===================================================================
--- scribus/canvas.cpp	(révision 17743)
+++ scribus/canvas.cpp	(copie de travail)
@@ -943,6 +943,7 @@
 #endif
 	// does mode specific rendering, currently selection in legacymode and nodes in nodeedit
 	m_view->m_canvasMode->drawControls(&qp);
+	m_view->m_canvasMode->drawSnapLine(&qp);
 	QPainter tp(this);
 	tp.drawPixmap(p->rect(), tmpImg, tmpImg.rect());
 #ifdef SHOW_ME_WHAT_YOU_GET_IN_D_CANVA
Index: scribus/pageitem.h
===================================================================
--- scribus/pageitem.h	(révision 17743)
+++ scribus/pageitem.h	(copie de travail)
@@ -1416,8 +1416,6 @@
 	void restoreCustomLineStyle(SimpleState *state, bool isUndo);
 	void restoreArrow(SimpleState *state, bool isUndo, bool isStart);
 
-	void restorePStyle(SimpleState *state, bool isUndo);
-
 	void restoreType(SimpleState *state, bool isUndo);
 	void restoreTextFlowing(SimpleState *state, bool isUndo);
 	void restoreImageScaleMode(SimpleState *state, bool isUndo);
Index: scribus/canvasmode_normal.cpp
===================================================================
--- scribus/canvasmode_normal.cpp	(révision 17743)
+++ scribus/canvasmode_normal.cpp	(copie de travail)
@@ -83,6 +83,8 @@
 	m_mouseCurrentPoint.setXY(0, 0);
 	m_mouseSavedPoint.setXY(0, 0);
 	m_objectDeltaPos.setXY(0,0 );
+	ySnap = 0;
+	xSnap = 0;
 }
 
 inline bool CanvasMode_Normal::GetItem(PageItem** pi)
@@ -95,13 +97,9 @@
 {
 //	qDebug() << "CanvasMode_Normal::drawControls";
 	if (m_canvas->m_viewMode.operItemMoving)
-	{
 		drawOutline(p, 1.0, 1.0, m_objectDeltaPos.x(), m_objectDeltaPos.y());
-	}
 	else
-	{
 		drawSelection(p, true);
-	}
 }
 
 void CanvasMode_Normal::enterEvent(QEvent *)
@@ -433,7 +431,6 @@
 			if (!m_canvas->m_viewMode.operItemResizing)
 			{
 				//Dragging an item (plus more?)
-				QRectF newPlace;
 				newX = mousePointDoc.x(); //static_cast<int>(m->x()/sc);
 				newY = mousePointDoc.y(); //static_cast<int>(m->y()/sc);
 				m_canvas->m_viewMode.operItemMoving = true;
@@ -466,7 +463,6 @@
 						}
 						double gx, gy, gh, gw;
 						m_objectDeltaPos.setXY(dX, dY);
-						m_doc->m_Selection->setGroupRect();
 						m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
 						// #10677 : temporary hack : we need to introduce the
 						// concept of item snapping points to handle better
@@ -491,7 +487,38 @@
 							ny = nyo = gy + gh + m_objectDeltaPos.y();
 							m_doc->ApplyGuides(&nx, &ny);
 							m_objectDeltaPos += FPoint(nx-nxo, ny-nyo);
+							if(false)
+							{
+								nx = nxo = gx + gw/2 + m_objectDeltaPos.x();
+								ny = nyo = gy + gh/2 + m_objectDeltaPos.y();
+								m_doc->ApplyGuides(&nx, &ny);
+								m_objectDeltaPos += FPoint(nx-nxo, ny-nyo);
+							}
 						}
+						if (m_doc->SnapElement)
+						{
+							xSnap = 0;
+							ySnap = 0;
+							double snapWidth[] = {0,gw,gw/2};
+							double snapHeight[] = {0,gh,gh/2};
+							if(m_objectDeltaPos.x()<0)
+								std::swap(snapWidth[0],snapWidth[2]);
+							if(m_objectDeltaPos.y()<0)
+								std::swap(snapHeight[0],snapHeight[2]);
+							double nx,ny,nyo,nxo;
+							for(int i = 0;i<3;i++)
+							{
+								nx = gx + snapWidth[i] + m_objectDeltaPos.x();
+								ny = gy + snapHeight[i] + m_objectDeltaPos.y();
+								nxo = nx, nyo = ny;
+								m_doc->ApplyGuides(&nx, &ny,true);
+								m_objectDeltaPos += FPoint(nx - nxo, ny - nyo);
+								if(ny != nyo)
+									ySnap = ny * m_canvas->scale();
+								if(nx != nxo)
+									xSnap = nx * m_canvas->scale();
+							}
+						}
 						if (m_doc->useRaster)
 						{
 							m_doc->m_Selection->setGroupRect();
@@ -537,17 +564,47 @@
 					m_objectDeltaPos.setXY(dX, dY);
 					if (m_doc->SnapGuides)
 					{
-						m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
 						double nx = gx + m_objectDeltaPos.x();
 						double ny = gy + m_objectDeltaPos.y();
 						double nxo = nx, nyo = ny;
 						m_doc->ApplyGuides(&nx, &ny);
-						m_objectDeltaPos += FPoint(nx-nxo, ny-nyo);
+						m_objectDeltaPos += FPoint(nx - nxo, ny - nyo);
 						nx = nxo = gx + gw + m_objectDeltaPos.x();
 						ny = nyo = gy + gh + m_objectDeltaPos.y();
 						m_doc->ApplyGuides(&nx, &ny);
 						m_objectDeltaPos += FPoint(nx-nxo, ny-nyo);
+						if(false)
+						{
+							nx = nxo = gx + gw/2 + m_objectDeltaPos.x();
+							ny = nyo = gy + gh/2 + m_objectDeltaPos.y();
+							m_doc->ApplyGuides(&nx, &ny);
+							m_objectDeltaPos += FPoint(nx-nxo, ny-nyo);
+						}
 					}
+					if (m_doc->SnapElement)
+					{
+						xSnap = 0;
+						ySnap = 0;
+						double snapWidth[] = {0,gw,gw/2};
+						double snapHeight[] = {0,gh,gh/2};
+						if(m_objectDeltaPos.x()<0)
+							std::swap(snapWidth[0],snapWidth[2]);
+						if(m_objectDeltaPos.y()<0)
+							std::swap(snapHeight[0],snapHeight[2]);
+						double nx,ny,nyo,nxo;
+						for(int i = 0;i<3;i++)
+						{
+							nx = gx + snapWidth[i] + m_objectDeltaPos.x();
+							ny = gy + snapHeight[i] + m_objectDeltaPos.y();
+							nxo = nx, nyo = ny;
+							m_doc->ApplyGuides(&nx, &ny,true);
+							m_objectDeltaPos += FPoint(nx - nxo, ny - nyo);
+							if(ny != nyo)
+								ySnap = ny * m_canvas->scale();
+							if(nx != nxo)
+								xSnap = nx * m_canvas->scale();
+						}
+					}
 					if (m_doc->useRaster)
 					{
 						double gx, gy, gh, gw, gxo, gyo;
@@ -920,7 +977,7 @@
 				m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
 				double nx = gx;
 				double ny = gy;
-				if (!m_doc->ApplyGuides(&nx, &ny))
+				if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 				{
 					FPoint npx = m_doc->ApplyGridF(FPoint(gx, gy));
 					FPoint npw = m_doc->ApplyGridF(FPoint(gx+gw, gy+gh));
@@ -938,7 +995,7 @@
 				m_doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
 				nx = gx+gw;
 				ny = gy+gh;
-				if (m_doc->ApplyGuides(&nx, &ny))
+				if (m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 					m_doc->moveGroup(nx-(gx+gw), ny-(gy+gh), false);
 				m_doc->m_Selection->setGroupRect();
 			}
@@ -950,7 +1007,7 @@
 				{
 					double nx = currItem->xPos();
 					double ny = currItem->yPos();
-					if (!m_doc->ApplyGuides(&nx, &ny))
+					if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 					{
 						m_doc->m_Selection->setGroupRect();
 						double gx, gy, gh, gw, gxo, gyo;
@@ -1090,6 +1147,7 @@
 	}
 	else
 		m_view->Deselect(true);
+	xSnap = ySnap = 0;
 	m_canvas->setRenderModeUseBuffer(false);
 	m_doc->DragP = false;
 	m_doc->leaveDrag = false;
@@ -1381,6 +1439,8 @@
 		QFileInfo fi(fileName);
 		bool savedAlignGrid = m_doc->useRaster;
 		bool savedAlignGuides = m_doc->SnapGuides;
+		bool savedAlignElement = m_doc->SnapElement;
+		m_doc->SnapElement = false;
 		m_doc->useRaster = false;
 		m_doc->SnapGuides = false;
 		if (fi.suffix().toLower() == "sce")
@@ -1415,6 +1475,7 @@
 		}
 		m_doc->useRaster = savedAlignGrid;
 		m_doc->SnapGuides = savedAlignGuides;
+		m_doc->SnapElement = savedAlignElement;
 		m_doc->setLoading(false);
 		m_doc->view()->DrawNew();
 		if (m_doc->m_Selection->count() > 0)
Index: scribus/actionmanager.cpp
===================================================================
--- scribus/actionmanager.cpp	(révision 17743)
+++ scribus/actionmanager.cpp	(copie de travail)
@@ -631,6 +631,8 @@
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name="viewSnapToGuides";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
+	name="viewSnapToElements";
+	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name="viewShowContextMenu";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	name="showMouseCoordinates";
@@ -653,6 +655,7 @@
 	(*scrActions)["viewRulerMode"]->setToggleAction(true);
 	(*scrActions)["viewSnapToGrid"]->setToggleAction(true);
 	(*scrActions)["viewSnapToGuides"]->setToggleAction(true);
+	(*scrActions)["viewSnapToElements"]->setToggleAction(true);
 	(*scrActions)["showMouseCoordinates"]->setToggleAction(true);
 
 	(*scrActions)["viewPreviewMode"]->setChecked(false);
@@ -689,6 +692,7 @@
 	connect( (*scrActions)["viewRulerMode"], SIGNAL(triggered()), mainWindow, SLOT(ToggleRulerMode()) );
 	connect( (*scrActions)["viewSnapToGrid"], SIGNAL(triggered()), mainWindow, SLOT(ToggleURaster()) );
 	connect( (*scrActions)["viewSnapToGuides"], SIGNAL(triggered()), mainWindow, SLOT(ToggleUGuides()) );
+	connect( (*scrActions)["viewSnapToElements"], SIGNAL(triggered()), mainWindow, SLOT(ToggleUElements()) );
 	connect( (*scrActions)["showMouseCoordinates"], SIGNAL(triggered()), mainWindow, SLOT(ToggleMouseTips()) );
 //	connect( (*scrActions)["viewNewView"], SIGNAL(triggered()), mainWindow, SLOT(newView()) );
 
@@ -1540,6 +1544,7 @@
 	(*scrActions)["viewRulerMode"]->setTexts( tr("Rulers Relative to Page"));
 	(*scrActions)["viewSnapToGrid"]->setTexts( tr("Sn&ap to Grid"));
 	(*scrActions)["viewSnapToGuides"]->setTexts( tr("Sna&p to Guides"));
+	(*scrActions)["viewSnapToElements"]->setTexts( tr("Snap to Items"));
 	(*scrActions)["viewShowContextMenu"]->setTexts( tr("Show Context Menu"));
 //	(*scrActions)["viewNewView"]->setTexts( tr("New View"));
 
@@ -2087,7 +2092,8 @@
 		<< "pageManageGuides"
 		<< "pageManageMargins"
 		<< "viewSnapToGrid"
-		<< "viewSnapToGuides";
+		<< "viewSnapToGuides"
+		<< "viewSnapToElements";
 	//View
 	++itmenu;
 	itmenu->second
Index: scribus/canvasmode_nodeedit.cpp
===================================================================
--- scribus/canvasmode_nodeedit.cpp	(révision 17743)
+++ scribus/canvasmode_nodeedit.cpp	(copie de travail)
@@ -428,7 +428,7 @@
 			FPoint npf;
 			double nx = newP.x();
 			double ny = newP.y();
-			if (!m_doc->ApplyGuides(&nx, &ny))
+			if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 				npf = m_doc->ApplyGridF(FPoint(nx, ny));
 			else
 				npf = FPoint(nx, ny);
@@ -1118,7 +1118,7 @@
 				npf = m_canvas->globalToCanvas(m->globalPos());
 				double nx = npf.x();
 				double ny = npf.y();
-				if (!m_doc->ApplyGuides(&nx, &ny))
+				if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 					npf = m_doc->ApplyGridF(FPoint(nx, ny));
 				else
 					npf = FPoint(nx, ny);
@@ -1219,7 +1219,7 @@
 			npf = m_canvas->globalToCanvas(m->globalPos());
 			double nx = npf.x();
 			double ny = npf.y();
-			if (!m_doc->ApplyGuides(&nx, &ny))
+			if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 				npf = m_doc->ApplyGridF(FPoint(nx, ny));
 			else
 				npf = FPoint(nx, ny);
Index: scribus/guidesmodel.cpp
===================================================================
--- scribus/guidesmodel.cpp	(révision 17743)
+++ scribus/guidesmodel.cpp	(copie de travail)
@@ -49,7 +49,7 @@
 	{
 		QLocale l;
 		return QVariant(l.toString(pts2value(m_values.at(index.row()),
-											  m_docUnitIndex), 'f',
+											  m_docUnitIndex) - rule, 'f',
 											  m_docUnitDecimals)
 						);
 	}
@@ -69,7 +69,7 @@
 	double newVal = value.toDouble(&ok);
 	if (!ok)
 		return false;
-	m_values[index.row()] = value2pts(newVal, m_docUnitIndex);
+	m_values[index.row()] = value2pts(newVal, m_docUnitIndex) + rule;
 	qSort(m_values);
 	emit dataChanged(index, index);
 	emit valueChanged();
@@ -138,8 +138,9 @@
 	return m_values;
 }
 
-void GuidesModel::unitChange(int docUnitIndex, int docUnitDecimals)
+void GuidesModel::unitChange(int docUnitIndex, int docUnitDecimals,double offset)
 {
+	rule = offset;
 	m_docUnitIndex = docUnitIndex;
 	m_docUnitDecimals = docUnitDecimals;
 	reset();
Index: scribus/scribusview.cpp
===================================================================
--- scribus/scribusview.cpp	(révision 17743)
+++ scribus/scribusview.cpp	(copie de travail)
@@ -423,6 +423,7 @@
 
 void ScribusView::togglePreview()
 {
+	undoManager->setUndoEnabled(false);
 	m_canvas->m_viewMode.viewAsPreview = !m_canvas->m_viewMode.viewAsPreview;
 	Doc->drawAsPreview = m_canvas->m_viewMode.viewAsPreview;
 	if (m_canvas->m_viewMode.viewAsPreview)
@@ -470,6 +471,7 @@
 	{
 		DrawNew();
 	}
+	undoManager->setUndoEnabled(true);
 }
 
 void ScribusView::changed(QRectF re, bool)
@@ -1181,7 +1183,7 @@
 				Doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
 				double nx = gx;
 				double ny = gy;
-				if (!Doc->ApplyGuides(&nx, &ny))
+				if (!Doc->ApplyGuides(&nx, &ny) && !Doc->ApplyGuides(&nx, &ny,true))
 				{
 					FPoint npx;
 					npx = Doc->ApplyGridF(FPoint(nx, ny));
@@ -1195,6 +1197,7 @@
 				nx = gx+gw;
 				ny = gy+gh;
 				Doc->ApplyGuides(&nx, &ny);
+				Doc->ApplyGuides(&nx, &ny,true);
 				Doc->moveGroup(nx-(gx+gw), ny-(gy+gh), false);
 				Doc->m_Selection->setGroupRect();
 				Doc->m_Selection->getGroupRect(&gx, &gy, &gw, &gh);
@@ -1221,7 +1224,7 @@
 				{
 					double nx = currItem->xPos();
 					double ny = currItem->yPos();
-					if (!Doc->ApplyGuides(&nx, &ny))
+					if (!Doc->ApplyGuides(&nx, &ny) && !Doc->ApplyGuides(&nx, &ny,true))
 					{
 						FPoint npx;
 						npx = Doc->ApplyGridF(FPoint(nx, ny));
@@ -1962,7 +1965,7 @@
 		newObjects.getGroupRect(&gx, &gy, &gw, &gh);
 		double nx = gx;
 		double ny = gy;
-		if (!Doc->ApplyGuides(&nx, &ny))
+		if (!Doc->ApplyGuides(&nx, &ny) && !Doc->ApplyGuides(&nx, &ny,true))
 		{
 			FPoint npx;
 			npx = Doc->ApplyGridF(FPoint(nx, ny));
@@ -1975,6 +1978,7 @@
 		nx = gx+gw;
 		ny = gy+gh;
 		Doc->ApplyGuides(&nx, &ny);
+		Doc->ApplyGuides(&nx, &ny,true);
 		Doc->moveGroup(nx-(gx+gw), ny-(gy+gh), false, &newObjects);
 		newObjects.setGroupRect();
 		newObjects.getGroupRect(&gx, &gy, &gw, &gh);
@@ -1988,7 +1992,7 @@
 		{
 			double nx = currItem->xPos();
 			double ny = currItem->yPos();
-			if (!Doc->ApplyGuides(&nx, &ny))
+			if (!Doc->ApplyGuides(&nx, &ny) && !Doc->ApplyGuides(&nx, &ny,true))
 			{
 				FPoint npx;
 				npx = Doc->ApplyGridF(FPoint(nx, ny));
@@ -4255,9 +4259,9 @@
 		{
 			//user creates new frame using linking tool
 			PageItem * frame = Doc->m_Selection->itemAt(0);
+			requestMode(modeImportImage);
 			if (frame)
 			{
-				requestMode(modeImportImage);
 				dynamic_cast<CanvasMode_ImageImport*>(canvasMode())->setImage(frame);
 				dynamic_cast<CanvasMode_ImageImport*>(canvasMode())->updateList();
 			}
Index: scribus/pageitem_textframe.cpp
===================================================================
--- scribus/pageitem_textframe.cpp	(révision 17743)
+++ scribus/pageitem_textframe.cpp	(copie de travail)
@@ -3409,7 +3409,7 @@
 		return;
 	}
 	//>>
-	
+
 	ScribusView* view = m_Doc->view();	
 	switch (kk)
 	{
@@ -3461,14 +3461,31 @@
 			unicodeInputString = "";
 			if (ok)
 			{
+				UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::ITextFrame,Um::InsertText,"",Um::IDelete));
 				if (itemText.lengthOfSelection() > 0)
 					deleteSelectedTextFromFrame();
 				if (conv < 31)
 					conv = 32;
+				if (UndoManager::undoEnabled())
+				{
+					SimpleState *ss = dynamic_cast<SimpleState*>(undoManager->getLastUndo());
+					if(ss && ss->get("ETEA") == "insert_frametext")
+							ss->set("TEXT_STR",ss->get("TEXT_STR") + QString(QChar(conv)));
+					else {
+						ss = new SimpleState(Um::InsertText,"",Um::ICreate);
+						ss->set("INSERT_FRAMETEXT", "insert_frametext");
+						ss->set("ETEA", QString("insert_frametext"));
+						ss->set("TEXT_STR", QString(QChar(conv)));
+						ss->set("START", itemText.cursorPosition());
+						undoManager->action(this, ss);
+					}
+				}
 				itemText.insertChars(QString(QChar(conv)), true);
+				trans.commit();
 //				Tinput = true;
 				m_Doc->scMW()->setTBvals(this);
 				update();
+				doc()->changed();
 				keyRepeat = false;
 				return;
 			}
@@ -3772,14 +3789,18 @@
 		if (itemText.lengthOfSelection() == 0)
 			itemText.select(itemText.cursorPosition(), 1, true);
 		deleteSelectedTextFromFrame();
+		updateLayout();
+		if (oldLast != lastInFrame() && NextBox != 0 && NextBox->invalid)
+			NextBox->updateLayout();
 		update();
 //		Tinput = false;
-		if ((cr == QChar(13)) && (itemText.length() != 0))
-		{
+//		if ((cr == QChar(13)) && (itemText.length() != 0))
+//		{
 //			m_Doc->chAbStyle(this, findParagraphStyle(m_Doc, itemText.paragraphStyle(qMax(itemText.cursorPosition()-1,0))));
 //			Tinput = false;
-		}
+//		}
 		m_Doc->scMW()->setTBvals(this);
+		doc()->changed();
 //		view->RefreshItem(this);
 		break;
 	case Qt::Key_Backspace:
@@ -3826,6 +3847,7 @@
 		}
 		m_Doc->scMW()->setTBvals(this);
 		update();
+		doc()->changed();
 //		view->RefreshItem(this);
 		break;
 	default:
@@ -3938,12 +3960,12 @@
 			updateLayout();
 			if (oldLast != lastInFrame() && NextBox != 0 && NextBox->invalid)
 				NextBox->updateLayout();
+			doc()->changed();
 		}
 		//check if cursor need to jump to next linked frame
 		if ((itemText.cursorPosition() > lastInFrame() + 1) && (lastInFrame() < (itemText.length() - 2)) && NextBox != 0)
 		{
 			view->Deselect(true);
-			view->Deselect(true);
 			NextBox->update();
 			m_Doc->scMW()->selectItemsFromOutlines(NextBox);
 		}
@@ -3952,10 +3974,7 @@
 // 	update();
 //	view->slotDoCurs(true);
 	if ((kk == Qt::Key_Left) || (kk == Qt::Key_Right) || (kk == Qt::Key_Up) || (kk == Qt::Key_Down))
-	{
 		keyRepeat = false;
-		return;
-	}
 }
 
 void PageItem_TextFrame::deleteSelectedTextFromFrame()
Index: scribus/canvasmode.cpp
===================================================================
--- scribus/canvasmode.cpp	(révision 17743)
+++ scribus/canvasmode.cpp	(copie de travail)
@@ -766,8 +766,29 @@
 }
 #endif // GESTURE_FRAME_PREVIEW
 
+void CanvasMode::drawSnapLine(QPainter* p)
+{
+	if(m_doc->SnapElement)
+	{
+		if(ySnap)
+		{
+			p->setPen(Qt::green);
+			double x = (m_doc->currentPage()->xOffset() - m_doc->bleedsVal().Left)* m_canvas->scale();
+			double w = (m_doc->currentPage()->width() + m_doc->bleedsVal().Left + m_doc->bleedsVal().Right) * m_canvas->scale();
+			p->drawLine(x, ySnap, x+w,ySnap);
+			ySnap = 0;
+		}
+		if(xSnap)
+		{
+			p->setPen(Qt::green);
+			double y = (m_doc->currentPage()->yOffset() - m_doc->bleedsVal().Top) * m_canvas->scale();
+			double h = (m_doc->currentPage()->height() + m_doc->bleedsVal().Bottom + m_doc->bleedsVal().Top) * m_canvas->scale();
+			p->drawLine(xSnap, y, xSnap,y+h);
+			xSnap = 0;
+		}
+	}
+}
 
-
 void CanvasMode::setResizeCursor(int how, double rot)
 {
 	switch (how)
@@ -1265,14 +1286,17 @@
 						/* Don't use Grid or Guide Snapping when dragging Items or Groups with the keyboard */
 						/* as the user might be trying to fine tune a position */
 							bool sav1 = m_doc->SnapGuides;
+							bool sav3 = m_doc->SnapElement;
 							bool sav2 = m_doc->useRaster;
 							m_doc->SnapGuides = false;
 							m_doc->useRaster = false;
+							m_doc->SnapElement = false;
 							if (m_doc->m_Selection->count() > 1)
 								m_view->startGroupTransaction(Um::Move, "", Um::IMove);
 							m_doc->moveGroup(-moveBy, 0);
 							if (m_doc->m_Selection->count() > 1)
 								m_view->endGroupTransaction();
+							m_doc->SnapElement = sav3;
 							m_doc->SnapGuides = sav1;
 							m_doc->useRaster = sav2;
 						}
@@ -1337,8 +1361,10 @@
 						/* as the user might be trying to fine tune a position */
 							bool sav1 = m_doc->SnapGuides;
 							bool sav2 = m_doc->useRaster;
+							bool sav3 = m_doc->SnapElement;
 							m_doc->SnapGuides = false;
 							m_doc->useRaster = false;
+							m_doc->SnapElement = false;
 							if (m_doc->m_Selection->count() > 1)
 								m_view->startGroupTransaction(Um::Move, "", Um::IMove);
 							m_doc->moveGroup(moveBy, 0);
@@ -1346,6 +1372,7 @@
 								m_view->endGroupTransaction();
 							m_doc->SnapGuides = sav1;
 							m_doc->useRaster = sav2;
+							m_doc->SnapElement = sav3;
 						}
 					}
 					else
@@ -1408,8 +1435,10 @@
 						/* as the user might be trying to fine tune a position */
 							bool sav1 = m_doc->SnapGuides;
 							bool sav2 = m_doc->useRaster;
+							bool sav3 = m_doc->SnapElement;
 							m_doc->SnapGuides = false;
 							m_doc->useRaster = false;
+							m_doc->SnapElement = false;
 							if (m_doc->m_Selection->count() > 1)
 								m_view->startGroupTransaction(Um::Move, "", Um::IMove);
 							m_doc->moveGroup(0, -moveBy);
@@ -1417,6 +1446,7 @@
 								m_view->endGroupTransaction();
 							m_doc->SnapGuides = sav1;
 							m_doc->useRaster = sav2;
+							m_doc->SnapElement = sav3;
 						}
 					}
 					else
@@ -1479,8 +1509,10 @@
 						/* as the user might be trying to fine tune a position */
 							bool sav1 = m_doc->SnapGuides;
 							bool sav2 = m_doc->useRaster;
+							bool sav3 = m_doc->SnapElement;
 							m_doc->SnapGuides = false;
 							m_doc->useRaster = false;
+							m_doc->SnapElement = false;
 							if (m_doc->m_Selection->count() > 1)
 								m_view->startGroupTransaction(Um::Move, "", Um::IMove);
 							m_doc->moveGroup(0, moveBy);
@@ -1488,6 +1520,7 @@
 								m_view->endGroupTransaction();
 							m_doc->SnapGuides = sav1;
 							m_doc->useRaster = sav2;
+							m_doc->SnapElement = sav3;
 						}
 					}
 					else
Index: scribus/canvasgesture_resize.cpp
===================================================================
--- scribus/canvasgesture_resize.cpp	(révision 17743)
+++ scribus/canvasgesture_resize.cpp	(copie de travail)
@@ -420,13 +420,21 @@
 	}
 
 	// snap to grid	+ snap to guides
+	xSnap = 0;
+	ySnap = 0;
 	bool isCorner = m_handle == Canvas::NORTHWEST || m_handle == Canvas::NORTHEAST 
 		|| m_handle == Canvas::SOUTHWEST || m_handle == Canvas::SOUTHEAST;
 	if (m_rotation == 0 || isCorner)
 	{
 		FPoint snappedPoint = m_doc->ApplyGridF(docPoint);
 		double x = snappedPoint.x(), y = snappedPoint.y();
+
 		m_doc->ApplyGuides(&x, &y);
+		m_doc->ApplyGuides(&x, &y,true);
+		if(x != snappedPoint.x() && m_handle != Canvas::NORTH && m_handle != Canvas::SOUTH)
+			xSnap = x * m_canvas->scale();
+		if(y != snappedPoint.y() && m_handle != Canvas::EAST && m_handle != Canvas::WEST)
+			ySnap = y * m_canvas->scale();
 //		if (m_doc->ApplyGuides(&x, &y))
 //			qDebug() << "guides applied:" << snappedPoint.x() << snappedPoint.y() << "to" << x << y;
 		if (m_handle == Canvas::NORTH || m_handle == Canvas::SOUTH) 
Index: scribus/canvasmode_create.cpp
===================================================================
--- scribus/canvasmode_create.cpp	(révision 17743)
+++ scribus/canvasmode_create.cpp	(copie de travail)
@@ -299,6 +299,7 @@
 				double nx = np2.x();
 				double ny = np2.y();
 				m_doc->ApplyGuides(&nx, &ny);
+				m_doc->ApplyGuides(&nx, &ny,true);
 				// #8959 : suppress qRound here as this prevent drawing line with angle constrain
 				// precisely and does not allow to stick precisely to grid or guides
 				newX = /*qRound(*/nx/*)*/;
@@ -359,6 +360,7 @@
 
 	canvasCurrCoord = canvasPressCoord;
 	m_doc->ApplyGuides(&Rxp, &Ryp);
+	m_doc->ApplyGuides(&Rxp, &Ryp,true);
 	createObjectPos.setXY(Rxp, Ryp);
 
 	if (m->button() == Qt::MidButton)
@@ -667,6 +669,7 @@
 		Rxp = createObjectPos.x();
 		Ryp = createObjectPos.y();
 		m_doc->ApplyGuides(&Rxp, &Ryp);
+		m_doc->ApplyGuides(&Rxp, &Ryp,true);
 		rot = xy2Deg(Rxpd, Rypd);
 		if (rot < 0.0) 
 			rot += 360;
@@ -934,14 +937,16 @@
 	FPoint first = m_doc->ApplyGridF(firstPoint);
 	FPoint second = m_doc->ApplyGridF(secondPoint);
 
-	// Lock to guides.
+	// Lock to guides and items.
 	double firstX = first.x();
 	double firstY = first.y();
 	m_doc->ApplyGuides(&firstX, &firstY);
+	m_doc->ApplyGuides(&firstX, &firstY,true);
 
 	double secondX = second.x();
 	double secondY = second.y();
 	m_doc->ApplyGuides(&secondX, &secondY);
+	m_doc->ApplyGuides(&secondX, &secondY,true);
 
 	// Return normalized rectangle.
 	FRect rect(firstX, firstY, secondX - firstX, secondY - firstY);
Index: scribus/prefsmanager.cpp
===================================================================
--- scribus/prefsmanager.cpp	(révision 17743)
+++ scribus/prefsmanager.cpp	(copie de travail)
@@ -258,7 +258,7 @@
 	appPrefs.itemToolPrefs.lineEndArrow = 0;
 	appPrefs.opToolPrefs.magMin = 1;
 	appPrefs.opToolPrefs.magMax = 3200;
-	appPrefs.opToolPrefs.magStep = 200;
+	appPrefs.opToolPrefs.magStep = 125;
 	appPrefs.docSetupPrefs.docUnitIndex = 0;
 	appPrefs.itemToolPrefs.polyCorners = 4;
 	appPrefs.itemToolPrefs.polyFactor = 0.5;
@@ -2104,8 +2104,8 @@
 			appPrefs.itemToolPrefs.imageStrokeColorShade = dc.attribute("ImageStrokeColorShade", "100").toInt();
 			appPrefs.itemToolPrefs.imageScaleX = ScCLocale::toDoubleC(dc.attribute("ImageScaleX"), 1.0);
 			appPrefs.itemToolPrefs.imageScaleY = ScCLocale::toDoubleC(dc.attribute("ImageScaleY"), 1.0);
-			appPrefs.itemToolPrefs.imageScaleType = static_cast<bool>(dc.attribute("PSCALE", "1").toInt());
-			appPrefs.itemToolPrefs.imageAspectRatio = static_cast<bool>(dc.attribute("PASPECT", "0").toInt());
+			appPrefs.itemToolPrefs.imageScaleType = static_cast<bool>(dc.attribute("PSCALE", "0").toInt());
+			appPrefs.itemToolPrefs.imageAspectRatio = static_cast<bool>(dc.attribute("PASPECT", "1").toInt());
 			appPrefs.itemToolPrefs.imageUseEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt());
 			appPrefs.itemToolPrefs.imageLowResType = dc.attribute("ImageLowResType", "1").toInt();
 			appPrefs.itemToolPrefs.polyCorners = dc.attribute("PolygonCorners", "4").toInt();
@@ -2146,10 +2146,10 @@
 		{
 			appPrefs.opToolPrefs.magMin  = dc.attribute("MinimumMagnification", "1").toInt();
 			appPrefs.opToolPrefs.magMax  = dc.attribute("MaximumMagnification", "3200").toInt();
-			appPrefs.opToolPrefs.magStep = dc.attribute("MagnificationStep", "200").toInt();
+			appPrefs.opToolPrefs.magStep = dc.attribute("MagnificationStep", "125").toInt();
 			//CB Reset prefs zoom step value to 200% instead of old values.
 			if (appPrefs.opToolPrefs.magStep <= 100)
-				appPrefs.opToolPrefs.magStep = 200;
+				appPrefs.opToolPrefs.magStep = 125;
 			appPrefs.opToolPrefs.dispX = ScCLocale::toDoubleC(dc.attribute("DisplayOffsetX"), 10.0);
 			appPrefs.opToolPrefs.dispY = ScCLocale::toDoubleC(dc.attribute("DisplayOffsetY"), 10.0);
 			appPrefs.opToolPrefs.constrain = ScCLocale::toDoubleC(dc.attribute("RotationConstrainAngle"), 15.0);
Index: scribus/undomanager.cpp
===================================================================
--- scribus/undomanager.cpp	(révision 17743)
+++ scribus/undomanager.cpp	(copie de travail)
@@ -422,7 +422,7 @@
 	if (!stacks_.contains(currentDoc_))
 		stacks_[currentDoc_] = UndoStack();
 
-	stacks_[currentDoc_].setMaxSize(prefs_->getInt("historylength", 20));
+	stacks_[currentDoc_].setMaxSize(prefs_->getInt("historylength", 100));
 	for (uint i = 0; i < undoGuis_.size(); ++i)
 		setState(undoGuis_[i]);
 
@@ -937,6 +937,7 @@
 	UndoManager::SetFontEffect      = tr("Set font effect");
 	UndoManager::ImageFrame         = tr("Image frame");
 	UndoManager::TextFrame          = tr("Text frame");
+	UndoManager::Layer              = tr("Layer");
 	UndoManager::LatexFrame         = tr("Render frame");
 	UndoManager::Polygon            = tr("Polygon");
 	UndoManager::EditPolygon        = tr("Edit polygon");
@@ -1205,6 +1206,7 @@
 QString UndoManager::SetFontEffect      = "";
 QString UndoManager::ImageFrame         = "";
 QString UndoManager::TextFrame          = "";
+QString UndoManager::Layer              = "";
 QString UndoManager::LatexFrame         = "";
 QString UndoManager::Polygon            = "";
 QString UndoManager::EditPolygon        = "";
Index: scribus/canvasmode_editmeshpatch.cpp
===================================================================
--- scribus/canvasmode_editmeshpatch.cpp	(révision 17743)
+++ scribus/canvasmode_editmeshpatch.cpp	(copie de travail)
@@ -570,7 +570,7 @@
 	FPoint npfN;
 	double nx = mousePointDoc.x();
 	double ny = mousePointDoc.y();
-	if (!m_doc->ApplyGuides(&nx, &ny))
+	if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
 		npfN = m_doc->ApplyGridF(FPoint(nx, ny));
 	else
 		npfN = FPoint(nx, ny);
Index: scribus/canvasmode_drawbezier.cpp
===================================================================
--- scribus/canvasmode_drawbezier.cpp	(révision 17743)
+++ scribus/canvasmode_drawbezier.cpp	(copie de travail)
@@ -138,7 +138,7 @@
 //	m_view->stopDragTimer();
 	PageItem* currItem = m_doc->m_Selection->itemAt(0);
 	undoManager->setUndoEnabled(true);
-	if (UndoManager::undoEnabled())
+	if (currItem && UndoManager::undoEnabled())
 	{
 		ScItemState<PageItem*> *is = new ScItemState<PageItem*>("Create PageItem");
 		is->set("CREATE_ITEM", "create_item");
Index: scribus/scribusdoc.cpp
===================================================================
--- scribus/scribusdoc.cpp	(révision 17743)
+++ scribus/scribusdoc.cpp	(copie de travail)
@@ -207,7 +207,8 @@
 	NrItems(0),
 	First(1), Last(0),
 	viewCount(0), viewID(0),
-	SnapGuides(false), GuideLock(false),
+	SnapGuides(false),
+	SnapElement(false), GuideLock(false),
 	minCanvasCoordinate(FPoint(0, 0)),
 	rulerXoffset(0.0), rulerYoffset(0.0),
 	Pages(0), MasterPages(), DocPages(),
@@ -301,6 +302,7 @@
 	NrItems(0),
 	First(1), Last(0),
 	viewCount(0), viewID(0),
+	SnapElement(false),
 	SnapGuides(false), GuideLock(false),
 	minCanvasCoordinate(FPoint(0, 0)),
 	rulerXoffset(0.0), rulerYoffset(0.0),
@@ -2472,7 +2474,7 @@
 	QString name   = lToRemove->Name;
 	UndoTransaction* activeTransaction = NULL;
 	if (UndoManager::undoEnabled())
-		activeTransaction = new UndoTransaction(undoManager->beginTransaction("Layer", Um::IDocument, Um::DeleteLayer, "", Um::IDelete));
+		activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Layer, Um::IDocument, Um::DeleteLayer, "", Um::IDelete));
 
 	rebuildItemLists();
 	if (ScCore->usingGUI())
@@ -4965,7 +4967,9 @@
 		   iafData.linkToExistingFramePtr->itemType()==PageItem::TextFrame &&
 		   DocItems.contains(iafData.linkToExistingFramePtr))
 		prevItem=iafData.linkToExistingFramePtr;
-	UndoTransaction transaction(undoManager->beginTransaction(iafData.frameType==PageItem::TextFrame ? Um::TextFrame : Um::ImageFrame,
+	UndoTransaction *transaction = NULL;
+	if(UndoManager::undoEnabled())
+		transaction = new UndoTransaction(undoManager->beginTransaction(iafData.frameType==PageItem::TextFrame ? Um::TextFrame : Um::ImageFrame,
 															  iafData.frameType==PageItem::TextFrame ? Um::ITextFrame : Um::IImageFrame,
 															  Um::InsertFrame, "", Um::ICreate));
 	for (uint i=0;i<pageNs.size();++i)
@@ -5075,7 +5079,12 @@
 		}
 	}
 
-	transaction.commit();
+	if(transaction)
+	{
+		transaction->commit();
+		delete transaction;
+		transaction = NULL;
+	}
 	setCurrentPage(oldCurrentPage);
 	changed();
 	regionsChanged()->update(QRectF());
@@ -5811,9 +5820,7 @@
 		case PageItem::TextFrame:
 			newItem = new PageItem_TextFrame(*oldItem);
 			if (UndoManager::undoEnabled() && oldItem->itemType()==PageItem::PathText)
-			{
 				transactionConversion = new UndoTransaction(undoManager->beginTransaction(currentPage()->getUName(), 0, Um::TextFrame, "", Um::ITextFrame));
-			}
 			break;
 		//We dont allow this
 /*		case PageItem::Line:
@@ -5829,9 +5836,7 @@
 			if (secondaryItem==NULL)
 				return NULL;
 			if (UndoManager::undoEnabled())
-			{
 				transactionConversion = new UndoTransaction(undoManager->beginTransaction(currentPage()->getUName(), 0, Um::PathText, "", Um::ITextFrame));
-			}
 			newItem = new PageItem_PathText(*oldItem);
 			break;
 		default:
@@ -5847,6 +5852,7 @@
 		{
 			transactionConversion->cancel();
 			delete transactionConversion;
+			transactionConversion = NULL;
 		}
 		return NULL;
 	}
@@ -5975,9 +5981,9 @@
 	//Create the undo action for the new item
 	if (UndoManager::undoEnabled())
 	{
-		ScItemState<std::pair<PageItem*, PageItem*> > *is = new ScItemState<std::pair<PageItem*, PageItem*> >("Convert Item");
+		ScItemState<QPair<PageItem*, PageItem*> > *is = new ScItemState<QPair<PageItem*, PageItem*> >("Convert Item");
 		is->set("CONVERT_ITEM", "convert_item");
-		is->setItem(std::pair<PageItem*, PageItem*>(oldItem, newItem));
+		is->setItem(qMakePair(oldItem, newItem));
 		//Undo target rests with the Page for object specific undo
 		UndoObject *target = Pages->at(0);
 		if (newItem->OwnPage > -1)
@@ -6374,11 +6380,9 @@
 		return false;
 	QMap<uint, DocumentSection>::Iterator itprev=docPrefsData.docSectionMap.begin();
 	QMap<uint, DocumentSection>::Iterator it=itprev;
-	uint currMinIndex = itprev.value().fromindex;
 	uint currMaxIndex = itprev.value().toindex;
 	for ( ; it != docPrefsData.docSectionMap.end(); ++it )
 	{
-		currMinIndex=it.value().fromindex;
 		currMaxIndex=it.value().toindex;
 
 		if (it.key()!=number)
@@ -6648,8 +6652,10 @@
 				int currActiveLayer = activeLayer();
 				bool savedAlignGrid   = this->useRaster;
 				bool savedAlignGuides = this->SnapGuides;
+				bool savedAlignElement = this->SnapElement;
 				this->useRaster  = false;
 				this->SnapGuides = false;
+				this->SnapElement = false;
 				for (it = Layers.begin(); it != Layers.end(); ++it)
 				{
 					if ((lcount < itemBuffer.count()) && !itemBuffer[lcount].isEmpty())
@@ -6663,6 +6669,7 @@
 				}
 				this->useRaster  = savedAlignGrid;
 				this->SnapGuides = savedAlignGuides;
+				this->SnapElement = savedAlignElement;
 				setActiveLayer(currActiveLayer);
 			}
 		}
@@ -7186,7 +7193,7 @@
 	{
 		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
-		if (selectedItemCount > 1)
+		if (UndoManager::undoEnabled() && selectedItemCount > 1)
 			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
 																				  Um::IGroup, Um::LineWidth, "", Um::ILineStyle));
 		for (uint a = 0; a < selectedItemCount; ++a)
@@ -7230,7 +7237,7 @@
 	{
 		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
-		if (selectedItemCount > 1)
+		if (UndoManager::undoEnabled() && selectedItemCount > 1)
 			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
 																				  Um::IGroup, Um::LineStyle, "", Um::ILineStyle));
 		for (uint a = 0; a < selectedItemCount; ++a)
@@ -7258,7 +7265,7 @@
 	{
 		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
-		if (selectedItemCount > 1)
+		if (UndoManager::undoEnabled() && selectedItemCount > 1)
 			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
 																				  Um::IGroup, Um::LineJoin, "", Um::ILineStyle));
 		for (uint a = 0; a < selectedItemCount; ++a)
@@ -7286,7 +7293,7 @@
 	{
 		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
-		if (selectedItemCount > 1)
+		if (UndoManager::undoEnabled() && selectedItemCount > 1)
 			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
 																				  Um::IGroup, Um::LineEnd, "", Um::ILineStyle));
 		for (uint a = 0; a < selectedItemCount; ++a)
@@ -7348,7 +7355,7 @@
 	{
 		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
-		if (docSelectionCount > 1)
+		if (UndoManager::undoEnabled() && docSelectionCount > 1)
 			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::LineStyle, name, Um::ILineStyle));
 		for (uint aa = 0; aa < docSelectionCount; ++aa)
 		{
@@ -7377,7 +7384,7 @@
 		m_updateManager.setUpdatesDisabled();
 		if (farbe == CommonStrings::tr_NoneColor)
 			farbe = CommonStrings::None;
-		if (selectedItemCount > 1)
+		if (selectedItemCount > 1 && UndoManager::undoEnabled())
 			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
 																				  Um::IGroup, Um::SetLineColor, farbe, Um::IFill));
 		PageItem *i;
@@ -7494,7 +7501,7 @@
 	{
 		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
-		if (selectedItemCount > 1)
+		if (selectedItemCount > 1 && UndoManager::undoEnabled())
 			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
 																				  Um::IGroup, Um::SetFill, farbe, Um::IFill));
 		PageItem *currItem;
@@ -7522,7 +7529,7 @@
 	{
 		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
-		if (selectedItemCount > 1)
+		if (selectedItemCount > 1 && UndoManager::undoEnabled())
 			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
 																				  Um::IGroup, Um::SetShade, QString("%1").arg(sha),
 																				  Um::IShade));
@@ -7551,7 +7558,7 @@
 	{
 		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
-		if (selectedItemCount > 1)
+		if (selectedItemCount > 1 && UndoManager::undoEnabled())
 			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup,
 																				  Um::IGroup, Um::SetLineShade, QString("%1").arg(sha), Um::IShade));
 		PageItem *currItem;
@@ -7577,9 +7584,11 @@
 	uint selectedItemCount=m_Selection->count();
 	if (selectedItemCount != 0)
 	{
+		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
 		PageItem *currItem;
-		UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradTypeMask,"",Um::IFill));
+		if (selectedItemCount > 1 && UndoManager::undoEnabled())
+			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradTypeMask,"",Um::IFill));
 		for (uint a = 0; a < selectedItemCount; ++a)
 		{
 			currItem = m_Selection->itemAt(a);
@@ -7588,7 +7597,12 @@
 				currItem->updateGradientVectors();
 			currItem->update();
 		}
-		trans.commit();
+		if (activeTransaction)
+		{
+			activeTransaction->commit();
+			delete activeTransaction;
+			activeTransaction = NULL;
+		}
 		m_updateManager.setUpdatesEnabled();
 		changed();
 	}
@@ -7599,9 +7613,11 @@
 	uint selectedItemCount=m_Selection->count();
 	if (selectedItemCount != 0)
 	{
+		UndoTransaction *activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
 		PageItem *currItem;
-		UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradTypeMask,"",Um::IFill));
+		if (UndoManager::undoEnabled())
+			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradTypeMask,"",Um::IFill));
 		for (uint a = 0; a < selectedItemCount; ++a)
 		{
 			currItem = m_Selection->itemAt(a);
@@ -7636,7 +7652,12 @@
 				currItem->updateGradientVectors();
 			currItem->update();
 		}
-		trans.commit();
+		if (activeTransaction)
+		{
+			activeTransaction->commit();
+			delete activeTransaction;
+			activeTransaction = NULL;
+		}
 		m_updateManager.setUpdatesEnabled();
 		changed();
 	}
@@ -7647,9 +7668,11 @@
 	uint selectedItemCount=m_Selection->count();
 	if (selectedItemCount != 0)
 	{
+		UndoTransaction* trans = NULL;
 		m_updateManager.setUpdatesDisabled();
 		PageItem *currItem;
-		UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::SetFill,"",Um::IFill));
+		if(UndoManager::undoEnabled())
+			trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::SetFill,"",Um::IFill));
 		for (uint a = 0; a < selectedItemCount; ++a)
 		{
 			currItem = m_Selection->itemAt(a);
@@ -7729,7 +7752,12 @@
 				currItem->createConicalMesh();
 			currItem->update();
 		}
-		trans.commit();
+		if(trans)
+		{
+			trans->commit();
+			delete trans;
+			trans = NULL;
+		}
 		m_updateManager.setUpdatesEnabled();
 		changed();
 	}
@@ -8481,7 +8509,7 @@
 						ScItemState<QPair<ParagraphStyle,ParagraphStyle> > *is = new ScItemState<QPair <ParagraphStyle,ParagraphStyle> >(Um::SetStyle);
 						is->set("SET_PARASTYLE", "set_parastyle");
 						is->set("POS",pos);
-						is->setItem(QPair<ParagraphStyle,ParagraphStyle>(newStyle, currItem->itemText.paragraphStyle(pos)));
+						is->setItem(qMakePair(newStyle, currItem->itemText.paragraphStyle(pos)));
 						undoManager->action(currItem, is);
 					}
 					currItem->itemText.setStyle(pos, newStyle);
@@ -8494,7 +8522,7 @@
 				ScItemState<QPair<ParagraphStyle,ParagraphStyle> > *is = new ScItemState<QPair <ParagraphStyle,ParagraphStyle> >(Um::SetStyle);
 				is->set("SET_PARASTYLE", "set_parastyle");
 				is->set("POS",stop);
-				is->setItem(QPair<ParagraphStyle,ParagraphStyle>(newStyle2, currItem->itemText.paragraphStyle(stop)));
+				is->setItem(qMakePair(newStyle2, currItem->itemText.paragraphStyle(stop)));
 				undoManager->action(currItem, is);
 			}
 			currItem->itemText.setStyle(stop, newStyle2);
@@ -8507,7 +8535,7 @@
 			{
 				ScItemState<QPair<ParagraphStyle,ParagraphStyle> > *is = new ScItemState<QPair <ParagraphStyle,ParagraphStyle> >(Um::SetStyle);
 				is->set("APPLY_DEFAULTPARASTYLE", "apply_defaultparastyle");
-				is->setItem(QPair<ParagraphStyle,ParagraphStyle>(newStyle, currItem->itemText.defaultStyle()));
+				is->setItem(qMakePair(newStyle, currItem->itemText.defaultStyle()));
 				undoManager->action(currItem, is);
 			}
 			currItem->itemText.setDefaultStyle(newStyle);
@@ -8534,7 +8562,7 @@
 	if (selectedItemCount == 0)
 		return;
 	UndoTransaction* activeTransaction = NULL;
-	if (selectedItemCount > 1)
+	if (UndoManager::undoEnabled() && selectedItemCount > 1)
 		activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::ApplyTextStyle, newStyle.displayName(), Um::IFont));
 	for (uint aa = 0; aa < selectedItemCount; ++aa)
 	{
@@ -8548,7 +8576,7 @@
 			{
 				ScItemState<QPair<ParagraphStyle,ParagraphStyle> > *is = new ScItemState<QPair <ParagraphStyle,ParagraphStyle> >(Um::SetStyle);
 				is->set("APPLY_DEFAULTPARASTYLE", "apply_defaultparastyle");
-				is->setItem(QPair<ParagraphStyle,ParagraphStyle>(dstyle, currItem->itemText.defaultStyle()));
+				is->setItem(qMakePair(dstyle, currItem->itemText.defaultStyle()));
 				undoManager->action(currItem, is);
 			}
 			currItem->itemText.setDefaultStyle(dstyle);
@@ -8573,7 +8601,7 @@
 						ScItemState<QPair<ParagraphStyle,ParagraphStyle> > *is = new ScItemState<QPair <ParagraphStyle,ParagraphStyle> >(Um::SetStyle);
 						is->set("APPLY_PARASTYLE", "apply_parastyle");
 						is->set("POS",pos);
-						is->setItem(QPair<ParagraphStyle,ParagraphStyle>(newStyle, currItem->itemText.paragraphStyle(pos)));
+						is->setItem(qMakePair(newStyle, currItem->itemText.paragraphStyle(pos)));
 						undoManager->action(currItem, is);
 					}
 					currItem->itemText.applyStyle(pos, newStyle, rmDirectFormatting);
@@ -8584,7 +8612,7 @@
 				ScItemState<QPair<ParagraphStyle,ParagraphStyle> > *is = new ScItemState<QPair <ParagraphStyle,ParagraphStyle> >(Um::SetStyle);
 				is->set("APPLY_PARASTYLE", "apply_parastyle");
 				is->set("POS",stop);
-				is->setItem(QPair<ParagraphStyle,ParagraphStyle>(newStyle, currItem->itemText.paragraphStyle(stop)));
+				is->setItem(qMakePair(newStyle, currItem->itemText.paragraphStyle(stop)));
 				undoManager->action(currItem, is);
 			}
 			currItem->itemText.applyStyle(stop, newStyle, rmDirectFormatting);
@@ -8656,9 +8684,9 @@
 							ss = dynamic_cast<SimpleState*>(ts->at(0));
 						if(ss && ss->get("ETEA") == ETEA)
 						{
-							for(int i=0;i<ts->sizet();i++){
+							for(uint i=0;i<ts->sizet();i++){
 								is = dynamic_cast<ScItemState<QPair<CharStyle,CharStyle> > *>(ts->at(i));
-								is->setItem(QPair<CharStyle,CharStyle>(newStyle, is->getItem().second));
+								is->setItem(qMakePair(newStyle, is->getItem().second));
 							}
 						}
 						else
@@ -8668,7 +8696,7 @@
 							is->set("START",lastPos);
 							is->set("LENGTH",i-lastPos);
 							is->set("ETEA", ETEA);
-							is->setItem(QPair<CharStyle,CharStyle>(newStyle, currItem->itemText.charStyle(lastPos)));
+							is->setItem(qMakePair(newStyle, currItem->itemText.charStyle(lastPos)));
 							undoManager->action(currItem, is);
 						}
 					}
@@ -8687,7 +8715,7 @@
 			{
 				ScItemState<QPair<ParagraphStyle,ParagraphStyle> > *is = new ScItemState<QPair <ParagraphStyle,ParagraphStyle> >(Um::SetStyle);
 				is->set("APPLY_DEFAULTPARASTYLE", "apply_defaultparastyle");
-				is->setItem(QPair<ParagraphStyle,ParagraphStyle>(dstyle, currItem->itemText.defaultStyle()));
+				is->setItem(qMakePair(dstyle, currItem->itemText.defaultStyle()));
 				undoManager->action(currItem, is);
 			}
 			CharStyle lastParent = currItem->itemText.charStyle(0);
@@ -8704,7 +8732,7 @@
 						ist->set("APPLY_CHARSTYLE", "apply_charstyle");
 						ist->set("START",lastPos);
 						ist->set("LENGTH",i-lastPos);
-						ist->setItem(QPair<CharStyle,CharStyle>(newStyle, currItem->itemText.charStyle(lastPos)));
+						ist->setItem(qMakePair(newStyle, currItem->itemText.charStyle(lastPos)));
 						undoManager->action(currItem, ist);
 					}
 					lastPos = i;
@@ -8770,7 +8798,7 @@
 				is->set("SET_CHARSTYLE", "set_charstyle");
 				is->set("START",start);
 				is->set("LENGTH",length);
-				is->setItem(QPair<CharStyle,CharStyle>(newStyle, currItem->itemText.charStyle(start)));
+				is->setItem(qMakePair(newStyle, currItem->itemText.charStyle(start)));
 				undoManager->action(currItem, is);
 			}
 			currItem->itemText.setCharStyle(start, length, newStyle);
@@ -8784,14 +8812,14 @@
 			{
 				ScItemState<QPair<ParagraphStyle,ParagraphStyle> > *is = new ScItemState<QPair <ParagraphStyle,ParagraphStyle> >(Um::SetStyle);
 				is->set("APPLY_DEFAULTPARASTYLE", "apply_defaultparastyle");
-				is->setItem(QPair<ParagraphStyle,ParagraphStyle>(dstyle, currItem->itemText.defaultStyle()));
+				is->setItem(qMakePair(dstyle, currItem->itemText.defaultStyle()));
 				undoManager->action(currItem, is);
 
 				ScItemState<QPair<CharStyle,CharStyle> > *ist = new ScItemState<QPair <CharStyle,CharStyle> >(Um::ApplyTextStyle);
 				ist->set("SET_CHARSTYLE", "set_charstyle");
 				ist->set("START",0);
 				ist->set("LENGTH",currItem->itemText.length());
-				ist->setItem(QPair<CharStyle,CharStyle>(newStyle, currItem->itemText.charStyle(0)));
+				ist->setItem(qMakePair(newStyle, currItem->itemText.charStyle(0)));
 				undoManager->action(currItem, ist);
 			}
 			currItem->itemText.setDefaultStyle(dstyle);
@@ -8864,7 +8892,7 @@
 							is->set("SET_CHARSTYLE", "set_charstyle");
 							is->set("START",lastPos);
 							is->set("LENGTH",i-lastPos);
-							is->setItem(QPair<CharStyle,CharStyle>(newStyle, currItem->itemText.charStyle(lastPos)));
+							is->setItem(qMakePair(newStyle, currItem->itemText.charStyle(lastPos)));
 							undoManager->action(currItem, is);
 						}
 						currItem->itemText.setCharStyle(lastPos, i-lastPos, newStyle);
@@ -8883,7 +8911,7 @@
 					is->set("SET_CHARSTYLE", "set_charstyle");
 					is->set("START",lastPos);
 					is->set("LENGTH",stop-lastPos);
-					is->setItem(QPair<CharStyle,CharStyle>(newStyle2, currItem->itemText.charStyle(lastPos)));
+					is->setItem(qMakePair(newStyle2, currItem->itemText.charStyle(lastPos)));
 					undoManager->action(currItem, is);
 				}
 				currItem->itemText.setCharStyle(lastPos, stop-lastPos, newStyle2);
@@ -8899,7 +8927,7 @@
 			{
 				ScItemState<QPair<ParagraphStyle,ParagraphStyle> > *is = new ScItemState<QPair <ParagraphStyle,ParagraphStyle> >(Um::SetStyle);
 				is->set("APPLY_DEFAULTPARASTYLE", "apply_defaultparastyle");
-				is->setItem(QPair<ParagraphStyle,ParagraphStyle>(defStyle, currItem->itemText.defaultStyle()));
+				is->setItem(qMakePair(defStyle, currItem->itemText.defaultStyle()));
 				undoManager->action(currItem, is);
 			}
 			currItem->itemText.setDefaultStyle(defStyle);
@@ -9889,7 +9917,7 @@
 	{
 		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
-		if (docSelectionCount > 1)
+		if (UndoManager::undoEnabled() && docSelectionCount > 1)
 		{
 			if (m_Selection->itemAt(0)->locked())
 				activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::UnLock, 0, Um::IUnLock));
@@ -9921,7 +9949,7 @@
 	{
 		UndoTransaction* activeTransaction = NULL;
 		m_updateManager.setUpdatesDisabled();
-		if (selectedItemCount > 1)
+		if (UndoManager::undoEnabled() && selectedItemCount > 1)
 		{
 			if (m_Selection->itemAt(0)->sizeLocked())
 				activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::SizeUnLock, 0, Um::IUnLock));
@@ -9976,7 +10004,7 @@
 		return;
 	UndoTransaction* activeTransaction = NULL;
 	m_updateManager.setUpdatesDisabled();
-	if (docSelectionCount > 1)
+	if (docSelectionCount > 1 && UndoManager::undoEnabled())
 	{
 		if (m_Selection->itemAt(0)->printEnabled())
 			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::DisablePrint, 0, Um::IDisablePrint));
@@ -10044,18 +10072,21 @@
 				matrixAft.translate(gw, 0);
 				break;
 			}
-			ScItemState<QList<QTransform> > *state = new ScItemState<QList<QTransform> >(Um::Transform);
-			state->set("TRANSFORM", "TRANSFORM");
-			state->set("DX",deltaX);
-			state->set("DY",deltaY);
-			state->set("POSX",currItem->xPos());
-			state->set("POSY",currItem->yPos());
-			QList<QTransform> l;
-			l.append(matrixPre);
-			l.append(matrix);
-			l.append(matrixAft);
-			state->setItem(l);
-			undoManager->action(currItem, state);
+			if(UndoManager::undoEnabled())
+			{
+				ScItemState<QList<QTransform> > *state = new ScItemState<QList<QTransform> >(Um::Transform);
+				state->set("TRANSFORM", "TRANSFORM");
+				state->set("DX",deltaX);
+				state->set("DY",deltaY);
+				state->set("POSX",currItem->xPos());
+				state->set("POSY",currItem->yPos());
+				QList<QTransform> l;
+				l.append(matrixPre);
+				l.append(matrix);
+				l.append(matrixAft);
+				state->setItem(l);
+				undoManager->action(currItem, state);
+			}
 
 			currItem->PoLine.translate(deltaX, deltaY);
 			currItem->PoLine.map(matrixPre);
@@ -10070,9 +10101,7 @@
 //			currItem->Frame = false;
 			currItem->ClipEdited = true;
 //			currItem->FrameType = 3;
-			undoManager->setUndoEnabled(false);
 			AdjustItemSize(currItem);
-			undoManager->setUndoEnabled(true);
 		}
 	}
 	else
@@ -10080,8 +10109,10 @@
 		QList<PageItem*> Elements;
 		bool savedAlignGrid = useRaster;
 		bool savedAlignGuides = SnapGuides;
+		bool savedAlignElement = SnapElement;
 		useRaster = false;
 		SnapGuides = false;
+		SnapElement = false;
 		DoDrawing = false;
 		view()->updatesOn(false);
 		m_Selection->delaySignalsOn();
@@ -10134,18 +10165,21 @@
 					break;
 				}
 
-				ScItemState<QList<QTransform> > *state = new ScItemState<QList<QTransform> >(Um::Transform);
-				state->set("TRANSFORM", "TRANSFORM");
-				state->set("DX",deltaX);
-				state->set("DY",deltaY);
-				state->set("POSX",currItem->xPos());
-				state->set("POSY",currItem->yPos());
-				QList<QTransform> l;
-				l.append(matrixPre);
-				l.append(matrix);
-				l.append(matrixAft);
-				state->setItem(l);
-				undoManager->action(currItem, state);
+				if(UndoManager::undoEnabled())
+				{
+					ScItemState<QList<QTransform> > *state = new ScItemState<QList<QTransform> >(Um::Transform);
+					state->set("TRANSFORM", "TRANSFORM");
+					state->set("DX",deltaX);
+					state->set("DY",deltaY);
+					state->set("POSX",currItem->xPos());
+					state->set("POSY",currItem->yPos());
+					QList<QTransform> l;
+					l.append(matrixPre);
+					l.append(matrix);
+					l.append(matrixAft);
+					state->setItem(l);
+					undoManager->action(currItem, state);
+				}
 
 				currItem->PoLine.translate(deltaX, deltaY);
 				currItem->PoLine.map(matrixPre);
@@ -10160,9 +10194,7 @@
 //				currItem->Frame = false;
 				currItem->ClipEdited = true;
 //				currItem->FrameType = 3;
-				undoManager->setUndoEnabled(false);
 				AdjustItemSize(currItem);
-				undoManager->setUndoEnabled(true);
 				Elements.append(currItem);
 			}
 			comulatedMatrix *= matrix;
@@ -10175,6 +10207,7 @@
 		RotMode (rotBack);
 		useRaster = savedAlignGrid;
 		SnapGuides = savedAlignGuides;
+		SnapGuides = savedAlignElement;
 		DoDrawing = true;
 		m_Selection->delaySignalsOff();
 		view()->updatesOn(true);
@@ -10193,7 +10226,9 @@
 	uint docSelectionCount=m_Selection->count();
 	if (docSelectionCount == 0)
 		return;
-	UndoTransaction trans(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipH, 0, Um::IFlipH));
+	UndoTransaction*  trans = NULL;
+	if(UndoManager::undoEnabled())
+		trans = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipH, 0, Um::IFlipH));
 	if (docSelectionCount > 1)
 	{
 		double gx, gy, gh, gw, ix, iy, iw, ih;
@@ -10290,7 +10325,12 @@
 		else if (currItem->isSpiral())
 			emit updateEditItem();
 	}
-	trans.commit();
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 	regionsChanged()->update(QRectF());
 	changed();
 	emit firstSelectedItemType(m_Selection->itemAt(0)->itemType());
@@ -10302,7 +10342,9 @@
 	uint docSelectionCount=m_Selection->count();
 	if (docSelectionCount == 0)
 		return;
-	UndoTransaction trans(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipV, 0, Um::IFlipV));
+	UndoTransaction *trans = NULL;
+	if(UndoManager::undoEnabled())
+		trans = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::FlipV, 0, Um::IFlipV));
 	if (docSelectionCount > 1)
 	{
 		double gx, gy, gh, gw, ix, iy, iw, ih;
@@ -10405,7 +10447,12 @@
 			emit updateEditItem();
 		regionsChanged()->update(QRectF());
 	}
-	trans.commit();
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 	changed();
 	emit firstSelectedItemType(m_Selection->itemAt(0)->itemType());
 }
@@ -11217,17 +11264,14 @@
 		return;
 	m_updateManager.setUpdatesDisabled();
 	UndoTransaction* outerTransaction = NULL;
-	if (UndoManager::undoEnabled() && selectedItemCount > 1)
+	if (UndoManager::undoEnabled())
 		outerTransaction = new UndoTransaction(undoManager->beginTransaction());
 	QString tooltip = Um::ItemsInvolved + "\n";
 	if (selectedItemCount > Um::ItemsInvolvedLimit)
 		tooltip = Um::ItemsInvolved2 + "\n";
 	for (uint a = 0; a < selectedItemCount; ++a)
 	{
-		UndoTransaction* activeTransaction = NULL;
 		PageItem *currItem = itemSelection->itemAt(a);
-		if (UndoManager::undoEnabled())
-			activeTransaction = new UndoTransaction(undoManager->beginTransaction());
 		currItem->setImageXYScale(sx, sy);
 		currItem->setImageXYOffset(ox/sx, oy/sy);
 		if (currItem->imageClip.size() != 0)
@@ -11241,16 +11285,6 @@
 		}
 		if (selectedItemCount <= Um::ItemsInvolvedLimit)
 			tooltip += "\t" + currItem->getUName() + "\n";
-		if (activeTransaction)
-		{	
-			activeTransaction->commit(Um::Selection,
-									  Um::IImageFrame,
-									  Um::ImageScale,
-									  tooltip,
-									  Um::IImageScaling);
-			delete activeTransaction;
-			activeTransaction = NULL;
-		}
 		currItem->update();
 	}
 	if (outerTransaction)
@@ -11274,7 +11308,8 @@
 	uint selectedItemCount=itemSelection->count();
 	if (selectedItemCount != 0)
 	{
-		UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IImageFrame,Um::Rotate,"",Um::IRotate));
+		UndoTransaction * trans = NULL;
+			trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IImageFrame,Um::Rotate,"",Um::IRotate));
 		for (uint a = 0; a < selectedItemCount; ++a)
 		{
 			PageItem *currItem = itemSelection->itemAt(a);
@@ -11290,7 +11325,12 @@
 			}
 			currItem->update();
 		}
-		trans.commit();
+		if(trans)
+		{
+			trans->commit();
+			delete trans;
+			trans = NULL;
+		}
 		changed();
 	}
 }
@@ -12944,13 +12984,15 @@
 		currItem->effectsInUse = newEffectList;
 		updatePic();
 		
-		// this messy part is for the undo action
-		ScItemState<QPair<ScImageEffectList, ScImageEffectList> > *state =
-		new ScItemState<QPair<ScImageEffectList, ScImageEffectList> >(
-				Um::ImageEffects, "", currItem->getUPixmap());
-		state->set("APPLY_IMAGE_EFFECTS", "apply_image_effects");
-		state->setItem(QPair<ScImageEffectList, ScImageEffectList>(oldEffects, currItem->effectsInUse));
-		undoManager->action(currItem, state);
+		if(UndoManager::undoEnabled())
+		{
+			ScItemState<QPair<ScImageEffectList, ScImageEffectList> > *state =
+			new ScItemState<QPair<ScImageEffectList, ScImageEffectList> >(
+					Um::ImageEffects, "", currItem->getUPixmap());
+			state->set("APPLY_IMAGE_EFFECTS", "apply_image_effects");
+			state->setItem(qMakePair(oldEffects, currItem->effectsInUse));
+			undoManager->action(currItem, state);
+		}
 		changed();
 	}
 }
@@ -13113,12 +13155,12 @@
 	QMap<double, uint> tmpGuidesSel;
 	Guides tmpGuides = page->guides.horizontals(GuideManagerCore::Standard);
 	Guides::iterator it;
+	double viewScale=m_View->scale();
 	uint yg = 0;
 	uint xg = 0;
-	double viewScale=m_View->scale();
 	for (it = tmpGuides.begin(); it != tmpGuides.end(); ++it, ++yg)
 	{
-		if (fabs((*it) + page->yOffset() - yin) < (docPrefsData.guidesPrefs.guideRad / viewScale))
+		if (fabs((*it) + page->yOffset() - yin) < (prefsData().guidesPrefs.guideRad / viewScale))
 			tmpGuidesSel.insert(fabs((*it) + page->yOffset() - yin), yg);
 	}
 	if (tmpGuidesSel.count() != 0)
@@ -13130,7 +13172,7 @@
 	tmpGuides = page->guides.verticals(GuideManagerCore::Standard);
 	for (it = tmpGuides.begin(); it != tmpGuides.end(); ++it, ++xg)
 	{
-		if (fabs((*it) + page->xOffset() - xin) < (docPrefsData.guidesPrefs.guideRad / viewScale))
+		if (fabs((*it) + page->xOffset() - xin) < (prefsData().guidesPrefs.guideRad / viewScale))
 			tmpGuidesSel.insert(fabs((*it) + page->xOffset() - xin), xg);
 	}
 	if (tmpGuidesSel.count() != 0)
@@ -13144,7 +13186,7 @@
 	tmpGuides = page->guides.horizontals(GuideManagerCore::Auto);
 	for (it = tmpGuides.begin(); it != tmpGuides.end(); ++it, ++yg)
 	{
-		if (fabs((*it) + page->yOffset() - yin) < (docPrefsData.guidesPrefs.guideRad / viewScale))
+		if (fabs((*it) + page->yOffset() - yin) < (prefsData().guidesPrefs.guideRad / viewScale))
 			tmpGuidesSel.insert(fabs((*it) + page->yOffset() - yin), yg);
 	}
 	if (tmpGuidesSel.count() != 0)
@@ -13156,7 +13198,7 @@
 	tmpGuides = page->guides.verticals(GuideManagerCore::Auto);
 	for (it = tmpGuides.begin(); it != tmpGuides.end(); ++it, ++xg)
 	{
-		if (fabs((*it) + page->xOffset() - xin) < (docPrefsData.guidesPrefs.guideRad / viewScale))
+		if (fabs((*it) + page->xOffset() - xin) < (prefsData().guidesPrefs.guideRad / viewScale))
 			tmpGuidesSel.insert(fabs((*it) + page->xOffset() - xin), xg);
 	}
 	if (tmpGuidesSel.count() != 0)
@@ -13166,7 +13208,60 @@
 	}
 }
 
+void ScribusDoc::getClosestElementBorder(double xin, double yin, double *xout, double *yout, int *GxM, int *GyM, ScPage* refPage)
+{
+	*GxM = -1;
+	*GyM = -1;
+	ScPage* page = (refPage == NULL) ? currentPage() : refPage;
+	QMap<double, uint> tmpGuidesSel;
+	double viewScale=m_View->scale();
+	QList<PageItem*> item = getAllItems(*Items);
+	for(int i=0;i<item.size();i++)
+	{
+		if(m_Selection->containsItem(item.at(i)) || item.at(i)->OwnPage != OnPage(xin,yin))
+			continue;
+		else if (fabs(item.at(i)->yPos() - yin) < (prefsData().guidesPrefs.guideRad / viewScale))
+			tmpGuidesSel.insert(fabs(item.at(i)->yPos() - yin), i*3);
+		else if (fabs(item.at(i)->yPos() + item.at(i)->height() - yin) < (prefsData().guidesPrefs.guideRad / viewScale))
+			tmpGuidesSel.insert(fabs(item.at(i)->yPos() + item.at(i)->height() - yin), i*3+1);
+		else if (fabs(item.at(i)->yPos() + item.at(i)->height()/2 - yin) < (prefsData().guidesPrefs.guideRad / viewScale))
+			tmpGuidesSel.insert(fabs(item.at(i)->yPos() + item.at(i)->height()/2 - yin), i*3+2);
+	}
+	if (tmpGuidesSel.count() != 0)
+	{
+		*GyM = tmpGuidesSel.begin().value();
+		if(*GyM%3==0)
+			*yout = item.at(*GyM/3)->yPos() - page->yOffset();
+		else if(*GyM%3==1)
+			*yout = item.at(*GyM/3)->yPos() + item.at(*GyM/3)->height() -page->yOffset();
+		else if(*GyM%3==2)
+			*yout = item.at(*GyM/3)->yPos() + item.at(*GyM/3)->height()/2 -page->yOffset();
+	}
+	tmpGuidesSel.clear();
+	for(int i=0;i<item.size();i++)
+	{
+		if(m_Selection->containsItem(item.at(i)) || item.at(i)->OwnPage != OnPage(xin,yin))
+			continue;
+		else if (fabs(item.at(i)->xPos() - xin) < (prefsData().guidesPrefs.guideRad / viewScale))
+			tmpGuidesSel.insert(fabs(item.at(i)->xPos() - xin), i*3);
+		else if (fabs(item.at(i)->xPos() + item.at(i)->width() - xin) < (prefsData().guidesPrefs.guideRad / viewScale))
+			tmpGuidesSel.insert(fabs(item.at(i)->xPos() + item.at(i)->width() - xin), i*3+1);
+		else if (fabs(item.at(i)->xPos() + item.at(i)->width()/2 - xin) < (prefsData().guidesPrefs.guideRad / viewScale))
+			tmpGuidesSel.insert(fabs(item.at(i)->xPos() + item.at(i)->width()/2 - xin), i*3+2);
+	}
+	if (tmpGuidesSel.count() != 0)
+	{
+		*GxM = tmpGuidesSel.begin().value();
+		if(*GxM%3==0)
+			*xout = item.at(*GxM/3)->xPos() -page->xOffset();
+		else if(*GxM%3==1)
+			*xout = item.at(*GxM/3)->xPos() + item.at(*GxM/3)->width() -page->xOffset();
+		else if(*GxM%3==2)
+			*xout = item.at(*GxM/3)->xPos() + item.at(*GxM/3)->width()/2 -page->xOffset();
+	}
+}
 
+
 void ScribusDoc::SnapToGuides(PageItem *currItem)
 {
 	int pg = OnPage(currItem);
@@ -13175,8 +13270,7 @@
 		return;
 	ScPage* page = Pages->at(pg);
 	int GxM, GyM;
-	
-	//FIXME: stop using m_View
+
 	getClosestGuides(0, currItem->yPos(), &xout, &yout, &GxM, &GyM);
 	if (GyM != -1)
 		currItem->setYPos(yout+page->yOffset());
@@ -13220,7 +13314,7 @@
 }
 
 
-bool ScribusDoc::ApplyGuides(double *x, double *y)
+bool ScribusDoc::ApplyGuides(double *x, double *y, bool elementSnap)
 {
 //	m_SnapCounter++;
 	bool ret = false;
@@ -13232,10 +13326,13 @@
 	int GxM, GyM;
 
 	//	if ((SnapGuides) && (m_SnapCounter > 1))
-	if (SnapGuides)
+	if ((SnapGuides && !elementSnap) || (SnapElement && elementSnap))
 	{
 //		m_SnapCounter = 0;
-		getClosestGuides(*x, *y, &xout, &yout, &GxM, &GyM, page);
+		if(!elementSnap)
+			getClosestGuides(*x, *y, &xout, &yout, &GxM, &GyM, page);
+		else
+			getClosestElementBorder(*x, *y, &xout, &yout, &GxM, &GyM, page);
 		if (GxM != -1)
 		{
 			*x = xout+page->xOffset();
@@ -13273,11 +13370,11 @@
 	return ret;
 }
 
-bool ScribusDoc::ApplyGuides(FPoint* point)
+bool ScribusDoc::ApplyGuides(FPoint* point,bool elementSnap)
 {
 	double newX = point->x();
 	double newY = point->y();
-	bool ret = ApplyGuides(&newX, &newY);
+	bool ret = ApplyGuides(&newX, &newY, elementSnap);
 	point->setX(newX);
 	point->setY(newY);
 
@@ -13401,7 +13498,6 @@
 	PageItem *currItem = pi;
 	if (currItem->locked())
 		return false;
-	QPainter p;
 	QRectF oldR(currItem->getBoundingRect());
 	//Uncomment for stopping resize in any direction
 	//and remove the height/width <0 tests in item sizing switch
@@ -13412,11 +13508,11 @@
 		newY = qMax(newY, 1);
 	}
 	*/
-	std::auto_ptr<UndoTransaction> activeTransaction;
+	UndoTransaction *activeTransaction = NULL;
 	if (UndoManager::undoEnabled())
 	{
 		QString transacDesc = QString(Um::ResizeFromTo).arg(currItem->oldWidth).arg(currItem->oldHeight).arg(newX).arg(newY);
-		activeTransaction.reset( new UndoTransaction(undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(), Um::Resize, transacDesc, Um::IResize)) );
+		activeTransaction = new UndoTransaction(undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(), Um::Resize, transacDesc, Um::IResize));
 	}
 	int ph = static_cast<int>(qMax(1.0, currItem->lineWidth() / 2.0));
 	QTransform ma;
@@ -13465,23 +13561,17 @@
 	{
 		currItem->FrameOnly = true;
 
-		if (currItem->FrameType == 0 || currItem->asLine())
+		if (currItem->FrameType != 0 && !currItem->asLine())
 		{
-			if (activeTransaction.get())
-			{
-				currItem->checkChanges();
-				activeTransaction->commit();
-			}
-			return true;
+			currItem->updateClip();
+//			currItem->updateGradientVectors();
 		}
-		
-		currItem->updateClip();
-//		currItem->updateGradientVectors();
-
-		if (activeTransaction.get())
+		if (activeTransaction)
 		{
 			currItem->checkChanges();
 			activeTransaction->commit();
+			delete activeTransaction;
+			activeTransaction = NULL;
 		}
 		return true;
 	}
@@ -13530,10 +13620,12 @@
 		}
 	}
 	currItem->setCornerRadius(qMin(currItem->cornerRadius(), qMin(currItem->width(),currItem->height())/2));
-	if (activeTransaction.get())
+	if (activeTransaction)
 	{
 		currItem->checkChanges();
 		activeTransaction->commit();
+		delete activeTransaction;
+		activeTransaction = NULL;
 	}
 	return true;
 }
@@ -14146,7 +14238,9 @@
 		return NULL;
 	PageItem *currItem;
 	double x, y, w, h;
-	UndoTransaction activeTransaction(undoManager->beginTransaction(Um::Selection,Um::IGroup,Um::Group,"",Um::IGroup));
+	UndoTransaction *activeTransaction = NULL;
+	if(UndoManager::undoEnabled())
+		activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IGroup,Um::Group,"",Um::IGroup));
 	uint selectedItemCount = itemSelection->count();
 	QString tooltip = Um::ItemsInvolved + "\n";
 	if (selectedItemCount > Um::ItemsInvolvedLimit)
@@ -14211,13 +14305,20 @@
 	}
 	groupItem->asGroupFrame()->adjustXYPosition();
 
-	ScItemState<QList<QPointer<PageItem> > > *is = new ScItemState<QList<QPointer<PageItem> > >(UndoManager::Group);
-	is->set("GROUP", "group");
-	itemSelection->addItem(groupItem,true);
-	is->setItem(itemSelection->selectionList());
-	undoManager->action(this, is);
-	activeTransaction.commit();
-
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QList<QPointer<PageItem> > > *is = new ScItemState<QList<QPointer<PageItem> > >(UndoManager::Group);
+		is->set("GROUP", "group");
+		itemSelection->addItem(groupItem,true);
+		is->setItem(itemSelection->selectionList());
+		undoManager->action(this, is);
+	}
+	if(activeTransaction)
+	{
+		activeTransaction->commit();
+		delete activeTransaction;
+		activeTransaction = NULL;
+	}
 	itemSelection->clear();
 	itemSelection->addItem(groupItem);
 
@@ -14240,7 +14341,9 @@
 	{
 		uint docSelectionCount = itemSelection->count();
 		PageItem *currItem;
-		UndoTransaction activeTransaction(undoManager->beginTransaction(Um::Selection,Um::IGroup,Um::Ungroup,"",Um::IGroup));
+		UndoTransaction *activeTransaction= NULL;
+		if(UndoManager::undoEnabled())
+			activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IGroup,Um::Ungroup,"",Um::IGroup));
 		QList<PageItem*> toDelete;
 		for (uint a=0; a < docSelectionCount; ++a)
 		{
@@ -14313,11 +14416,14 @@
 				rItem->OwnPage = OnPage(rItem);
 			}
 
-			ScItemState<QList<QPointer<PageItem> > > *is = new ScItemState<QList<QPointer<PageItem> > >(UndoManager::Ungroup);
-			is->set("UNGROUP", "ungroup");
-			tempSelection.addItem(currItem,true);
-			is->setItem(tempSelection.selectionList());
-			undoManager->action(this, is);
+			if(UndoManager::undoEnabled())
+			{
+				ScItemState<QList<QPointer<PageItem> > > *is = new ScItemState<QList<QPointer<PageItem> > >(UndoManager::Ungroup);
+				is->set("UNGROUP", "ungroup");
+				tempSelection.addItem(currItem,true);
+				is->setItem(tempSelection.selectionList());
+				undoManager->action(this, is);
+			}
 
 			tempSelection.clear();
 			tempSelection.delaySignalsOff();
@@ -14351,7 +14457,12 @@
 			currItem = toDelete.at(0);
 			delete currItem;
 		}
-		activeTransaction.commit();
+		if(activeTransaction)
+		{
+			activeTransaction->commit();
+			delete activeTransaction;
+			activeTransaction = NULL;
+		}
 
 /*		QMap<int, QList<PageItem*> >::iterator groupIt;
 		for (it = toDelete.begin(); it != toDelete.end(); ++it)
@@ -14540,7 +14651,7 @@
 		if (UndoManager::undoEnabled())
 		{
 			ScItemState< QPair<QList<PageItem*> , QList<QTransform> > > *is = new ScItemState< QPair<QList<PageItem*> , QList<QTransform> > >(Um::UniteItem, "", Um::IGroup);
-			is->setItem(QPair<QList<PageItem*>,QList<QTransform> >(toDel,transform));
+			is->setItem(qMakePair(toDel,transform));
 			is->set("UNITEITEM", "uniteitem");
 			is->set("FRAME",currFrame);
 			is->set("FRAMETYPE",currFrameType);
@@ -14622,8 +14733,7 @@
 	}
 	undoManager->setUndoEnabled(true);
 	m_Selection->delaySignalsOff();
-	//FIXME: stop using m_View
-	m_View->Deselect(true);
+	view()->Deselect(true);
 	regionsChanged()->update(QRectF());
 	if(transaction)
 	{
@@ -14670,7 +14780,11 @@
 		}
 	}
 	if (convertTransaction)
+	{
 		convertTransaction->commit();
+		delete convertTransaction;
+		convertTransaction = NULL;
+	}
 	tmpSel.delaySignalsOff();
 	m_updateManager.setUpdatesEnabled();
 	changed();
@@ -14690,6 +14804,10 @@
 	if (selectedItemCount > 0)
 	{
 		UndoTransaction* activeTransaction = NULL;
+		if (UndoManager::undoEnabled())
+			activeTransaction = new UndoTransaction(undoManager->beginTransaction( Um::SelectionGroup,
+																					Um::IGroup,
+																					Um::AdjustFrameToImage,"",Um::IResize));
 		for (uint i = 0; i < selectedItemCount; ++i)
 		{
 			PageItem *currItem = itemSelection->itemAt(i);
@@ -14697,12 +14815,6 @@
 			{
 				if (currItem->asImageFrame() && currItem->PictureIsAvailable)
 				{
-					if (!activeTransaction)
-						activeTransaction = new UndoTransaction(undoManager->beginTransaction(selectedItemCount == 1 ?
-																							  currItem->getUName() : Um::SelectionGroup,
-																							  selectedItemCount == 1 ?
-																							  currItem->getUPixmap() : Um::IGroup,
-																							  Um::AdjustFrameToImage,"",Um::IResize));
 					double w, h, x, y;
 					w = currItem->OrigW * currItem->imageXScale();
 					h = currItem->OrigH * currItem->imageYScale();
@@ -14724,10 +14836,10 @@
 			activeTransaction->commit();
 			delete activeTransaction;
 			activeTransaction = NULL;
-			regionsChanged()->update(QRectF());
-			changed();
-			itemSelection->itemAt(0)->emitAllToGUI();
 		}
+		regionsChanged()->update(QRectF());
+		changed();
+		itemSelection->itemAt(0)->emitAllToGUI();
 	}
 }
 void ScribusDoc::itemSelection_AdjustImagetoFrameSize( Selection *customSelection)
@@ -14765,7 +14877,9 @@
 	
 	if (selectedItemCount > 0)
 	{
-		UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::ITextFrame,Um::Resize,"",Um::IResize));
+		UndoTransaction *trans = NULL;
+		if(UndoManager::undoEnabled())
+			trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::ITextFrame,Um::Resize,"",Um::IResize));
 		for (uint i = 0; i < selectedItemCount; ++i)
 		{
 			PageItem *currItem = itemSelection->itemAt(i);
@@ -14775,7 +14889,12 @@
 					currItem ->asTextFrame()->setTextFrameHeight();
 			}
 		}
-		trans.commit();
+		if(trans)
+		{
+			trans->commit();
+			delete trans;
+			trans = NULL;
+		}
 		regionsChanged()->update(QRectF());
 		changed();
 		itemSelection->itemAt(0)->emitAllToGUI();
@@ -14886,7 +15005,8 @@
 	oldClip = new FPointArray(Clip);
 	oldItemX = currItem->xPos();
 	oldItemY = currItem->yPos();
-	nodeTransaction = new UndoTransaction(undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(), uAction));
+	if(UndoManager::undoEnabled())
+		nodeTransaction = new UndoTransaction(undoManager->beginTransaction(currItem->getUName(), currItem->getUPixmap(), uAction));
 	Doc->nodeEdit.deselect();
 	return Clip;
 }
@@ -14908,7 +15028,7 @@
 				new ScItemState<QPair<FPointArray, FPointArray> >(name);
 			state->set("EDIT_SHAPE_OR_CONTOUR", "edit_shape_or_contour");
 			state->set("IS_CONTOUR", Doc->nodeEdit.isContourLine);
-			state->setItem(QPair<FPointArray, FPointArray>(*oldClip, newClip));
+			state->setItem(qMakePair(*oldClip, newClip));
 			state->set("OLD_X", oldItemX);
 			state->set("OLD_Y", oldItemY);
 			state->set("NEW_X", currItem->xPos());
@@ -14945,7 +15065,7 @@
 			state = new ScItemState<QPair<FPointArray, FPointArray> >(name);
 			state->set("EDIT_SHAPE_OR_CONTOUR", "edit_shape_or_contour");
 			state->set("IS_CONTOUR", Doc->nodeEdit.isContourLine);
-			state->setItem(QPair<FPointArray, FPointArray>(*oldClip, newClip));
+			state->setItem(qMakePair(*oldClip, newClip));
 			undoManager->setUndoEnabled(false);
 		}
 		else
@@ -15190,14 +15310,14 @@
 	}
 	undoManager->setUndoEnabled(true);
 	FPointArray newClip(Doc->nodeEdit.isContourLine ? currItem->ContourLine : currItem->PoLine);
-	if (*oldClip != newClip)
+	if (*oldClip != newClip && UndoManager::undoEnabled())
 	{
 		ScItemState<QPair<FPointArray, FPointArray> > *state =
 		new ScItemState<QPair<FPointArray, FPointArray> >(Um::ResetControlPoint, "",
 														currItem->getUPixmap());
 		state->set("EDIT_SHAPE_OR_CONTOUR", "edit_shape_or_contour");
 		state->set("IS_CONTOUR", Doc->nodeEdit.isContourLine);
-		state->setItem(QPair<FPointArray, FPointArray>(*oldClip, newClip));
+		state->setItem(qMakePair(*oldClip, newClip));
 		state->set("OLD_X", oldItemX);
 		state->set("OLD_Y", oldItemY);
 		state->set("NEW_X", currItem->xPos());
@@ -15288,14 +15408,14 @@
 	
 	undoManager->setUndoEnabled(true);
 	FPointArray newClip(Doc->nodeEdit.isContourLine ? currItem->ContourLine : currItem->PoLine);
-	if (*oldClip != newClip)
+	if (*oldClip != newClip && UndoManager::undoEnabled())
 	{
 		ScItemState<QPair<FPointArray, FPointArray> > *state =
 		new ScItemState<QPair<FPointArray, FPointArray> >(Um::ResetControlPoints, "",
 														currItem->getUPixmap());
 		state->set("EDIT_SHAPE_OR_CONTOUR", "edit_shape_or_contour");
 		state->set("IS_CONTOUR", Doc->nodeEdit.isContourLine);
-		state->setItem(QPair<FPointArray, FPointArray>(*oldClip, newClip));
+		state->setItem(qMakePair(*oldClip, newClip));
 		state->set("OLD_X", oldItemX);
 		state->set("OLD_Y", oldItemY);
 		state->set("NEW_X", currItem->xPos());
Index: scribus/guidesmodel.h
===================================================================
--- scribus/guidesmodel.h	(révision 17743)
+++ scribus/guidesmodel.h	(copie de travail)
@@ -49,7 +49,7 @@
 		//! \brief Get values back to the app.
 		Guides values();
 
-		void unitChange(int docUnitIndex, int docUnitDecimals);
+		void unitChange(int docUnitIndex, int docUnitDecimals, double offset);
 #if 0
 		//! debug only
 		void printValues();
@@ -64,6 +64,7 @@
 		Guides m_values;
 		int m_docUnitIndex;
 		int m_docUnitDecimals;
+		double rule;
 };
 
 #endif
Index: scribus/canvasgesture_table.cpp
===================================================================
--- scribus/canvasgesture_table.cpp	(révision 17743)
+++ scribus/canvasgesture_table.cpp	(copie de travail)
@@ -32,6 +32,7 @@
 		// Snap to grid and guides.
 		canvasPoint = m_doc->ApplyGridF(canvasPoint);
 		m_doc->ApplyGuides(&canvasPoint);
+		m_doc->ApplyGuides(&canvasPoint,true);
 	}
 
 	// Return point mapped to table grid.
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(révision 17743)
+++ scribus/scribus.cpp	(copie de travail)
@@ -952,6 +952,7 @@
 	scrMenuMgr->addMenuSeparator("Page");
 	scrMenuMgr->addMenuItem(scrActions["viewSnapToGrid"], "Page", true);
 	scrMenuMgr->addMenuItem(scrActions["viewSnapToGuides"], "Page", true);
+	scrMenuMgr->addMenuItem(scrActions["viewSnapToElements"], "Page", true);
 
 	//View menu
 	scrMenuMgr->createMenu("View", ActionManager::defaultMenuNameEntryTranslated("View"));
@@ -1346,8 +1347,6 @@
 	QList<QMdiSubWindow *> windows;
 	QMdiSubWindow* w = NULL;
 	int kk = k->key();
-	QString uc = k->text();
-// 	QString cr, Tcha, Twort;
 	if (HaveDoc)
 	{
 		if ((doc->appMode == modeMagnifier) && (kk == Qt::Key_Shift))
@@ -1598,16 +1597,16 @@
 				if (currItem->asImageFrame() && !currItem->locked())
 				{
 					currItem->handleModeEditKey(k, keyrep);
+					slotDocCh(false);
 				}
 //FIXME:av		view->oldCp = currItem->CPos;
-				if (currItem->itemType() == PageItem::TextFrame)
+				else if (currItem->itemType() == PageItem::TextFrame)
 				{
 					bool kr=keyrep;
 					view->canvasMode()->keyPressEvent(k); //Hack for 1.4.x for stopping the cursor blinking while moving about
 					currItem->handleModeEditKey(k, keyrep);
 					keyrep=kr;
 				}
-				slotDocCh(false);
 			}
 		}
 	}
@@ -2451,6 +2450,7 @@
 
 	scrActions["viewSnapToGrid"]->setChecked(doc->useRaster);
 	scrActions["viewSnapToGuides"]->setChecked(doc->SnapGuides);
+	scrActions["viewSnapToElements"]->setChecked(doc->SnapElement);
 	scrActions["viewShowRulers"]->setEnabled(true);
 
 	scrMenuMgr->setMenuEnabled("Insert", true);
@@ -3449,14 +3449,17 @@
 			uint ac = doc->Items->count();
 			bool savedAlignGrid = doc->useRaster;
 			bool savedAlignGuides = doc->SnapGuides;
+			bool savedAlignElement = doc->SnapElement;
 			doc->useRaster = false;
 			doc->SnapGuides = false;
+			doc->SnapElement = false;
 			if ((view->dragX == 0) && (view->dragY == 0))
 				slotElemRead(data, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), true, false, doc, view);
 			else
 				slotElemRead(data, view->dragX, view->dragY, true, false, doc, view);
 			doc->useRaster = savedAlignGrid;
 			doc->SnapGuides = savedAlignGuides;
+			doc->SnapElement = savedAlignElement;
 			Selection tmpSelection(this, false);
 			tmpSelection.copy(*doc->m_Selection, true);
 			for (int as = ac; as < doc->Items->count(); ++as)
@@ -4417,6 +4420,7 @@
 		slotFileClose();
 		qApp->processEvents();
 		loadDoc(fn);
+		undoManager->clearStack();
 	}
 }
 
@@ -4678,6 +4682,7 @@
 		scrActions["viewFit400"]->setEnabled(false);
 		//scrMenuMgr->setMenuEnabled("Windows", false);
 		scrActions["viewSnapToGuides"]->setChecked(false);
+		scrActions["viewSnapToElements"]->setChecked(false);
 		scrActions["viewSnapToGrid"]->setChecked(false);
 		scrActions["viewShowRulers"]->setEnabled(false);
 
@@ -5161,6 +5166,7 @@
 			{
 				bool savedAlignGrid = doc->useRaster;
 				bool savedAlignGuides = doc->SnapGuides;
+				bool savedAlignElement = doc->SnapElement;
 				int ac = doc->Items->count();
 				bool isGroup = false;
 				double gx, gy, gh, gw;
@@ -5168,6 +5174,7 @@
 				FPoint maxSize = doc->maxCanvasCoordinate;
 				doc->useRaster = false;
 				doc->SnapGuides = false;
+				doc->SnapElement = false;
 				// HACK #6541 : undo does not handle text modification => do not record embedded item creation
 				// if embedded item is deleted, undo system will not be aware of its deletion => crash - JG
 				undoManager->setUndoEnabled(false);
@@ -5182,6 +5189,7 @@
 
 				doc->useRaster = savedAlignGrid;
 				doc->SnapGuides = savedAlignGuides;
+				doc->SnapElement = savedAlignElement;
 				//int tempList=doc->m_Selection->backupToTempList(0);
 				Selection tempSelection(*doc->m_Selection);
 				doc->m_Selection->clear();
@@ -5255,8 +5263,10 @@
 				uint ac = doc->Items->count();
 				bool savedAlignGrid = doc->useRaster;
 				bool savedAlignGuides = doc->SnapGuides;
+				bool savedAlignElement = doc->SnapElement;
 				doc->useRaster = false;
 				doc->SnapGuides = false;
+				doc->SnapElement = false;
 				if (internalCopy)
 					slotElemRead(internalCopyBuffer, doc->currentPage()->xOffset(), doc->currentPage()->yOffset(), false, true, doc, view);
 				else
@@ -5275,6 +5285,7 @@
 
 				doc->useRaster = savedAlignGrid;
 				doc->SnapGuides = savedAlignGuides;
+				doc->SnapElement = savedAlignElement;
 				doc->m_Selection->delaySignalsOn();
 				for (int as = ac; as < doc->Items->count(); ++as)
 				{
@@ -6191,7 +6202,16 @@
 	}
 }
 
+void ScribusMainWindow::ToggleUElements()
+{
+	if (doc)
+	{
+		doc->SnapElement = !doc->SnapElement;
+		slotDocCh();
+	}
+}
 
+
 void ScribusMainWindow::toggleNodeEdit()
 {
 	if (!doc)
@@ -7480,9 +7500,11 @@
 	slotSelect();
 	bool savedAlignGrid = doc->useRaster;
 	bool savedAlignGuides = doc->SnapGuides;
+	bool savedAlignElement = doc->SnapElement;
 	internalCopy = true;
 	doc->useRaster = false;
 	doc->SnapGuides = false;
+	doc->SnapElement = false;
 	slotEditCopy();
 	view->Deselect(true);
 	UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::Duplicate,"",Um::IMultipleDuplicate));
@@ -7495,6 +7517,7 @@
 	trans.commit();
 	doc->useRaster = savedAlignGrid;
 	doc->SnapGuides = savedAlignGuides;
+	doc->SnapElement = savedAlignElement;
 	internalCopy = false;
 	internalCopyBuffer = "";
 	view->DrawNew();
@@ -8851,7 +8874,7 @@
 				QMessageBox msgBox;
 				QPushButton *abortButton = msgBox.addButton(QMessageBox::Cancel);
 				QPushButton *lockButton = msgBox.addButton(tr("&Lock All"), QMessageBox::AcceptRole);
-				QPushButton *unlockButton = msgBox.addButton(tr("&Unlock All"), QMessageBox::AcceptRole);
+				msgBox.addButton(tr("&Unlock All"), QMessageBox::AcceptRole);
 				msgBox.setIcon(QMessageBox::Warning);
 				msgBox.setWindowTitle(CommonStrings::trWarning);
 				msgBox.setText( tr("Some objects are locked."));
@@ -8861,7 +8884,6 @@
 				else if (msgBox.clickedButton() == lockButton)
 					lockObject = true;
 				modifyLock = true;
-				unlockButton = NULL;	// just to silence the compiler
 			}
 		}
 		doc->itemSelection_GroupObjects(modifyLock, lockObject);
Index: scribus/ui/rulermover.cpp
===================================================================
--- scribus/ui/rulermover.cpp	(révision 17743)
+++ scribus/ui/rulermover.cpp	(copie de travail)
@@ -31,6 +31,7 @@
 
 #include "canvas.h"
 #include "canvasgesture_rulermove.h"
+#include "ui/guidemanager.h"
 #include "scribusview.h"
 #include "scribusdoc.h"
 #include "scraction.h"
@@ -104,6 +105,8 @@
 		if (pmen2)
 			delete pmen2;
 	}
+	if (currView->Doc->guidesPrefs().guidesShown)
+		currView->Doc->scMW()->guidePalette->setupPage();
 	QWidget::mouseReleaseEvent(m);
 }
 
Index: scribus/ui/guidemanager.cpp
===================================================================
--- scribus/ui/guidemanager.cpp	(révision 17743)
+++ scribus/ui/guidemanager.cpp	(copie de travail)
@@ -293,8 +293,8 @@
 	horizontalGroupBox->setTitle(horizontalGroupBox->title() + " ("+suffix.trimmed()+")");
 	verticalGroupBox->setTitle(verticalGroupBox->title() + " ("+suffix.trimmed()+")");
 	// models display
-	horizontalModel->unitChange(docUnitIndex, docUnitDecimals);
-	verticalModel->unitChange(docUnitIndex, docUnitDecimals);
+	horizontalModel->unitChange(docUnitIndex, docUnitDecimals, m_Doc->rulerYoffset);
+	verticalModel->unitChange(docUnitIndex, docUnitDecimals, m_Doc->rulerXoffset);
 	qobject_cast<GuidesHDelegate*>(horizontalView->itemDelegateForColumn(0))->setDoc(m_Doc);
 	qobject_cast<GuidesVDelegate*>(verticalView->itemDelegateForColumn(0))->setDoc(m_Doc);
 }
Index: scribus/ui/cpalette.cpp
===================================================================
--- scribus/ui/cpalette.cpp	(révision 17743)
+++ scribus/ui/cpalette.cpp	(copie de travail)
@@ -320,11 +320,12 @@
 	else
 		setMeshPoint();
 	if(CGradDia && gradEditButton->isChecked())
+	{
 		if(tabFillStroke->currentIndex() == 0)
 			CGradDia->setValues(currentItem->gradientStartX(), currentItem->gradientStartY(), currentItem->gradientEndX(), currentItem->gradientEndY(), currentItem->GrFocalX, currentItem->GrFocalY, currentItem->GrScale, currentItem->GrSkew, 0, 0);
 		else
 			CGradDia->setValues(currentItem->GrStrokeStartX, currentItem->GrStrokeStartY, currentItem->GrStrokeEndX, currentItem->GrStrokeEndY, currentItem->GrStrokeFocalX, currentItem->GrStrokeFocalY, currentItem->GrStrokeScale, currentItem->GrStrokeSkew, 0, 0);
-
+	}
 	editMeshColors->setEnabled(!CGradDia->isVisible());
 	gradEditButton->setEnabled(true);
 
@@ -667,11 +668,18 @@
 	double t2 = color2Alpha->value() / 100.0;
 	double t3 = color3Alpha->value() / 100.0;
 	double t4 = color4Alpha->value() / 100.0;
-	UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
+	UndoTransaction *trans = NULL;
+	if(UndoManager::undoEnabled())
+		trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IFill,Um::GradVal,"",Um::IFill));
 	currentItem->set4ColorShade(static_cast<int>(color1Shade->value()), static_cast<int>(color2Shade->value()), static_cast<int>(color3Shade->value()), static_cast<int>(color4Shade->value()));
 	currentItem->set4ColorTransparency(t1, t2, t3, t4);
 	currentItem->set4ColorColors(color1, color2, color3, color4);
-	trans.commit();
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 	currentItem->update();
 }
 
@@ -1227,11 +1235,15 @@
 	{
 		if ((grow == -1) || (gcol == 0))
 			return;
-		ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
-		ss->set("MOVE_MESH_PATCH","move_mesh_patch");
-		ss->set("ARRAY",false);
-		ss->set("X",grow);
-		ss->set("Y",gcol);
+		ScItemState<QPair<meshPoint,meshPoint> > *ss = NULL;
+		if(UndoManager::undoEnabled())
+		{
+			ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
+			ss->set("MOVE_MESH_PATCH","move_mesh_patch");
+			ss->set("ARRAY",false);
+			ss->set("X",grow);
+			ss->set("Y",gcol);
+		}
 		switch (gcol)
 		{
 			case 1:
@@ -1240,7 +1252,8 @@
 					tmp.controlBottom = tmp.gridPoint;
 				if (cont == 4)
 					tmp.controlRight  = tmp.gridPoint;
-				ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].TL,tmp));
+				if(UndoManager::undoEnabled())
+					ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].TL,tmp));
 				currentItem->meshGradientPatches[grow].TL = tmp;
 				break;
 			case 2:
@@ -1249,7 +1262,8 @@
 					tmp.controlBottom = tmp.gridPoint;
 				if (cont == 3)
 					tmp.controlLeft   = tmp.gridPoint;
-				ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].TR,tmp));
+				if(UndoManager::undoEnabled())
+					ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].TR,tmp));
 				currentItem->meshGradientPatches[grow].TR = tmp;
 				break;
 			case 3:
@@ -1258,7 +1272,8 @@
 					tmp.controlTop  = tmp.gridPoint;
 				if (cont == 3)
 					tmp.controlLeft = tmp.gridPoint;
-				ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].BR,tmp));
+				if(UndoManager::undoEnabled())
+					ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].BR,tmp));
 				currentItem->meshGradientPatches[grow].BR = tmp;
 				break;
 			case 4:
@@ -1267,21 +1282,19 @@
 					tmp.controlTop   = tmp.gridPoint;
 				if (cont == 4)
 					tmp.controlRight = tmp.gridPoint;
-				ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].BL,tmp));
+				if(UndoManager::undoEnabled())
+					ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].BL,tmp));
 				currentItem->meshGradientPatches[grow].BL = tmp;
 				break;
 		}
-		undoManager->action(currentItem,ss);
+		if(UndoManager::undoEnabled())
+			undoManager->action(currentItem,ss);
 	}
 	else
 	{
 		if ((grow == -1) || (gcol == -1))
 			return;
-		ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
-		ss->set("MOVE_MESH_PATCH","move_mesh_patch");
-		ss->set("ARRAY",true);
-		ss->set("X",grow);
-		ss->set("Y",gcol);
+
 		tmp = currentItem->meshGradientArray[grow][gcol];
 		if (cont == 1)
 			tmp.controlTop    = tmp.gridPoint;
@@ -1291,9 +1304,18 @@
 			tmp.controlLeft   = tmp.gridPoint;
 		else if (cont == 4)
 			tmp.controlRight  = tmp.gridPoint;
-		ss->setItem(qMakePair(currentItem->meshGradientArray[grow][gcol],tmp));
+
+		if(UndoManager::undoEnabled())
+		{
+			ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
+			ss->set("MOVE_MESH_PATCH","move_mesh_patch");
+			ss->set("ARRAY",true);
+			ss->set("X",grow);
+			ss->set("Y",gcol);
+			ss->setItem(qMakePair(currentItem->meshGradientArray[grow][gcol],tmp));
+			undoManager->action(currentItem,ss);
+		}
 		currentItem->meshGradientArray[grow][gcol] = tmp;
-		undoManager->action(currentItem,ss);
 	}
 	currentItem->update();
 	currentDoc->regionsChanged()->update(QRect());
@@ -1308,11 +1330,15 @@
 	{
 		if ((grow == -1) || (gcol == 0))
 			return;
-		ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
-		ss->set("MOVE_MESH_PATCH","move_mesh_patch");
-		ss->set("ARRAY",false);
-		ss->set("X",grow);
-		ss->set("Y",gcol);
+		ScItemState<QPair<meshPoint,meshPoint> > *ss = NULL;
+		if(UndoManager::undoEnabled())
+		{
+			ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
+			ss->set("MOVE_MESH_PATCH","move_mesh_patch");
+			ss->set("ARRAY",false);
+			ss->set("X",grow);
+			ss->set("Y",gcol);
+		}
 		switch (gcol)
 		{
 			case 1:
@@ -1321,7 +1347,8 @@
 				tmp.controlLeft   = tmp.gridPoint;
 				tmp.controlRight  = tmp.gridPoint;
 				tmp.controlBottom = tmp.gridPoint;
-				ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].TL,tmp));
+				if(UndoManager::undoEnabled())
+					ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].TL,tmp));
 				currentItem->meshGradientPatches[grow].TL = tmp;
 		break;
 			case 2:
@@ -1330,7 +1357,8 @@
 				tmp.controlLeft   = tmp.gridPoint;
 				tmp.controlRight  = tmp.gridPoint;
 				tmp.controlBottom = tmp.gridPoint;
-				ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].TR,tmp));
+				if(UndoManager::undoEnabled())
+					ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].TR,tmp));
 				currentItem->meshGradientPatches[grow].TR = tmp;
 		break;
 			case 3:
@@ -1339,7 +1367,8 @@
 				tmp.controlLeft   = tmp.gridPoint;
 				tmp.controlRight  = tmp.gridPoint;
 				tmp.controlBottom = tmp.gridPoint;
-				ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].BR,tmp));
+				if(UndoManager::undoEnabled())
+					ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].BR,tmp));
 				currentItem->meshGradientPatches[grow].BR = tmp;
 		break;
 			case 4:
@@ -1348,29 +1377,34 @@
 				tmp.controlLeft   = tmp.gridPoint;
 				tmp.controlRight  = tmp.gridPoint;
 				tmp.controlBottom = tmp.gridPoint;
-				ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].BL,tmp));
+				if(UndoManager::undoEnabled())
+					ss->setItem(qMakePair(currentItem->meshGradientPatches[grow].BL,tmp));
 				currentItem->meshGradientPatches[grow].BL = tmp;
 		break;
 		}
-		undoManager->action(currentItem,ss);
+		if(UndoManager::undoEnabled())
+			undoManager->action(currentItem,ss);
 	}
 	else
 	{
 		if ((grow == -1) || (gcol == -1))
 			return;
-		ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
-		ss->set("MOVE_MESH_PATCH","move_mesh_patch");
-		ss->set("ARRAY",true);
-		ss->set("X",grow);
-		ss->set("Y",gcol);
 		tmp = currentItem->meshGradientArray[grow][gcol];
 		tmp.controlTop    = tmp.gridPoint;
 		tmp.controlLeft   = tmp.gridPoint;
 		tmp.controlRight  = tmp.gridPoint;
 		tmp.controlBottom = tmp.gridPoint;
-		ss->setItem(qMakePair(currentItem->meshGradientArray[grow][gcol],tmp));
+		if(UndoManager::undoEnabled())
+		{
+			ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
+			ss->set("MOVE_MESH_PATCH","move_mesh_patch");
+			ss->set("ARRAY",true);
+			ss->set("X",grow);
+			ss->set("Y",gcol);
+			ss->setItem(qMakePair(currentItem->meshGradientArray[grow][gcol],tmp));
+			undoManager->action(currentItem,ss);
+		}
 		currentItem->meshGradientArray[grow][gcol] = tmp;
-		undoManager->action(currentItem,ss);
 	}
 	currentItem->update();
 	currentDoc->regionsChanged()->update(QRect());
@@ -1501,11 +1535,14 @@
 {
 	if ((currentItem->selectedMeshPointX > -1) && (currentItem->meshGradientPatches.count() > 1))
 	{
-		ScItemState<meshGradientPatch> *ss = new ScItemState<meshGradientPatch>(Um::RemoveMeshPatch,"",Um::ILine);
-		ss->set("REMOVE_MESH_PATCH","remove_mesh_patch");
-		ss->setItem(currentItem->meshGradientPatches.takeAt(currentItem->selectedMeshPointX));
-		ss->set("POS",currentItem->selectedMeshPointX);
-		undoManager->action(currentItem,ss);
+		if(UndoManager::undoEnabled())
+		{
+			ScItemState<meshGradientPatch> *ss = new ScItemState<meshGradientPatch>(Um::RemoveMeshPatch,"",Um::ILine);
+			ss->set("REMOVE_MESH_PATCH","remove_mesh_patch");
+			ss->setItem(currentItem->meshGradientPatches.takeAt(currentItem->selectedMeshPointX));
+			ss->set("POS",currentItem->selectedMeshPointX);
+			undoManager->action(currentItem,ss);
+		}
 		currentItem->selectedMeshPointX = -1;
 		CGradDia->changebuttonRemovePatch((currentItem->selectedMeshPointX > -1) && (currentItem->meshGradientPatches.count() > 1));
 		currentItem->update();
Index: scribus/ui/contextmenu.cpp
===================================================================
--- scribus/ui/contextmenu.cpp	(révision 17743)
+++ scribus/ui/contextmenu.cpp	(copie de travail)
@@ -507,6 +507,7 @@
 	addSeparator();
 	addAction(m_AP->scrActions["viewSnapToGrid"]);
 	addAction(m_AP->scrActions["viewSnapToGuides"]);
+	addAction(m_AP->scrActions["viewSnapToElements"]);
 	
 	onAPage = (m_doc->OnPage(mx, my) != -1);
 	if (onAPage)
Index: scribus/ui/propertiespalette_imagebase.ui
===================================================================
--- scribus/ui/propertiespalette_imagebase.ui	(révision 17743)
+++ scribus/ui/propertiespalette_imagebase.ui	(copie de travail)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>280</width>
-    <height>502</height>
+    <width>286</width>
+    <height>617</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -143,6 +143,9 @@
         <property name="checkable">
          <bool>true</bool>
         </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
         <property name="autoRaise">
          <bool>true</bool>
         </property>
@@ -182,6 +185,9 @@
         <property name="checkable">
          <bool>true</bool>
         </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
         <property name="autoRaise">
          <bool>true</bool>
         </property>
@@ -338,8 +344,8 @@
  <customwidgets>
   <customwidget>
    <class>ScrSpinBox</class>
-   <extends>QDoubleSpinBox</extends>
-   <header>ui/scrspinbox.h</header>
+   <extends>QSpinBox</extends>
+   <header location="global">ui/scrspinbox.h</header>
   </customwidget>
   <customwidget>
    <class>LinkButton</class>
Index: scribus/ui/paintmanager.cpp
===================================================================
--- scribus/ui/paintmanager.cpp	(révision 17743)
+++ scribus/ui/paintmanager.cpp	(copie de travail)
@@ -1292,8 +1292,10 @@
 	uint ap = m_doc->docPatterns.count();
 	bool savedAlignGrid = m_doc->useRaster;
 	bool savedAlignGuides = m_doc->SnapGuides;
+	bool savedAlignElement = m_doc->SnapElement;
 	m_doc->useRaster = false;
 	m_doc->SnapGuides = false;
+	m_doc->SnapElement = false;
 	if (fi.suffix().toLower() == "sce")
 	{
 		ScriXmlDoc ss;
@@ -1316,6 +1318,7 @@
 	}
 	m_doc->useRaster = savedAlignGrid;
 	m_doc->SnapGuides = savedAlignGuides;
+	m_doc->SnapElement = savedAlignElement;
 	uint ae = m_doc->Items->count();
 	if (ac != ae)
 	{
Index: scribus/ui/prefs_guidesbase.ui
===================================================================
--- scribus/ui/prefs_guidesbase.ui	(révision 17743)
+++ scribus/ui/prefs_guidesbase.ui	(copie de travail)
@@ -79,13 +79,6 @@
          <item>
           <layout class="QVBoxLayout" name="verticalLayout_6">
            <item>
-            <widget class="QLabel" name="label_5">
-             <property name="text">
-              <string>Foreground</string>
-             </property>
-            </widget>
-           </item>
-           <item>
             <spacer name="verticalSpacer_5">
              <property name="orientation">
               <enum>Qt::Vertical</enum>
@@ -150,13 +143,6 @@
              </property>
             </spacer>
            </item>
-           <item>
-            <widget class="QLabel" name="label_6">
-             <property name="text">
-              <string>Background</string>
-             </property>
-            </widget>
-           </item>
           </layout>
          </item>
          <item>
snap.diff (158,105 bytes)   

Chelen

2012-08-01 16:21

reporter  

fix.diff (60,375 bytes)   
diff --git a/Scribus/scribus/canvasmode_create.cpp b/Scribus/scribus/canvasmode_create.cpp
index 3bc916f..8bbd4f7 100644
--- a/Scribus/scribus/canvasmode_create.cpp
+++ b/Scribus/scribus/canvasmode_create.cpp
@@ -300,6 +300,10 @@ void CreateMode::mouseMoveEvent(QMouseEvent *m)
 				double ny = np2.y();
 				m_doc->ApplyGuides(&nx, &ny);
 				m_doc->ApplyGuides(&nx, &ny,true);
+				if(nx!=np2.x())
+					xSnap = nx * m_canvas->scale();
+				if(ny!=np2.y())
+					ySnap = ny * m_canvas->scale();
 				// #8959 : suppress qRound here as this prevent drawing line with angle constrain
 				// precisely and does not allow to stick precisely to grid or guides
 				newX = /*qRound(*/nx/*)*/;
diff --git a/Scribus/scribus/canvasmode_drawcalligraphic.cpp b/Scribus/scribus/canvasmode_drawcalligraphic.cpp
index 22e35d5..8df73f2 100644
--- a/Scribus/scribus/canvasmode_drawcalligraphic.cpp
+++ b/Scribus/scribus/canvasmode_drawcalligraphic.cpp
@@ -242,7 +242,9 @@ void CalligraphicMode::mouseReleaseEvent(QMouseEvent *m)
 	{
 		if (RecordP.size() > 1)
 		{
-			UndoTransaction createTransaction(UndoManager::instance()->beginTransaction());
+			UndoTransaction *createTransaction = NULL;
+			if(UndoManager::undoEnabled())
+				createTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction());
 			uint z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, Mxp, Myp, 1, 1, m_doc->itemToolPrefs().calligrapicPenLineWidth, m_doc->itemToolPrefs().calligrapicPenFillColor, m_doc->itemToolPrefs().calligrapicPenLineColor, true);
 			currItem = m_doc->Items->at(z);
 			currItem->PoLine.resize(0);
@@ -283,7 +285,12 @@ void CalligraphicMode::mouseReleaseEvent(QMouseEvent *m)
 			QString targetName = Um::ScratchSpace;
 			if (currItem->OwnPage > -1)
 				targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
-			createTransaction.commit(targetName, currItem->getUPixmap(), Um::Create + " " + currItem->getUName(),  "", Um::ICreate);
+			if(createTransaction)
+			{
+				createTransaction->commit(targetName, currItem->getUPixmap(), Um::Create + " " + currItem->getUName(),  "", Um::ICreate);
+				delete createTransaction;
+				createTransaction = NULL;
+			}
 			//FIXME	
 			m_canvas->m_viewMode.operItemResizing = false;
 			m_doc->changed();
diff --git a/Scribus/scribus/canvasmode_editarc.cpp b/Scribus/scribus/canvasmode_editarc.cpp
index 3956a9c..7278c35 100644
--- a/Scribus/scribus/canvasmode_editarc.cpp
+++ b/Scribus/scribus/canvasmode_editarc.cpp
@@ -227,19 +227,8 @@ void CanvasMode_EditArc::applyValues(double start, double end, double height, do
 	QRectF upRect2 = QRectF(mPoint.x() - item->arcWidth / 2.0, mPoint.y() - item->arcHeight / 2.0, item->arcWidth, item->arcHeight);
 	upRect = upRect2.united(upRect);
 	upRect.translate(currItem->xPos(), currItem->yPos());
-	ScItemState<QPair<FPointArray, FPointArray> > *ss = new ScItemState<QPair<FPointArray, FPointArray> >(Um::EditArc,"",Um::IPolygon);
-	FPointArray old = item->PoLine;
-	ss->set("ARC","arc");
-	ss->set("OLD_WIDTH",item->arcWidth);
-	ss->set("NEW_WIDTH",width);
-	ss->set("OLD_XPOS",item->xPos());
-	ss->set("OLD_YPOS",item->yPos());
-	ss->set("OLD_HEIGHT",item->arcHeight);
-	ss->set("NEW_HEIGHT",height);
-	item->arcWidth = width;
-	item->arcHeight = height;
 	QTransform bb;
-	bb.scale(item->arcHeight / item->arcWidth, 1.0);
+	bb.scale(height / width, 1.0);
 	QLineF inp = QLineF(QPointF(width / 2.0, height / 2.0), QPointF(width, height / 2.0));
 	inp.setAngle(start);
 	QLineF res = bb.map(inp);
@@ -252,22 +241,34 @@ void CanvasMode_EditArc::applyValues(double start, double end, double height, do
 		nSweep += 360;
 	QPainterPath pp;
 	pp.moveTo(mPoint);
-	pp.arcTo(QRectF(mPoint.x() - item->arcWidth / 2.0, mPoint.y() - item->arcHeight / 2.0, item->arcWidth, item->arcHeight), startAngle, nSweep);
+	pp.arcTo(QRectF(mPoint.x() - width / 2.0, mPoint.y() - height / 2.0, width, height), startAngle, nSweep);
 	pp.closeSubpath();
 	currItem->PoLine.fromQPainterPath(pp);
-	undoManager->setUndoEnabled(false);
 	m_doc->AdjustItemSize(currItem);
-	undoManager->setUndoEnabled(true);
-	ss->set("OLD_START",item->arcStartAngle);
-	ss->set("NEW_START",startAngle);
-	ss->set("OLD_SWEEP",item->arcSweepAngle);
-	ss->set("NEW_SWEEP",nSweep);
-	ss->setItem(qMakePair(old,item->PoLine));
+	if(UndoManager::undoEnabled())
+	{
+		ScItemState<QPair<FPointArray, FPointArray> > *ss = new ScItemState<QPair<FPointArray, FPointArray> >(Um::EditArc,"",Um::IPolygon);
+		FPointArray old = item->PoLine;
+		ss->set("ARC","arc");
+		ss->set("OLD_WIDTH",item->arcWidth);
+		ss->set("NEW_WIDTH",width);
+		ss->set("OLD_XPOS",item->xPos());
+		ss->set("OLD_YPOS",item->yPos());
+		ss->set("OLD_HEIGHT",item->arcHeight);
+		ss->set("NEW_HEIGHT",height);
+		ss->set("OLD_START",item->arcStartAngle);
+		ss->set("NEW_START",startAngle);
+		ss->set("OLD_SWEEP",item->arcSweepAngle);
+		ss->set("NEW_SWEEP",nSweep);
+		ss->setItem(qMakePair(old,item->PoLine));
+		ss->set("NEW_XPOS",item->xPos());
+		ss->set("NEW_YPOS",item->yPos());
+		undoManager->action(currItem,ss);
+	}
 	item->arcStartAngle = startAngle;
 	item->arcSweepAngle = nSweep;
-	ss->set("NEW_XPOS",item->xPos());
-	ss->set("NEW_YPOS",item->yPos());
-	undoManager->action(currItem,ss);
+	item->arcWidth = width;
+	item->arcHeight = height;
 	startPoint = currItem->PoLine.pointQF(2);
 	endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 4);
 	centerPoint = currItem->PoLine.pointQF(0);
diff --git a/Scribus/scribus/canvasmode_editgradient.cpp b/Scribus/scribus/canvasmode_editgradient.cpp
index 9281c65..b47715a 100644
--- a/Scribus/scribus/canvasmode_editgradient.cpp
+++ b/Scribus/scribus/canvasmode_editgradient.cpp
@@ -932,7 +932,7 @@ void CanvasMode_EditGradient::mouseReleaseEvent(QMouseEvent *m)
 	m_canvas->resetRenderMode();
 	m->accept();
 	PageItem* currItem = m_doc->m_Selection->itemAt(0);
-	if(m_gradientPoint != noPointDefined){
+	if(m_gradientPoint != noPointDefined && UndoManager::undoEnabled()){
 		QList<FPoint> tmp;
 		ScItemState<QList<FPoint> > *is = new ScItemState<QList<FPoint> >(Um::GradPos + "i");
 		is->set("GRAD_POS","grad_pos");
diff --git a/Scribus/scribus/canvasmode_editmeshgradient.cpp b/Scribus/scribus/canvasmode_editmeshgradient.cpp
index 0ce79eb..ab97fde 100644
--- a/Scribus/scribus/canvasmode_editmeshgradient.cpp
+++ b/Scribus/scribus/canvasmode_editmeshgradient.cpp
@@ -972,7 +972,7 @@ void CanvasMode_EditMeshGradient::mouseReleaseEvent(QMouseEvent *m)
 	m_canvas->resetRenderMode();
 	m->accept();
 	PageItem *currItem = m_doc->m_Selection->itemAt(0);
-	if (currItem->selectedMeshPointX >=0 && currItem->selectedMeshPointY >=0)
+	if (currItem->selectedMeshPointX >=0 && currItem->selectedMeshPointY >=0 && UndoManager::undoEnabled())
 	{
 		ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
 		ss->set("MOVE_MESH_PATCH","move_mesh_patch");
diff --git a/Scribus/scribus/canvasmode_editmeshpatch.cpp b/Scribus/scribus/canvasmode_editmeshpatch.cpp
index ae49e94..4dc53f7 100644
--- a/Scribus/scribus/canvasmode_editmeshpatch.cpp
+++ b/Scribus/scribus/canvasmode_editmeshpatch.cpp
@@ -972,7 +972,7 @@ void CanvasMode_EditMeshPatch::mouseReleaseEvent(QMouseEvent *m)
 	m_canvas->m_viewMode.m_MouseButtonPressed = false;
 	m_canvas->resetRenderMode();
 	m->accept();
-	if (m_view->editStrokeGradient != 11 && currItem->selectedMeshPointX >=0 && m_patchPoint != noPointDefined)
+	if (m_view->editStrokeGradient != 11 && currItem->selectedMeshPointX >=0 && m_patchPoint != noPointDefined && UndoManager::undoEnabled())
 	{
 		ScItemState<QPair<meshPoint,meshPoint> > *ss = new ScItemState<QPair<meshPoint,meshPoint> >(Um::GradPos);
 		ss->set("MOVE_MESH_PATCH","move_mesh_patch");
diff --git a/Scribus/scribus/canvasmode_editpolygon.cpp b/Scribus/scribus/canvasmode_editpolygon.cpp
index dc3829e..7d17bc8 100644
--- a/Scribus/scribus/canvasmode_editpolygon.cpp
+++ b/Scribus/scribus/canvasmode_editpolygon.cpp
@@ -251,23 +251,26 @@ void CanvasMode_EditPolygon::applyValues(int polyC, double polyF, bool polyUseCF
 	polyCurvature = polyCur;
 	polyInnerRot = polyIRot;
 	polyOuterCurvature = polyOCur;
-	SimpleState *ss = new SimpleState(Um::EditPolygon,"",Um::IPolygon);
-	ss->set("POLYGON","polygon");
-	ss->set("NEW_CORNER",polyC);
-	ss->set("NEW_USEFACTOR",polyUseCF);
-	ss->set("NEW_FACTOR",polyFactor);
-	ss->set("NEW_ROTATION",polyRotation);
-	ss->set("NEW_CURV",polyCurvature);
-	ss->set("NEW_INNER",polyInnerRot);
-	ss->set("NEW_OUTER",polyOuterCurvature);
-	ss->set("OLD_CORNER",item->polyCorners);
-	ss->set("OLD_USEFACTOR",item->polyUseFactor);
-	ss->set("OLD_FACTOR",item->polyFactor);
-	ss->set("OLD_ROTATION",item->polyRotation);
-	ss->set("OLD_CURV",item->polyCurvature);
-	ss->set("OLD_INNER",item->polyInnerRot);
-	ss->set("OLD_OUTER",item->polyOuterCurvature);
-	undoManager->action(currItem,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::EditPolygon,"",Um::IPolygon);
+		ss->set("POLYGON","polygon");
+		ss->set("NEW_CORNER",polyC);
+		ss->set("NEW_USEFACTOR",polyUseCF);
+		ss->set("NEW_FACTOR",polyFactor);
+		ss->set("NEW_ROTATION",polyRotation);
+		ss->set("NEW_CURV",polyCurvature);
+		ss->set("NEW_INNER",polyInnerRot);
+		ss->set("NEW_OUTER",polyOuterCurvature);
+		ss->set("OLD_CORNER",item->polyCorners);
+		ss->set("OLD_USEFACTOR",item->polyUseFactor);
+		ss->set("OLD_FACTOR",item->polyFactor);
+		ss->set("OLD_ROTATION",item->polyRotation);
+		ss->set("OLD_CURV",item->polyCurvature);
+		ss->set("OLD_INNER",item->polyInnerRot);
+		ss->set("OLD_OUTER",item->polyOuterCurvature);
+		undoManager->action(currItem,ss);
+	}
 	item->polyCorners = polyC;
 	item->polyUseFactor = polyUseCF;
 	item->polyFactor = polyFactor;
@@ -453,7 +456,7 @@ void CanvasMode_EditPolygon::mousePressEvent(QMouseEvent *m)
 	}
 	else
 		m_polygonPoint = noPointDefined;
-	if(m_polygonPoint != noPointDefined)
+	if(m_polygonPoint != noPointDefined && UndoManager::undoEnabled())
 		trans = new UndoTransaction(undoManager->beginTransaction(Um::Polygon,Um::IPolygon,Um::EditPolygon,"",Um::IPolygon));
 	qApp->changeOverrideCursor(QCursor(Qt::CrossCursor));
 	QPainterPath path = itemMatrix.map(RegularPolygonPath(currItem->width(), currItem->height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature));
diff --git a/Scribus/scribus/canvasmode_nodeedit.cpp b/Scribus/scribus/canvasmode_nodeedit.cpp
index 6a64aa4..e229db2 100644
--- a/Scribus/scribus/canvasmode_nodeedit.cpp
+++ b/Scribus/scribus/canvasmode_nodeedit.cpp
@@ -459,10 +459,7 @@ void CanvasMode_NodeEdit::mouseReleaseEvent(QMouseEvent *m)
 			}
 			m_doc->nodeEdit.moveClipPoint(currItem, npf);
 		}
-
-		undoManager->setUndoEnabled(false);
 		m_doc->AdjustItemSize(currItem, true, true);
-		undoManager->setUndoEnabled(true);
 		if (!m_doc->nodeEdit.isContourLine)
 			currItem->ContourLine.translate(xposOrig - currItem->xPos(), yposOrig - currItem->yPos());
 		m_doc->regionsChanged()->update(QRectF());
diff --git a/Scribus/scribus/canvasmode_objimport.cpp b/Scribus/scribus/canvasmode_objimport.cpp
index 211658c..6bae373 100644
--- a/Scribus/scribus/canvasmode_objimport.cpp
+++ b/Scribus/scribus/canvasmode_objimport.cpp
@@ -179,6 +179,7 @@ void CanvasMode_ObjImport::mousePressEvent(QMouseEvent *m)
 		{
 			undoTransaction->commit();
 			delete undoTransaction;
+			undoTransaction = NULL;
 		}
 		// Return to normal mode
 		m_view->requestMode(modeNormal);
diff --git a/Scribus/scribus/guidesmodel.cpp b/Scribus/scribus/guidesmodel.cpp
index 66ba993..3023ff7 100644
--- a/Scribus/scribus/guidesmodel.cpp
+++ b/Scribus/scribus/guidesmodel.cpp
@@ -48,13 +48,13 @@ QVariant GuidesModel::data(const QModelIndex & index, int role) const
 	if (role == Qt::DisplayRole)
 	{
 		QLocale l;
-		return QVariant(l.toString(pts2value(m_values.at(index.row()),
-											  m_docUnitIndex) - rule, 'f',
+		return QVariant(l.toString(pts2value(m_values.at(index.row()) - rule,
+											  m_docUnitIndex), 'f',
 											  m_docUnitDecimals)
 						);
 	}
 	if (role == Qt::EditRole)
-		return pts2value(m_values.at(index.row()), m_docUnitIndex);
+		return pts2value(m_values.at(index.row()) - rule, m_docUnitIndex);
 
 	if (role == Qt::BackgroundColorRole && m_values.at(index.row()) == 0.0)
 		return QVariant(Qt::red);
diff --git a/Scribus/scribus/pageitem_textframe.cpp b/Scribus/scribus/pageitem_textframe.cpp
index 52b2564..ecf4c84 100644
--- a/Scribus/scribus/pageitem_textframe.cpp
+++ b/Scribus/scribus/pageitem_textframe.cpp
@@ -3461,7 +3461,9 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 			unicodeInputString = "";
 			if (ok)
 			{
-				UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::ITextFrame,Um::InsertText,"",Um::IDelete));
+				UndoTransaction *trans = NULL;
+				if(UndoManager::undoEnabled())
+					trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::ITextFrame,Um::InsertText,"",Um::IDelete));
 				if (itemText.lengthOfSelection() > 0)
 					deleteSelectedTextFromFrame();
 				if (conv < 31)
@@ -3481,7 +3483,12 @@ void PageItem_TextFrame::handleModeEditKey(QKeyEvent *k, bool& keyRepeat)
 					}
 				}
 				itemText.insertChars(QString(QChar(conv)), true);
-				trans.commit();
+				if(trans)
+				{
+					trans->commit();
+					delete trans;
+					trans = NULL;
+				}
 //				Tinput = true;
 				m_Doc->scMW()->setTBvals(this);
 				update();
diff --git a/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp b/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
index f42ff1b..a62054a 100644
--- a/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
+++ b/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
@@ -1016,15 +1016,9 @@ void Scribus134Format::readToolSettings(ScribusDoc* doc, ScXmlStreamAttributes&
 	doc->itemToolPrefs().shapeLineColorShade     = attrs.valueAsInt("PENSHADE", 100);
 	doc->itemToolPrefs().lineColor  = attrs.valueAsInt("LINESHADE", 100);
 	doc->itemToolPrefs().shapeFillColorShade      = attrs.valueAsInt("BRUSHSHADE", 100);
-	doc->opToolPrefs().magMin      = attrs.valueAsInt("MAGMIN", 1);
-	doc->opToolPrefs().magMax      = attrs.valueAsInt("MAGMAX", 3200);
-	doc->opToolPrefs().magStep     = attrs.valueAsInt("MAGSTEP", 125);
 	doc->opToolPrefs().dispX       = attrs.valueAsDouble("dispX", 10.0);
 	doc->opToolPrefs().dispY       = attrs.valueAsDouble("dispY", 10.0);
 	doc->opToolPrefs().constrain   = attrs.valueAsDouble("constrain", 15.0);
-	//CB Reset doc zoom step value to 200% instead of old values.
-	if (doc->opToolPrefs().magStep <= 100)
-		doc->opToolPrefs().magStep = 125;
 	doc->itemToolPrefs().textTabFillChar = attrs.valueAsString("TabFill","");
 	doc->itemToolPrefs().textTabWidth   = attrs.valueAsDouble("TabWidth", 36.0);
 	if (attrs.hasAttribute("CPICT"))
diff --git a/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp b/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp
index 3dcfda7..5f6300c 100644
--- a/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp
+++ b/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format_save.cpp
@@ -207,9 +207,6 @@ bool Scribus134Format::saveFile(const QString & fileName, const FileFormat & /*
 	docu.writeAttribute("PENSHADE",m_Doc->itemToolPrefs().shapeLineColorShade);
 	docu.writeAttribute("LINESHADE",m_Doc->itemToolPrefs().lineColorShade);
 	docu.writeAttribute("BRUSHSHADE",m_Doc->itemToolPrefs().shapeFillColorShade);
-	docu.writeAttribute("MAGMIN",m_Doc->opToolPrefs().magMin);
-	docu.writeAttribute("MAGMAX",m_Doc->opToolPrefs().magMax);
-	docu.writeAttribute("MAGSTEP",m_Doc->opToolPrefs().magStep);
 	docu.writeAttribute("CPICT",m_Doc->itemToolPrefs().imageFillColor);
 	docu.writeAttribute("PICTSHADE",m_Doc->itemToolPrefs().imageFillColorShade);
 	docu.writeAttribute("PICTSCX",m_Doc->itemToolPrefs().imageScaleX);
diff --git a/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp b/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
index 1dc5f7d..99ef238 100644
--- a/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
+++ b/Scribus/scribus/plugins/fileloader/scribus13format/scribus13format.cpp
@@ -400,12 +400,6 @@ bool Scribus13Format::loadFile(const QString & fileName, const FileFormat & /* f
 		m_Doc->itemToolPrefs().shapeLineColorShade    = dc.attribute("PENSHADE", "100").toInt();
 		m_Doc->itemToolPrefs().lineColorShade = dc.attribute("LINESHADE", "100").toInt();
 		m_Doc->itemToolPrefs().shapeFillColorShade     = dc.attribute("BRUSHSHADE", "100").toInt();
-		m_Doc->opToolPrefs().magMin     = dc.attribute("MAGMIN", "1").toInt();
-		m_Doc->opToolPrefs().magMax     = dc.attribute("MAGMAX", "3200").toInt();
-		m_Doc->opToolPrefs().magStep    = dc.attribute("MAGSTEP", "125").toInt();
-		//CB Reset doc zoom step value to 200% instead of old values.
-		if (m_Doc->opToolPrefs().magStep <= 100)
-			m_Doc->opToolPrefs().magStep = 125;
 		m_Doc->itemToolPrefs().textTabFillChar = dc.attribute("TabFill","");
 		m_Doc->itemToolPrefs().textTabWidth   = ScCLocale::toDoubleC(dc.attribute("TabWidth"), 36.0);
 		if (dc.hasAttribute("CPICT"))
diff --git a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
index 4a59095..1149088 100644
--- a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
+++ b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
@@ -2126,15 +2126,9 @@ void Scribus150Format::readToolSettings(ScribusDoc* doc, ScXmlStreamAttributes&
 	doc->itemToolPrefs().calligrapicPenAngle = attrs.valueAsDouble("calligrapicPenAngle", 0.0);
 	doc->itemToolPrefs().calligrapicPenWidth = attrs.valueAsDouble("calligrapicPenWidth", 10.0);
 	doc->itemToolPrefs().calligrapicPenStyle = static_cast<Qt::PenStyle>(attrs.valueAsInt("calligrapicPenStyle"));
-	doc->opToolPrefs().magMin      = attrs.valueAsInt("MAGMIN", 1);
-	doc->opToolPrefs().magMax      = attrs.valueAsInt("MAGMAX", 3200);
-	doc->opToolPrefs().magStep     = attrs.valueAsInt("MAGSTEP", 125);
 	doc->opToolPrefs().dispX       = attrs.valueAsDouble("dispX", 10.0);
 	doc->opToolPrefs().dispY       = attrs.valueAsDouble("dispY", 10.0);
 	doc->opToolPrefs().constrain   = attrs.valueAsDouble("constrain", 15.0);
-	//CB Reset doc zoom step value to 200% instead of old values.
-	if (doc->opToolPrefs().magStep <= 100)
-		doc->opToolPrefs().magStep = 125;
 	doc->itemToolPrefs().textTabFillChar = attrs.valueAsString("TabFill","");
 	doc->itemToolPrefs().textTabWidth   = attrs.valueAsDouble("TabWidth", 36.0);
 	if (attrs.hasAttribute("CPICT"))
diff --git a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
index 5b35591..a8d8fb4 100644
--- a/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
+++ b/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
@@ -332,9 +332,6 @@ bool Scribus150Format::saveFile(const QString & fileName, const FileFormat & /*
 	docu.writeAttribute("PENSHADE",m_Doc->itemToolPrefs().shapeLineColorShade);
 	docu.writeAttribute("LINESHADE",m_Doc->itemToolPrefs().lineColorShade);
 	docu.writeAttribute("BRUSHSHADE",m_Doc->itemToolPrefs().shapeFillColorShade);
-	docu.writeAttribute("MAGMIN",m_Doc->opToolPrefs().magMin);
-	docu.writeAttribute("MAGMAX",m_Doc->opToolPrefs().magMax);
-	docu.writeAttribute("MAGSTEP",m_Doc->opToolPrefs().magStep);
 	docu.writeAttribute("CPICT",m_Doc->itemToolPrefs().imageFillColor);
 	docu.writeAttribute("PICTSHADE",m_Doc->itemToolPrefs().imageFillColorShade);
 	docu.writeAttribute("CSPICT",m_Doc->itemToolPrefs().imageStrokeColor);
diff --git a/Scribus/scribus/plugins/import/ai/importaiplugin.cpp b/Scribus/scribus/plugins/import/ai/importaiplugin.cpp
index 5522321..30a0981 100644
--- a/Scribus/scribus/plugins/import/ai/importaiplugin.cpp
+++ b/Scribus/scribus/plugins/import/ai/importaiplugin.cpp
@@ -224,40 +224,28 @@ bool ImportAIPlugin::import(QString fileName, int flags)
 
 QImage ImportAIPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	AIPlug *dia = new AIPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
 
 bool ImportAIPlugin::readColors(const QString& fileName, ColorList &colors)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return false;
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	AIPlug *dia = new AIPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	bool ret = dia->readColors(fileName, colors);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/cgm/importcgmplugin.cpp b/Scribus/scribus/plugins/import/cgm/importcgmplugin.cpp
index 74885ec..8dbece8 100644
--- a/Scribus/scribus/plugins/import/cgm/importcgmplugin.cpp
+++ b/Scribus/scribus/plugins/import/cgm/importcgmplugin.cpp
@@ -170,17 +170,12 @@ QImage ImportCgmPlugin::readThumbnail(const QString& fileName)
 	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	CgmPlug *dia = new CgmPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/cvg/importcvgplugin.cpp b/Scribus/scribus/plugins/import/cvg/importcvgplugin.cpp
index 75469b8..9ab1bb6 100644
--- a/Scribus/scribus/plugins/import/cvg/importcvgplugin.cpp
+++ b/Scribus/scribus/plugins/import/cvg/importcvgplugin.cpp
@@ -166,20 +166,14 @@ bool ImportCvgPlugin::import(QString fileName, int flags)
 
 QImage ImportCvgPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	CvgPlug *dia = new CvgPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/drw/importdrwplugin.cpp b/Scribus/scribus/plugins/import/drw/importdrwplugin.cpp
index 59c0493..ebd4d94 100644
--- a/Scribus/scribus/plugins/import/drw/importdrwplugin.cpp
+++ b/Scribus/scribus/plugins/import/drw/importdrwplugin.cpp
@@ -168,20 +168,14 @@ bool ImportDrwPlugin::import(QString fileName, int flags)
 
 QImage ImportDrwPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	DrwPlug *dia = new DrwPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp b/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp
index 09079d8..ed12bad 100644
--- a/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp
+++ b/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp
@@ -183,40 +183,28 @@ bool ImportIdmlPlugin::import(QString fileName, int flags)
 
 QImage ImportIdmlPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	IdmlPlug *dia = new IdmlPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
 
 bool ImportIdmlPlugin::readColors(const QString& fileName, ColorList &colors)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return false;
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	IdmlPlug *dia = new IdmlPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	bool ret = dia->readColors(fileName, colors);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp b/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp
index a86ae58..d1f0237 100644
--- a/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp
+++ b/Scribus/scribus/plugins/import/oodraw/oodrawimp.cpp
@@ -220,20 +220,14 @@ bool OODrawImportPlugin::import(QString fileName, int flags)
 
 QImage OODrawImportPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	OODPlug *dia = new OODPlug(m_Doc);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/pct/importpctplugin.cpp b/Scribus/scribus/plugins/import/pct/importpctplugin.cpp
index f4a43b7..1e91c6d 100644
--- a/Scribus/scribus/plugins/import/pct/importpctplugin.cpp
+++ b/Scribus/scribus/plugins/import/pct/importpctplugin.cpp
@@ -162,17 +162,12 @@ QImage ImportPctPlugin::readThumbnail(const QString& fileName)
 	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	PctPlug *dia = new PctPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/pdf/importpdfplugin.cpp b/Scribus/scribus/plugins/import/pdf/importpdfplugin.cpp
index 3e4b874..b423aaa 100644
--- a/Scribus/scribus/plugins/import/pdf/importpdfplugin.cpp
+++ b/Scribus/scribus/plugins/import/pdf/importpdfplugin.cpp
@@ -238,20 +238,14 @@ bool ImportPdfPlugin::import(QString fileName, int flags)
 
 QImage ImportPdfPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	PdfPlug *dia = new PdfPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/shape/importshapeplugin.cpp b/Scribus/scribus/plugins/import/shape/importshapeplugin.cpp
index 5bd3f3b..22498e1 100644
--- a/Scribus/scribus/plugins/import/shape/importshapeplugin.cpp
+++ b/Scribus/scribus/plugins/import/shape/importshapeplugin.cpp
@@ -161,17 +161,14 @@ bool ImportShapePlugin::import(QString fileName, int flags)
 
 QImage ImportShapePlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = UndoManager::undoEnabled();
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-		UndoManager::instance()->setUndoEnabled(false);
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	ShapePlug *dia = new ShapePlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/sml/importsmlplugin.cpp b/Scribus/scribus/plugins/import/sml/importsmlplugin.cpp
index be46505..dbd5472 100644
--- a/Scribus/scribus/plugins/import/sml/importsmlplugin.cpp
+++ b/Scribus/scribus/plugins/import/sml/importsmlplugin.cpp
@@ -168,20 +168,14 @@ bool ImportSmlPlugin::import(QString fileName, int flags)
 
 QImage ImportSmlPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	SmlPlug *dia = new SmlPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/svg/svgplugin.cpp b/Scribus/scribus/plugins/import/svg/svgplugin.cpp
index c1bcd6f..e1ecf0a 100644
--- a/Scribus/scribus/plugins/import/svg/svgplugin.cpp
+++ b/Scribus/scribus/plugins/import/svg/svgplugin.cpp
@@ -207,20 +207,14 @@ bool SVGImportPlugin::import(QString filename, int flags)
 
 QImage SVGImportPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	SVGPlug *dia = new SVGPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/wmf/wmfimportplugin.cpp b/Scribus/scribus/plugins/import/wmf/wmfimportplugin.cpp
index 3cc9133..c62e0f7 100644
--- a/Scribus/scribus/plugins/import/wmf/wmfimportplugin.cpp
+++ b/Scribus/scribus/plugins/import/wmf/wmfimportplugin.cpp
@@ -194,20 +194,14 @@ bool WMFImportPlugin::import(QString filename, int flags)
 
 QImage WMFImportPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	WMFImport *dia = new WMFImport(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/wpg/importwpgplugin.cpp b/Scribus/scribus/plugins/import/wpg/importwpgplugin.cpp
index 38d5020..2b1ca47 100644
--- a/Scribus/scribus/plugins/import/wpg/importwpgplugin.cpp
+++ b/Scribus/scribus/plugins/import/wpg/importwpgplugin.cpp
@@ -166,20 +166,14 @@ bool ImportWpgPlugin::import(QString fileName, int flags)
 
 QImage ImportWpgPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	WpgPlug *dia = new WpgPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/xar/importxarplugin.cpp b/Scribus/scribus/plugins/import/xar/importxarplugin.cpp
index 76cdffe..db4e3c1 100644
--- a/Scribus/scribus/plugins/import/xar/importxarplugin.cpp
+++ b/Scribus/scribus/plugins/import/xar/importxarplugin.cpp
@@ -161,40 +161,28 @@ bool ImportXarPlugin::import(QString fileName, int flags)
 
 QImage ImportXarPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = ScCore->primaryMainWindow()->doc;
 	XarPlug *dia = new XarPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
 
 bool ImportXarPlugin::readColors(const QString& fileName, ColorList &colors)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return false;
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	XarPlug *dia = new XarPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	bool ret = dia->readColors(fileName, colors);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/import/xfig/importxfigplugin.cpp b/Scribus/scribus/plugins/import/xfig/importxfigplugin.cpp
index c7bbf06..49e486d 100644
--- a/Scribus/scribus/plugins/import/xfig/importxfigplugin.cpp
+++ b/Scribus/scribus/plugins/import/xfig/importxfigplugin.cpp
@@ -166,20 +166,14 @@ bool ImportXfigPlugin::import(QString fileName, int flags)
 
 QImage ImportXfigPlugin::readThumbnail(const QString& fileName)
 {
-	bool wasUndo = false;
 	if( fileName.isEmpty() )
 		return QImage();
-	if (UndoManager::undoEnabled())
-	{
-		UndoManager::instance()->setUndoEnabled(false);
-		wasUndo = true;
-	}
+	UndoManager::instance()->setUndoEnabled(false);
 	m_Doc = NULL;
 	XfigPlug *dia = new XfigPlug(m_Doc, lfCreateThumbnail);
 	Q_CHECK_PTR(dia);
 	QImage ret = dia->readThumbnail(fileName);
-	if (wasUndo)
-		UndoManager::instance()->setUndoEnabled(true);
+	UndoManager::instance()->setUndoEnabled(true);
 	delete dia;
 	return ret;
 }
diff --git a/Scribus/scribus/plugins/tools/pathconnect/pathconnect.cpp b/Scribus/scribus/plugins/tools/pathconnect/pathconnect.cpp
index 5b8548a..a7e1a74 100644
--- a/Scribus/scribus/plugins/tools/pathconnect/pathconnect.cpp
+++ b/Scribus/scribus/plugins/tools/pathconnect/pathconnect.cpp
@@ -56,7 +56,7 @@ PathConnectPlugin::PathConnectPlugin() : ScActionPlugin()
 	languageChange();
 }
 
-PathConnectPlugin::~PathConnectPlugin() {};
+PathConnectPlugin::~PathConnectPlugin() {}
 
 void PathConnectPlugin::languageChange()
 {
@@ -131,11 +131,10 @@ bool PathConnectPlugin::run(ScribusDoc* doc, QString)
 			int pointOne = dia->getFirstLinePoint();
 			int pointTwo = dia->getSecondLinePoint();
 			int mode = dia->getMode();
-			UndoTransaction trans(UndoManager::instance()->beginTransaction(Um::BezierCurve,Um::ILine,Um::ConnectPath,"",Um::ILine));
-			ScItemState<QPair<FPointArray,FPointArray> > *is = new ScItemState<QPair<FPointArray,FPointArray> >(Um::ConnectPath);
-			is->set("CONNECT_PATH","connect_path");
-			is->set("OLDX",originalXPos);
-			is->set("OLDY",originalYPos);
+			UndoTransaction *trans = NULL;
+			if(UndoManager::undoEnabled())
+				trans = new UndoTransaction(UndoManager::instance()->beginTransaction(Um::BezierCurve,Um::ILine,Um::ConnectPath,"",Um::ILine));
+
 			Item1->PoLine = computePath(pointOne, pointTwo, mode, originalPath1, originalPath2);
 			Item1->Frame = false;
 			Item1->ClipEdited = true;
@@ -143,16 +142,28 @@ bool PathConnectPlugin::run(ScribusDoc* doc, QString)
 			currDoc->AdjustItemSize(Item1);
 			Item1->OldB2 = Item1->width();
 			Item1->OldH2 = Item1->height();
-			is->set("NEWX",Item1->xPos());
-			is->set("NEWY",Item1->yPos());
-			is->setItem(qMakePair(originalPath1,Item1->PoLine));
-			UndoManager::instance()->action(Item1,is);
+			if(UndoManager::undoEnabled())
+			{
+				ScItemState<QPair<FPointArray,FPointArray> > *is = new ScItemState<QPair<FPointArray,FPointArray> >(Um::ConnectPath);
+				is->set("CONNECT_PATH","connect_path");
+				is->set("OLDX",originalXPos);
+				is->set("OLDY",originalYPos);
+				is->set("NEWX",Item1->xPos());
+				is->set("NEWY",Item1->yPos());
+				is->setItem(qMakePair(originalPath1,Item1->PoLine));
+				UndoManager::instance()->action(Item1,is);
+			}
 			Item1->updateClip();
 			Item1->ContourLine = Item1->PoLine.copy();
 			currDoc->m_Selection->removeItem(Item1);
 			currDoc->itemSelection_DeleteItem();
 			currDoc->changed();
-			trans.commit();
+			if(trans)
+			{
+				trans->commit();
+				delete trans;
+				trans = NULL;
+			}
 		}
 		else
 		{
diff --git a/Scribus/scribus/plugins/tools/pathfinder/pathfinder.cpp b/Scribus/scribus/plugins/tools/pathfinder/pathfinder.cpp
index af1e098..440a775 100644
--- a/Scribus/scribus/plugins/tools/pathfinder/pathfinder.cpp
+++ b/Scribus/scribus/plugins/tools/pathfinder/pathfinder.cpp
@@ -67,7 +67,7 @@ PathFinderPlugin::PathFinderPlugin() : ScActionPlugin()
 	languageChange();
 }
 
-PathFinderPlugin::~PathFinderPlugin() {};
+PathFinderPlugin::~PathFinderPlugin() {}
 
 void PathFinderPlugin::languageChange()
 {
diff --git a/Scribus/scribus/prefsmanager.cpp b/Scribus/scribus/prefsmanager.cpp
index 0320bdd..1496747 100644
--- a/Scribus/scribus/prefsmanager.cpp
+++ b/Scribus/scribus/prefsmanager.cpp
@@ -258,7 +258,7 @@ void PrefsManager::initDefaults()
 	appPrefs.itemToolPrefs.lineEndArrow = 0;
 	appPrefs.opToolPrefs.magMin = 1;
 	appPrefs.opToolPrefs.magMax = 3200;
-	appPrefs.opToolPrefs.magStep = 125;
+	appPrefs.opToolPrefs.magStep = 25;
 	appPrefs.docSetupPrefs.docUnitIndex = 0;
 	appPrefs.itemToolPrefs.polyCorners = 4;
 	appPrefs.itemToolPrefs.polyFactor = 0.5;
@@ -2146,10 +2146,9 @@ bool PrefsManager::ReadPref(QString ho)
 		{
 			appPrefs.opToolPrefs.magMin  = dc.attribute("MinimumMagnification", "1").toInt();
 			appPrefs.opToolPrefs.magMax  = dc.attribute("MaximumMagnification", "3200").toInt();
-			appPrefs.opToolPrefs.magStep = dc.attribute("MagnificationStep", "125").toInt();
-			//CB Reset prefs zoom step value to 200% instead of old values.
-			if (appPrefs.opToolPrefs.magStep <= 100)
-				appPrefs.opToolPrefs.magStep = 125;
+			appPrefs.opToolPrefs.magStep = dc.attribute("MagnificationStep", "25").toInt();
+			if (appPrefs.opToolPrefs.magStep < 0)
+				appPrefs.opToolPrefs.magStep = 25;
 			appPrefs.opToolPrefs.dispX = ScCLocale::toDoubleC(dc.attribute("DisplayOffsetX"), 10.0);
 			appPrefs.opToolPrefs.dispY = ScCLocale::toDoubleC(dc.attribute("DisplayOffsetY"), 10.0);
 			appPrefs.opToolPrefs.constrain = ScCLocale::toDoubleC(dc.attribute("RotationConstrainAngle"), 15.0);
diff --git a/Scribus/scribus/scribus.cpp b/Scribus/scribus/scribus.cpp
index 6c3eecd..0190508 100644
--- a/Scribus/scribus/scribus.cpp
+++ b/Scribus/scribus/scribus.cpp
@@ -3444,7 +3444,9 @@ void ScribusMainWindow::doPasteRecent(QString data)
 		}
 		else
 		{
-			UndoTransaction pasteAction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate));
+			UndoTransaction *pasteAction = NULL;
+			if(UndoManager::undoEnabled())
+				pasteAction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::Create,"",Um::ICreate));
 			view->Deselect(true);
 			uint ac = doc->Items->count();
 			bool savedAlignGrid = doc->useRaster;
@@ -3471,7 +3473,12 @@ void ScribusMainWindow::doPasteRecent(QString data)
 					AddBookMark(currItem);
 			}
 			doc->m_Selection->copy(tmpSelection, false);
-			pasteAction.commit();
+			if(pasteAction)
+			{
+				pasteAction->commit();
+				delete pasteAction;
+				pasteAction = NULL;
+			}
 		}
 		slotDocCh(false);
 		doc->regionsChanged()->update(QRectF());
@@ -6211,6 +6218,12 @@ void ScribusMainWindow::ToggleUElements()
 	}
 }
 
+void ScribusMainWindow::SetSnapElements(bool b)
+{
+	if(doc && doc->SnapElement != b)
+		ToggleUElements();
+}
+
 
 void ScribusMainWindow::toggleNodeEdit()
 {
@@ -6484,7 +6497,7 @@ void ScribusMainWindow::setAppMode(int mode)
 			ToggleFrameEdit();
 
 		//Ugly hack but I have absolutly no idea about how to do this in another way
-		if(currItem && oldMode != mode && (mode == modeEditMeshPatch || mode == modeEditMeshGradient || mode == modeEditGradientVectors || oldMode == modeEditMeshPatch || oldMode == modeEditMeshGradient || oldMode == modeEditGradientVectors || oldMode == modeEditPolygon || mode == modeEditPolygon || oldMode == modeEditArc || mode == modeEditArc || oldMode == modeEditSpiral || mode == modeEditSpiral))
+		if(UndoManager::undoEnabled() && currItem && oldMode != mode && (mode == modeEditMeshPatch || mode == modeEditMeshGradient || mode == modeEditGradientVectors || oldMode == modeEditMeshPatch || oldMode == modeEditMeshGradient || oldMode == modeEditGradientVectors || oldMode == modeEditPolygon || mode == modeEditPolygon || oldMode == modeEditArc || mode == modeEditArc || oldMode == modeEditSpiral || mode == modeEditSpiral))
 		{
 			SimpleState *ss = new SimpleState(Um::Mode);
 			ss->set("CHANGE_MODE","change_mode");
@@ -7507,14 +7520,21 @@ void ScribusMainWindow::duplicateItem()
 	doc->SnapElement = false;
 	slotEditCopy();
 	view->Deselect(true);
-	UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::Duplicate,"",Um::IMultipleDuplicate));
+	UndoTransaction *trans = NULL;
+	if(UndoManager::undoEnabled())
+		trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::Duplicate,"",Um::IMultipleDuplicate));
 	slotEditPaste();
 	for (int b=0; b<doc->m_Selection->count(); ++b)
 	{
 		doc->m_Selection->itemAt(b)->setLocked(false);
 		doc->MoveItem(doc->opToolPrefs().dispX, doc->opToolPrefs().dispY, doc->m_Selection->itemAt(b));
 	}
-	trans.commit();
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 	doc->useRaster = savedAlignGrid;
 	doc->SnapGuides = savedAlignGuides;
 	doc->SnapElement = savedAlignElement;
@@ -9973,14 +9993,21 @@ void ScribusMainWindow::slotItemTransform()
 		TransformDialog td(this, doc);
 		if (td.exec())
 		{
-			UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::Transform,"",Um::IMove));
+			UndoTransaction *trans = NULL;
+			if(UndoManager::undoEnabled())
+				trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::IPolygon,Um::Transform,"",Um::IMove));
 			qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
 			int count=td.getCount();
 			QTransform matrix(td.getTransformMatrix());
 			int basepoint=td.getBasepoint();
 			doc->itemSelection_Transform(count, matrix, basepoint);
 			qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-			trans.commit();
+			if(trans)
+			{
+				trans->commit();
+				delete trans;
+				trans = NULL;
+			}
 		}
 	}
 }
diff --git a/Scribus/scribus/scribus.h b/Scribus/scribus/scribus.h
index 4f01695..e79d311 100644
--- a/Scribus/scribus/scribus.h
+++ b/Scribus/scribus/scribus.h
@@ -479,6 +479,7 @@ public slots:
 	void ToggleBase();
 	void ToggleUGuides();
 	void ToggleUElements();
+	void SetSnapElements(bool b);
 	void EditTabs();
 	void SearchText();
 	void imageEditorExited(int, QProcess::ExitStatus);
diff --git a/Scribus/scribus/scribusview.cpp b/Scribus/scribus/scribusview.cpp
index fb81a30..0a8fd35 100644
--- a/Scribus/scribus/scribusview.cpp
+++ b/Scribus/scribus/scribusview.cpp
@@ -2442,7 +2442,9 @@ void ScribusView::slotZoomIn(int mx,int my)
 	}
 	else
 		rememberOldZoomLocation(mx,my);
-	double newScale = m_canvas->scale() * static_cast<double>(Doc->opToolPrefs().magStep)/100.0;
+	double newScale = m_canvas->scale() * (1 + static_cast<double>(Doc->opToolPrefs().magStep)/100.0);
+	if(static_cast<int>(newScale*100)>static_cast<int>(100 * static_cast<double>(Doc->opToolPrefs().magStep)*Prefs->displayPrefs.displayScale/100))
+		newScale = m_canvas->scale() + static_cast<double>(Doc->opToolPrefs().magStep)*Prefs->displayPrefs.displayScale/100;
 	if (Doc->m_Selection->count() != 0)
 	{
 		PageItem *currItem = Doc->m_Selection->itemAt(0);
@@ -2468,7 +2470,9 @@ void ScribusView::slotZoomOut(int mx,int my)
 	}
 	else
 		rememberOldZoomLocation(mx,my);
-	double newScale = m_canvas->scale() / (static_cast<double>(Doc->opToolPrefs().magStep)/100.0);
+	double newScale = m_canvas->scale() - static_cast<double>(Doc->opToolPrefs().magStep)*Prefs->displayPrefs.displayScale/100;
+	if(newScale<=Prefs->displayPrefs.displayScale/100)
+		newScale = m_canvas->scale() / (1 + static_cast<double>(Doc->opToolPrefs().magStep)/100.0);
 	if (Doc->m_Selection->count() != 0)
 	{
 		PageItem *currItem = Doc->m_Selection->itemAt(0);
@@ -4304,6 +4308,8 @@ bool ScribusView::eventFilter(QObject *obj, QEvent *event)
 	else if (event->type() == QEvent::KeyPress)
 	{
 		QKeyEvent* m = static_cast<QKeyEvent*> (event);
+		if(m->key() == Qt::Key_Shift)
+			m_ScMW->SetSnapElements(false);
 		if (m_canvasMode->handleKeyEvents())
 			m_canvasMode->keyPressEvent(m);
 		else
@@ -4313,6 +4319,8 @@ bool ScribusView::eventFilter(QObject *obj, QEvent *event)
 	else if (event->type() == QEvent::KeyRelease)
 	{
 		QKeyEvent* m = static_cast<QKeyEvent*> (event);
+		if(m->key() == Qt::Key_Shift)
+			m_ScMW->SetSnapElements(true);
 		if (m_canvasMode->handleKeyEvents())
 			m_canvasMode->keyReleaseEvent(m);
 		else
diff --git a/Scribus/scribus/ui/guidemanager.cpp b/Scribus/scribus/ui/guidemanager.cpp
index 87dd332..8ad4a4d 100644
--- a/Scribus/scribus/ui/guidemanager.cpp
+++ b/Scribus/scribus/ui/guidemanager.cpp
@@ -518,7 +518,9 @@ void GuideManager::clearRestoreVerticalList()
 
 void GuideManager::deletePageButton_clicked()
 {
-	UndoTransaction trans(UndoManager::instance()->beginTransaction(currentPage->getUName(),
+	UndoTransaction *trans = NULL;
+	if(UndoManager::undoEnabled())
+		trans = new UndoTransaction(UndoManager::instance()->beginTransaction(currentPage->getUName(),
 																currentPage->getUPixmap(),
 																Um::RemoveAllPageGuides, "",
 																Um::IGuides));
@@ -537,7 +539,12 @@ void GuideManager::deletePageButton_clicked()
 	currentPage->guides.setVerticalAutoRefer(0);
 	horizontalAutoCountSpin->setValue(0);
 	verticalAutoCountSpin->setValue(0);
-	trans.commit();
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 
 	drawGuides();
 	m_Doc->changed();
@@ -545,7 +552,9 @@ void GuideManager::deletePageButton_clicked()
 
 void GuideManager::deleteAllGuides_clicked()
 {
-	UndoTransaction trans(UndoManager::instance()->beginTransaction(m_Doc->getUName(),
+	UndoTransaction *trans = NULL;
+	if(UndoManager::undoEnabled())
+		trans = new UndoTransaction(UndoManager::instance()->beginTransaction(m_Doc->getUName(),
 																m_Doc->getUPixmap(),
 																Um::RemoveAllGuides, "",
 																Um::IGuides));
@@ -554,7 +563,12 @@ void GuideManager::deleteAllGuides_clicked()
 	copyGuidesToAllPages(GuideManagerCore::Standard);
 	copyGuidesToAllPages(GuideManagerCore::Auto);
 	m_drawGuides = true;
-	trans.commit();
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 	drawGuides();
 	m_Doc->changed();
 }
diff --git a/Scribus/scribus/ui/layers.cpp b/Scribus/scribus/ui/layers.cpp
index 5b5f247..edd0afc 100644
--- a/Scribus/scribus/ui/layers.cpp
+++ b/Scribus/scribus/ui/layers.cpp
@@ -276,7 +276,9 @@ void LayerPalette::addLayer()
 
 void LayerPalette::dupLayer()
 {
-	UndoTransaction copyTransaction( UndoManager::instance()->beginTransaction("", Um::ILayerAction, Um::DuplicateLayer.arg(m_Doc->activeLayerName()) , "", Um::ICreate) );
+	UndoTransaction *copyTransaction = NULL;
+	if(UndoManager::undoEnabled())
+		copyTransaction = new UndoTransaction(UndoManager::instance()->beginTransaction("", Um::ILayerAction, Um::DuplicateLayer.arg(m_Doc->activeLayerName()) , "", Um::ICreate) );
 	
 	int current = m_Doc->activeLayer();
 	
@@ -286,8 +288,12 @@ void LayerPalette::dupLayer()
 	m_Doc->copyLayer(current, m_Doc->activeLayer());
 	m_Doc->scMW()->changeLayer(m_Doc->activeLayer());
 	m_Doc->changed();
-	
-	copyTransaction.commit();
+	if(copyTransaction)
+	{
+		copyTransaction->commit();
+		delete copyTransaction;
+		copyTransaction = NULL;
+	}
 }
 
 void LayerPalette::removeLayer()
diff --git a/Scribus/scribus/ui/paintmanager.cpp b/Scribus/scribus/ui/paintmanager.cpp
index 7504c97..210b3ab 100644
--- a/Scribus/scribus/ui/paintmanager.cpp
+++ b/Scribus/scribus/ui/paintmanager.cpp
@@ -1283,7 +1283,6 @@ void PaintManagerDialog::loadVectors(QString data)
 {
 	m_doc->PageColors = m_colorList;
 	m_doc->docGradients = dialogGradients;
-	bool wasUndo = UndoManager::undoEnabled();
 	UndoManager::instance()->setUndoEnabled(false);
 	m_doc->setLoading(true);
 	QFileInfo fi(data);
@@ -1387,7 +1386,7 @@ void PaintManagerDialog::loadVectors(QString data)
 	m_doc->setLoading(false);
 	m_colorList = m_doc->PageColors;
 	dialogGradients = m_doc->docGradients;
-	UndoManager::instance()->setUndoEnabled(wasUndo);
+	UndoManager::instance()->setUndoEnabled(true);
 }
 
 ColorList PaintManagerDialog::getGradientColors()
diff --git a/Scribus/scribus/ui/prefs_itemtools.cpp b/Scribus/scribus/ui/prefs_itemtools.cpp
index 557b336..eda3540 100644
--- a/Scribus/scribus/ui/prefs_itemtools.cpp
+++ b/Scribus/scribus/ui/prefs_itemtools.cpp
@@ -136,6 +136,7 @@ void Prefs_ItemTools::restoreDefaults(struct ApplicationPrefs *prefsData)
 	imageHorizontalScalingSpinBox->setValue(qRound(prefsData->itemToolPrefs.imageScaleX * 100));
 	imageVerticalScalingSpinBox->setValue(qRound(prefsData->itemToolPrefs.imageScaleY * 100));
 	imageKeepAspectRatioCheckBox->setChecked(prefsData->itemToolPrefs.imageAspectRatio);
+	scalingLockToolButton->setChecked(prefsData->itemToolPrefs.imageAspectRatio);
 	imageFrameFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.imageFillColor);
 	imageFrameFillShadingSpinBox->setValue(prefsData->itemToolPrefs.imageFillColorShade );
 	imageFrameLineColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.imageStrokeColor);
@@ -252,11 +253,6 @@ void Prefs_ItemTools::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
 	prefsData->itemToolPrefs.textDistances.Bottom = bottomTextDistanceSpinBox->value() / unitRatio;
 	prefsData->itemToolPrefs.textDistances.Left = leftTextDistanceSpinBox->value() / unitRatio;
 	prefsData->itemToolPrefs.textDistances.Right = rightTextDistanceSpinBox->value() / unitRatio;
-
-	//Image Tool
-	//
-	//	TODO scalingLockToolButton
-
 	prefsData->itemToolPrefs.imageFillColor = imageFrameFillColorComboBox->currentText();
 	if (prefsData->itemToolPrefs.imageFillColor == CommonStrings::tr_NoneColor)
 		prefsData->itemToolPrefs.imageFillColor = CommonStrings::None;
@@ -340,6 +336,7 @@ void Prefs_ItemTools::enableSignals(bool on)
 //		connect(buttonGroup5, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingRatio(bool)));
 		connect(scalingLockToolButton, SIGNAL(clicked()), this, SLOT(toggleImagesScalingChain()));
 		connect(imageHorizontalScalingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(imageHorizontalScalingChange()));
+		connect(imageKeepAspectRatioCheckBox, SIGNAL(toggled(bool)), scalingLockToolButton, SLOT(setChecked(bool)));
 		connect(imageVerticalScalingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(imageVerticalScalingChange()));
 //		connect(tabFillCombo, SIGNAL(activated(int)), this, SLOT(setFillChar(int)));
 	}
@@ -414,6 +411,7 @@ void Prefs_ItemTools::updateFontPreview()
 void Prefs_ItemTools::toggleImagesScalingChain()
 {
 	imageHorizontalScalingChange();
+	imageKeepAspectRatioCheckBox->setChecked(scalingLockToolButton->isChecked());
 }
 
 void Prefs_ItemTools::imageHorizontalScalingChange()
diff --git a/Scribus/scribus/ui/propertiespalette.cpp b/Scribus/scribus/ui/propertiespalette.cpp
index 8e71a68..15a8d2b 100644
--- a/Scribus/scribus/ui/propertiespalette.cpp
+++ b/Scribus/scribus/ui/propertiespalette.cpp
@@ -637,7 +637,9 @@ void PropertiesPalette::NewSpGradient(double x1, double y1, double x2, double y2
 	if ((m_haveDoc) && (m_haveItem))
 	{
 		QRectF upRect;
-		UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::ILine,Um::GradPos + "p","",Um::ILine));
+		UndoTransaction *trans = NULL;
+		if(UndoManager::undoEnabled())
+			trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::ILine,Um::GradPos + "p","",Um::ILine));
 		if (m_ScMW->view->editStrokeGradient == 1)
 		{
 			m_item->setGradientStrokeStartX(x1 / m_unitRatio);
@@ -690,7 +692,7 @@ void PropertiesPalette::NewSpGradient(double x1, double y1, double x2, double y2
 		}
 		else
 		{
-			if (m_item->gradientType() == 13)
+			if (m_item->gradientType() == 13 && UndoManager::undoEnabled())
 			{
 				SimpleState *ss= new SimpleState("Refresh");
 				ss->set("UNDO_UPDATE_CONICAL","undo_update_conical");
@@ -709,7 +711,7 @@ void PropertiesPalette::NewSpGradient(double x1, double y1, double x2, double y2
 				m_item->setGradientFocalX(m_item->gradientStartX());
 				m_item->setGradientFocalY(m_item->gradientStartY());
 			}
-			if (m_item->gradientType() == 13)
+			if (m_item->gradientType() == 13 && UndoManager::undoEnabled())
 			{
 				m_item->createConicalMesh();
 				SimpleState *ss= new SimpleState("Refresh");
@@ -732,7 +734,12 @@ void PropertiesPalette::NewSpGradient(double x1, double y1, double x2, double y2
 			upRect |= QRectF(shP, QPointF(0, 0)).normalized();
 			upRect |= QRectF(shP, QPointF(m_item->width(), m_item->height())).normalized();
 		}
-		trans.commit();
+		if(trans)
+		{
+			trans->commit();
+			delete trans;
+			trans = NULL;
+		}
 		upRect.translate(m_item->xPos(), m_item->yPos());
 		m_doc->regionsChanged()->update(upRect.adjusted(-10.0, -10.0, 10.0, 10.0));
 		m_doc->changed();
@@ -778,7 +785,9 @@ void PropertiesPalette::NewSpGradientM(double x1, double y1, double x2, double y
 	if ((m_haveDoc) && (m_haveItem))
 	{
 		QRectF upRect;
-		UndoTransaction trans(undoManager->beginTransaction(Um::Selection,Um::ILine,Um::GradPos + "o","",Um::ILine));
+		UndoTransaction *trans = NULL;
+		if(UndoManager::undoEnabled())
+			trans = new UndoTransaction(undoManager->beginTransaction(Um::Selection,Um::ILine,Um::GradPos + "o","",Um::ILine));
 		m_item->setGradientMaskStartX(x1 / m_unitRatio);
 		m_item->setGradientMaskStartY(y1 / m_unitRatio);
 		m_item->setGradientMaskEndX(x2 / m_unitRatio);
@@ -793,7 +802,12 @@ void PropertiesPalette::NewSpGradientM(double x1, double y1, double x2, double y
 			m_item->setGradientMaskFocalY(m_item->GrMaskStartY);
 		}
 		m_item->update();
-		trans.commit();
+		if(trans)
+		{
+			trans->commit();
+			delete trans;
+			trans = NULL;
+		}
 		upRect = QRectF(QPointF(m_item->GrMaskStartX, m_item->GrMaskStartY), QPointF(m_item->GrMaskEndX, m_item->GrMaskEndY));
 		double radEnd = distance(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
 		double rotEnd = xy2Deg(m_item->GrMaskEndX - m_item->GrMaskStartX, m_item->GrMaskEndY - m_item->GrMaskStartY);
diff --git a/Scribus/scribus/ui/propertiespalette_image.cpp b/Scribus/scribus/ui/propertiespalette_image.cpp
index f57fe80..7ee3a19 100644
--- a/Scribus/scribus/ui/propertiespalette_image.cpp
+++ b/Scribus/scribus/ui/propertiespalette_image.cpp
@@ -104,7 +104,7 @@ PropertiesPalette_Image::PropertiesPalette_Image( QWidget* parent) : QWidget(par
 	connect(keepImageDPIRatioButton, SIGNAL(clicked())       , this, SLOT(handleImageDPIRatio()));
 	connect(freeScale          , SIGNAL(clicked())           , this, SLOT(handleScaling()));
 	connect(frameScale         , SIGNAL(clicked())           , this, SLOT(handleScaling()));
-	connect(cbProportional     , SIGNAL(clicked())           , this, SLOT(handleScaling()));
+	connect(cbProportional     , SIGNAL(stateChanged(int))   , this, SLOT(handleScaling()));
 	connect(imgEffectsButton   , SIGNAL(clicked())           , this, SLOT(handleImageEffects()));
 	connect(imgExtProperties   , SIGNAL(clicked())           , this, SLOT(handleExtImgProperties()));
 	connect(inputProfiles      , SIGNAL(activated(const QString&)), this, SLOT(handleProfile(const QString&)));
@@ -490,6 +490,8 @@ void PropertiesPalette_Image::setCurrentItem(PageItem *item)
 			//Necessary for undo action
 			keepImageWHRatioButton->setEnabled(setter);
 			keepImageDPIRatioButton->setEnabled(setter);
+			keepImageWHRatioButton->setChecked(m_item->AspectRatio);
+			keepImageDPIRatioButton->setChecked(m_item->AspectRatio);
 		}
 //CB Why do we need this? Setting it too much here
 // 		if (setter == true)
@@ -674,9 +676,13 @@ void PropertiesPalette_Image::handleImageDPIRatio()
 		imgDpiY->setValue(imgDpiX->value());
 		handleLocalDpi();
 		keepImageWHRatioButton->setChecked(true);
+		cbProportional->setChecked(true);
 	}
 	else
+	{
 		keepImageWHRatioButton->setChecked(false);
+		cbProportional->setChecked(false);
+	}
 	imgDpiX->blockSignals(false);
 	imgDpiY->blockSignals(false);
 }
@@ -692,9 +698,13 @@ void PropertiesPalette_Image::handleImageWHRatio()
 		imageYScaleSpinBox->setValue(imageXScaleSpinBox->value());
 		handleLocalScale();
 		keepImageDPIRatioButton->setChecked(true);
+		cbProportional->setChecked(true);
 	}
 	else
+	{
 		keepImageDPIRatioButton->setChecked(false);
+		cbProportional->setChecked(false);
+	}
 	imageXScaleSpinBox->blockSignals(false);
 	imageYScaleSpinBox->blockSignals(false);
 }
@@ -719,11 +729,14 @@ void PropertiesPalette_Image::handleImagePageNumber()
 	if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
 		return;
 	bool reallynew = (m_item->pixm.imgInfo.actualPageNumber != imagePageNumber->value());
-	SimpleState *ss = new SimpleState(Um::PageNmbr.arg(static_cast<int>(imagePageNumber->value())),"",Um::IImageFrame);
-	ss->set("IMAGE_NBR","image_nbr");
-	ss->set("OLD",m_item->pixm.imgInfo.actualPageNumber);
-	ss->set("NEW",imagePageNumber->value());
-	UndoManager::instance()->action(m_item,ss);
+	if(UndoManager::undoEnabled())
+	{
+		SimpleState *ss = new SimpleState(Um::PageNmbr.arg(static_cast<int>(imagePageNumber->value())),"",Um::IImageFrame);
+		ss->set("IMAGE_NBR","image_nbr");
+		ss->set("OLD",m_item->pixm.imgInfo.actualPageNumber);
+		ss->set("NEW",imagePageNumber->value());
+		UndoManager::instance()->action(m_item,ss);
+	}
 	m_item->pixm.imgInfo.actualPageNumber = static_cast<int>(imagePageNumber->value());
 	if (reallynew)
 		m_item->loadImage(m_item->externalFile(), true);
fix.diff (60,375 bytes)   

Chelen

2012-08-01 16:23

reporter   ~0028716

On the fix diff, I fix issue which appeared with this patch, finish to clean up undo work and add functionnality for item snaping (shift modifier, more line indicator)

Chelen

2012-08-01 20:14

reporter  

zoom.diff (707 bytes)   
diff --git a/Scribus/scribus/scribusview.cpp b/Scribus/scribus/scribusview.cpp
index 0a8fd35..147500e 100644
--- a/Scribus/scribus/scribusview.cpp
+++ b/Scribus/scribus/scribusview.cpp
@@ -2473,6 +2473,8 @@ void ScribusView::slotZoomOut(int mx,int my)
 	double newScale = m_canvas->scale() - static_cast<double>(Doc->opToolPrefs().magStep)*Prefs->displayPrefs.displayScale/100;
 	if(newScale<=Prefs->displayPrefs.displayScale/100)
 		newScale = m_canvas->scale() / (1 + static_cast<double>(Doc->opToolPrefs().magStep)/100.0);
+	if(newScale<=Prefs->displayPrefs.displayScale/100)
+		newScale = m_canvas->scale();
 	if (Doc->m_Selection->count() != 0)
 	{
 		PageItem *currItem = Doc->m_Selection->itemAt(0);
zoom.diff (707 bytes)   

cbradney

2012-10-13 19:28

administrator   ~0029044

Hi Chelen.. where did this one get to? Want to resubmit any features missing from SVN?

Chelen

2012-10-19 16:31

reporter   ~0029053

the only missing tool here is the zoom management. For now, I didn't change anything as we disagreed on this point. I remember that the last idea was : hard coding a table of value [10 20 30 40 50 75 100 150 200]. If you use you wheel, you go to the next or the preview step. If everyone agree on this, I can work on it?

pygmee

2012-10-20 17:28

developer   ~0029056

why not but i don't really understand why you choose those steps. Personnally i think we more often need zooming in more than 100 % (for preciseness) up to 400% (print res 300dpi/ screenres 72dpi). I would add 125%, 175 %, 250%, 300%, 400%

cbradney

2012-10-22 19:36

administrator   ~0029082

Ok, lets skip the wheel thing for now.. do you mean the rest is in SVN already?

Chelen

2012-10-23 11:09

reporter   ~0029089

Yes, I think so

Vladimir Savic

2012-11-02 13:49

reporter   ~0029143

Why did we all "blocked" at this point?! We're not reinventing wheel. No, not wheel - this is even more fundamental! Software does it for at least two decades. Never heard someone complaining on how any office or graphic suite does it. Why is it such a big deal with Scribus?

Take a look at LibreOffice Writer. I think its way is surprisingly good choice. If you don't want to go there, anything a bit fine-grainier then current defaults will work for me. ;)

Issue History

Date Modified Username Field Change
2012-07-31 10:58 Chelen New Issue
2012-07-31 10:58 Chelen Status new => assigned
2012-07-31 10:58 Chelen Assigned To => Chelen
2012-07-31 10:58 Chelen File Added: snap.diff
2012-07-31 11:28 Chelen Description Updated
2012-07-31 19:31 cbradney Relationship added related to 0010861
2012-07-31 19:31 cbradney Relationship added related to 0010759
2012-07-31 19:31 cbradney Relationship added related to 0010943
2012-07-31 19:31 cbradney Relationship added related to 0010944
2012-07-31 19:31 cbradney Relationship added related to 0010719
2012-07-31 19:31 cbradney Relationship added related to 0010951
2012-07-31 19:31 cbradney Relationship added related to 0010171
2012-07-31 19:35 cbradney Relationship added related to 0010865
2012-08-01 16:21 Chelen File Added: fix.diff
2012-08-01 16:23 Chelen Note Added: 0028716
2012-08-01 20:14 Chelen File Added: zoom.diff
2012-10-13 19:28 cbradney Note Added: 0029044
2012-10-19 16:31 Chelen Note Added: 0029053
2012-10-20 17:28 pygmee Note Added: 0029056
2012-10-22 19:36 cbradney Note Added: 0029082
2012-10-23 11:09 Chelen Note Added: 0029089
2012-11-02 13:49 Vladimir Savic Note Added: 0029143
2013-08-06 20:18 cbradney Status assigned => resolved
2013-08-06 20:18 cbradney Fixed in Version => 1.5.0svn
2013-08-06 20:18 cbradney Resolution open => fixed
2013-08-09 06:37 christoph_s Status resolved => closed