r17735 by craig - 10905: Chelen: some more undo added and multiple image import

scribus-commit scribus-commit at lists.scribus.net
Tue Jul 24 22:01:02 UTC 2012


Author: craig
Date: Tue Jul 24 22:01:01 2012
New Revision: 17735

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17735
Log:
10905: Chelen: some more undo added and multiple image import

Added:
    trunk/Scribus/scribus/canvasmode_imageimport.cpp   (with props)
    trunk/Scribus/scribus/canvasmode_imageimport.h   (with props)
Modified:
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/canvas.h
    trunk/Scribus/scribus/canvasmode.cpp
    trunk/Scribus/scribus/canvasmode_editarc.cpp
    trunk/Scribus/scribus/canvasmode_editpolygon.cpp
    trunk/Scribus/scribus/canvasmode_editpolygon.h
    trunk/Scribus/scribus/canvasmode_editspiral.cpp
    trunk/Scribus/scribus/canvasmode_editspiral.h
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pageitem_imageframe.cpp
    trunk/Scribus/scribus/plugins/tools/pathconnect/pathconnect.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusstructs.h
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/scribusview.h
    trunk/Scribus/scribus/ui/customfdialog.cpp
    trunk/Scribus/scribus/ui/customfdialog.h
    trunk/Scribus/scribus/ui/spiralvectordialog.cpp
    trunk/Scribus/scribus/undogui.cpp
    trunk/Scribus/scribus/undogui.h
    trunk/Scribus/scribus/undomanager.cpp
    trunk/Scribus/scribus/undomanager.h
    trunk/Scribus/scribus/undostack.cpp
    trunk/Scribus/scribus/undostack.h

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Tue Jul 24 22:01:01 2012
@@ -494,6 +494,7 @@
   canvasmode_drawfreehand.cpp
   canvasmode_eyedropper.cpp
   canvasmode_framelinks.cpp
+  canvasmode_imageimport.cpp
   canvasmode_edit.cpp
   canvasmode_editarc.cpp
   canvasmode_editgradient.cpp

Modified: trunk/Scribus/scribus/canvas.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/canvas.h
==============================================================================
--- trunk/Scribus/scribus/canvas.h (original)
+++ trunk/Scribus/scribus/canvas.h Tue Jul 24 22:01:01 2012
@@ -101,6 +101,7 @@
 	friend class CanvasMode_EditTable;
 	friend class CanvasMode_EyeDropper;
 	friend class CanvasMode_FrameLinks;
+	friend class CanvasMode_ImageImport;
 	friend class CanvasMode_Magnifier;
 	friend class CanvasMode_NodeEdit;
 	friend class CanvasMode_ObjImport;

Modified: trunk/Scribus/scribus/canvasmode.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/canvasmode.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode.cpp (original)
+++ trunk/Scribus/scribus/canvasmode.cpp Tue Jul 24 22:01:01 2012
@@ -34,6 +34,7 @@
 #include "canvasmode_editweldpoint.h"
 #include "canvasmode_eyedropper.h"
 #include "canvasmode_framelinks.h"
+#include "canvasmode_imageimport.h"
 #include "canvasmode_magnifier.h"
 #include "canvasmode_measurements.h"
 #include "canvasmode_nodeedit.h"
@@ -174,6 +175,9 @@
 		case modeLinkFrames:
 		case modeUnlinkFrames:
 			result = new CanvasMode_FrameLinks(view);
+			break;
+		case modeImportImage:
+			result = new CanvasMode_ImageImport(view);
 			break;
 		case modeMagnifier:
 			result = new CanvasMode_Magnifier(view);

Modified: trunk/Scribus/scribus/canvasmode_editarc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/canvasmode_editarc.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editarc.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editarc.cpp Tue Jul 24 22:01:01 2012
@@ -227,7 +227,7 @@
 	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::Selection);
+	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);
@@ -410,28 +410,15 @@
 	QPointF mPoint = item->PoLine.pointQF(0);
 	if ((m_arcPoint == useControlStart) || (m_arcPoint == useControlSweep) || (m_arcPoint == useControlHeight) || (m_arcPoint == useControlWidth))
 	{
+		QTransform bb;
+		bb.scale(item->arcHeight / item->arcWidth, 1.0);
+		QLineF inp = QLineF(QPointF(item->arcWidth / 2.0, item->arcHeight / 2.0), QPointF(item->arcWidth, item->arcHeight / 2.0));
+		double start = inp.angleTo(QLineF(QPointF(item->arcWidth / 2.0, item->arcHeight / 2.0),startPoint));
+		inp.setAngle(start);
+		double end = inp.angleTo(QLineF(QPointF(item->arcWidth / 2.0, item->arcHeight / 2.0),endPoint));
 		double nWidth = mPoint.x() - widthPoint.x();
 		double nHeight = mPoint.y() - heightPoint.y();
-		item->arcWidth = nWidth * 2.0;
-		item->arcHeight = nHeight * 2.0;
-		double nSweep = endAngle - startAngle;
-		if (nSweep < 0)
-			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.closeSubpath();
-		currItem->PoLine.fromQPainterPath(pp);
-		m_doc->AdjustItemSize(currItem);
-		item->arcStartAngle = startAngle;
-		item->arcSweepAngle = endAngle - startAngle;
-		startPoint = currItem->PoLine.pointQF(2);
-		endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 4);
-		centerPoint = currItem->PoLine.pointQF(0);
-		widthPoint = QPointF(centerPoint.x() - item->arcWidth / 2.0, centerPoint.y());
-		heightPoint = QPointF(centerPoint.x(), centerPoint.y() - item->arcHeight / 2.0);
-		startAngle = item->arcStartAngle;
-		endAngle = startAngle + item->arcSweepAngle;
+		applyValues(start,end + start, 2.0 * nHeight, 2.0 * nWidth);
 	}
 	QTransform itemMatrix = currItem->getTransform();
 	m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));

Modified: trunk/Scribus/scribus/canvasmode_editpolygon.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/canvasmode_editpolygon.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editpolygon.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editpolygon.cpp Tue Jul 24 22:01:01 2012
@@ -65,6 +65,7 @@
 	Mxp = Myp = -1;
 	m_blockUpdateFromItem = 0;
 	m_polygonPoint = noPointDefined;
+	trans = NULL;
 }
 
 inline bool CanvasMode_EditPolygon::GetItem(PageItem** pi)
@@ -452,6 +453,8 @@
 	}
 	else
 		m_polygonPoint = noPointDefined;
+	if(m_polygonPoint != noPointDefined)
+		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));
 	m_doc->regionsChanged()->update(path.boundingRect().adjusted(-5, -5, 10, 10));
@@ -503,6 +506,12 @@
 		item->polyOuterCurvature = polyOuterCurvature;
 		item->recalcPath();
 		VectorDialog->setValues(polyCorners, polyFactor, polyUseFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature);
+		if(trans)
+		{
+			trans->commit();
+			delete trans;
+			trans = NULL;
+		}
 	}
 	QPainterPath path = itemMatrix.map(RegularPolygonPath(item->width(), item->height(), polyCorners, polyUseFactor, polyFactor, polyRotation, polyCurvature, polyInnerRot, polyOuterCurvature));
 	m_doc->regionsChanged()->update(path.boundingRect().adjusted(-5, -5, 10, 10));

Modified: trunk/Scribus/scribus/canvasmode_editpolygon.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/canvasmode_editpolygon.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editpolygon.h (original)
+++ trunk/Scribus/scribus/canvasmode_editpolygon.h Tue Jul 24 22:01:01 2012
@@ -33,6 +33,7 @@
 class PageItem;
 class ScribusMainWindow;
 class ScribusView;
+class UndoTransaction;
 
 
 // This class encapsulate the old code for mouse interaction from scribusview.cpp
@@ -88,6 +89,7 @@
 	double polyOuterCurvature;
 	ePolygonPoint m_polygonPoint;
 	PolyVectorDialog *VectorDialog;
+	UndoTransaction *trans;
 
 	int    m_blockUpdateFromItem;
 	void   blockUpdateFromItem(bool block) { if (block) ++m_blockUpdateFromItem; else --m_blockUpdateFromItem; }

Modified: trunk/Scribus/scribus/canvasmode_editspiral.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/canvasmode_editspiral.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editspiral.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_editspiral.cpp Tue Jul 24 22:01:01 2012
@@ -41,6 +41,7 @@
 #include "scribusdoc.h"
 #include "scribusview.h"
 #include "selection.h"
+#include "undomanager.h"
 #include "util.h"
 #include "util_math.h"
 
@@ -49,6 +50,7 @@
 	Mxp = Myp = -1;
 	m_blockUpdateFromItem = 0;
 	m_arcPoint = noPointDefined;
+	trans = NULL;
 }
 
 inline bool CanvasMode_EditSpiral::GetItem(PageItem** pi)
@@ -228,9 +230,18 @@
 {
 	PageItem *currItem = m_doc->m_Selection->itemAt(0);
 	PageItem_Spiral *item = currItem->asSpiral();
+	SimpleState *ss = new SimpleState(Um::EditSpiral, "", Um::IPolygon);
+	ss->set("SPIRAL","spiral");
+	ss->set("OLD_START",item->spiralStartAngle);
+	ss->set("OLD_END",item->spiralEndAngle);
+	ss->set("OLD_FACTOR",item->spiralFactor);
 	item->spiralStartAngle = computeRealAngle(start, true);
 	item->spiralEndAngle = computeRealAngle(end, true);
 	item->spiralFactor = factor;
+	ss->set("NEW_START",item->spiralStartAngle);
+	ss->set("NEW_END",item->spiralEndAngle);
+	ss->set("NEW_FACTOR",item->spiralFactor);
+	undoManager->action(item,ss);
 	item->recalcPath();
 	startPoint = currItem->PoLine.pointQF(0);
 	endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
@@ -292,7 +303,7 @@
 			if (startAngle + deltaAngle >= 0)
 			{
 				startAngle += deltaAngle;
-				item->spiralStartAngle = startAngle;
+				applyValues(startAngle,endAngle,item->spiralFactor);
 				item->recalcPath();
 				startPoint = currItem->PoLine.pointQF(0);
 				m_canvas->displayRealRotHUD(m->globalPos(), startAngle);
@@ -304,7 +315,7 @@
 			if (endAngle + deltaAngle > startAngle)
 			{
 				endAngle += deltaAngle;
-				item->spiralEndAngle = endAngle;
+				applyValues(startAngle,endAngle,item->spiralFactor);
 				item->recalcPath();
 				endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 2);
 				m_canvas->displayRealRotHUD(m->globalPos(), endAngle);
@@ -350,6 +361,8 @@
 		m_arcPoint = useControlEnd;
 	else
 		m_arcPoint = noPointDefined;
+	if(m_arcPoint != noPointDefined)
+		trans = new UndoTransaction(undoManager->beginTransaction(Um::Polygon,Um::IPolygon,Um::EditSpiral,"",Um::IPolygon));
 	m_canvas->m_viewMode.m_MouseButtonPressed = true;
 	qApp->changeOverrideCursor(QCursor(Qt::CrossCursor));
 	m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
@@ -361,6 +374,12 @@
 	m_canvas->resetRenderMode();
 	m->accept();
 	PageItem *currItem = m_doc->m_Selection->itemAt(0);
+	if(trans)
+	{
+		trans->commit();
+		delete trans;
+		trans = NULL;
+	}
 	QTransform itemMatrix = currItem->getTransform();
 	m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-5, -5, 10, 10));
 }

Modified: trunk/Scribus/scribus/canvasmode_editspiral.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/canvasmode_editspiral.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editspiral.h (original)
+++ trunk/Scribus/scribus/canvasmode_editspiral.h Tue Jul 24 22:01:01 2012
@@ -33,6 +33,7 @@
 class PageItem;
 class ScribusMainWindow;
 class ScribusView;
+class UndoTransaction;
 
 
 // This class encapsulate the old code for mouse interaction from scribusview.cpp
@@ -77,6 +78,7 @@
 	double endAngle;
 	eSpiralPoint m_arcPoint;
 	SpiralVectorDialog* VectorDialog;
+	UndoTransaction *trans;
 
 	int    m_blockUpdateFromItem;
 	void   blockUpdateFromItem(bool block) { if (block) ++m_blockUpdateFromItem; else --m_blockUpdateFromItem; }

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Tue Jul 24 22:01:01 2012
@@ -45,6 +45,7 @@
 #include "pageitem_group.h"
 #include "pageitem_regularpolygon.h"
 #include "pageitem_arc.h"
+#include "pageitem_spiral.h"
 #include "pageitem_textframe.h"
 #include "pageitem_latexframe.h"
 #include "prefsmanager.h"
@@ -4864,6 +4865,8 @@
 			restoreImageNbr(ss, isUndo);
 		else if (ss->contains("CHANGE_MODE"))
 			restoreAppMode(ss, isUndo);
+		else if (ss->contains("CONNECT_PATH"))
+			restoreConnectPath(ss, isUndo);
 	}
 	if (!OnMasterPage.isEmpty())
 		m_Doc->setCurrentPage(oldCurrentPage);
@@ -4872,6 +4875,27 @@
 	m_Doc->SnapGuides = SnapGuidesBackup;
 }
 
+void PageItem::restoreConnectPath(SimpleState *state, bool isUndo)
+{
+	ScItemState<QPair<FPointArray, FPointArray> > *is = dynamic_cast<ScItemState<QPair<FPointArray, FPointArray> > *>(state);
+	if(isUndo)
+	{
+		PoLine = is->getItem().first;
+		doc()->AdjustItemSize(this);
+		moveBy(is->getDouble("OLDX") - xPos(),is->getDouble("OLDY") - yPos());
+	}
+	else
+	{
+		PoLine = is->getItem().second;
+		doc()->AdjustItemSize(this);
+		moveBy(is->getDouble("NEWX") - xPos(),is->getDouble("NEWY") - yPos());
+	}
+	OldB2 = width();
+	OldH2 = height();
+	updateClip();
+	ContourLine = PoLine.copy();
+}
+
 bool PageItem::checkGradientUndoRedo(SimpleState *ss, bool isUndo)
 {
 	if (ss->contains("SNAP_TO_PATCH"))
@@ -5180,6 +5204,26 @@
 		doc()->view()->requestMode(state->getInt("OLD"));
 	else
 		doc()->view()->requestMode(state->getInt("NEW"));
+}
+
+void PageItem::restoreSpiral(SimpleState *ss, bool isUndo)
+{
+	PageItem_Spiral *item = asSpiral();
+	if (isUndo)
+	{
+		item->spiralStartAngle = ss->getDouble("OLD_START");
+		item->spiralEndAngle = ss->getDouble("OLD_END");
+		item->spiralFactor = ss->getDouble("OLD_FACTOR");
+	}
+	else
+	{
+		item->spiralStartAngle = ss->getDouble("NEW_START");
+		item->spiralEndAngle = ss->getDouble("NEW_END");
+		item->spiralFactor = ss->getDouble("NEW_FACTOR");
+	}
+	item->recalcPath();
+	update();
+	doc()->changed();
 }
 
 void PageItem::restorePolygon(SimpleState *ss, bool isUndo)

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h (original)
+++ trunk/Scribus/scribus/pageitem.h Tue Jul 24 22:01:01 2012
@@ -1310,6 +1310,8 @@
 	 * @author Riku Leino
 	 */
 	/*@{*/
+	void restoreConnectPath(SimpleState *state, bool isUndo);
+	void restoreSpiral(SimpleState *state, bool isUndo);
 	void restoreAppMode(SimpleState *state, bool isUndo);
 	void restoreArc(SimpleState *state,bool isUndo);
 	void restorePolygon(SimpleState *state,bool isUndo);

Modified: trunk/Scribus/scribus/pageitem_imageframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/pageitem_imageframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_imageframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_imageframe.cpp Tue Jul 24 22:01:01 2012
@@ -440,7 +440,6 @@
 		if (pixm.imgInfo.exifDataValid)
 			actionList << "itemImageInfo";
 		actionList << "itemUpdateImage";
-		actionList << "editClearContents";
 		actionList << "editCopyContents";
 		actionList << "itemToggleInlineImage";
 		if (isRaster)
@@ -449,6 +448,8 @@
 			actionList << "editEditWithImageEditor";
 		}
 	}
+	if(!Pfile.isEmpty())
+		actionList << "editClearContents";
 	actionList << "itemConvertToPolygon";
 	if (doc()->scMW()->contentsBuffer.sourceType==PageItem::ImageFrame)
 	{

Modified: trunk/Scribus/scribus/plugins/tools/pathconnect/pathconnect.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/plugins/tools/pathconnect/pathconnect.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/tools/pathconnect/pathconnect.cpp (original)
+++ trunk/Scribus/scribus/plugins/tools/pathconnect/pathconnect.cpp Tue Jul 24 22:01:01 2012
@@ -28,6 +28,7 @@
 #include "pathconnectdialog.h"
 #include "selection.h"
 #include "scribusdoc.h"
+#include "undomanager.h"
 
 int pathconnect_getPluginAPIVersion()
 {
@@ -130,6 +131,11 @@
 			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);
 			Item1->PoLine = computePath(pointOne, pointTwo, mode, originalPath1, originalPath2);
 			Item1->Frame = false;
 			Item1->ClipEdited = true;
@@ -137,11 +143,16 @@
 			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);
 			Item1->updateClip();
 			Item1->ContourLine = Item1->PoLine.copy();
 			currDoc->m_Selection->removeItem(Item1);
 			currDoc->itemSelection_DeleteItem();
 			currDoc->changed();
+			trans.commit();
 		}
 		else
 		{

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Jul 24 22:01:01 2012
@@ -85,6 +85,7 @@
 
 #include "actionmanager.h"
 #include "canvasmode.h"
+#include "canvasmode_imageimport.h"
 #include "commonstrings.h"
 #include "desaxe/digester.h"
 #include "desaxe/saxXML.h"
@@ -197,6 +198,7 @@
 #include "ui/query.h"
 #include "ui/replacecolors.h"
 #include "ui/sccombobox.h"
+#include "ui/scfilewidget.h"
 #include "ui/scmessagebox.h"
 #include "ui/scrapbookpalette.h"
 #include "ui/scmwmenumanager.h"
@@ -1399,6 +1401,7 @@
 				case modeEditWeldPoint:
 				case modeEyeDropper:
 				case modeImportObject:
+				case modeImportImage:
 				case modePanning:
 					view->requestMode(modeNormal);
 					break;
@@ -4218,26 +4221,22 @@
 				docDir = prefsManager->prefsFile->getContext("dirs")->get("images", prefsDocDir);
 			else
 				docDir = prefsManager->prefsFile->getContext("dirs")->get("images", ".");
-			QString fileName = CFileDialog( docDir, tr("Open"), formatD, "", fdShowPreview | fdExistingFiles);
-			if (!fileName.isEmpty())
-			{
-				prefsManager->prefsFile->getContext("dirs")->set("images", fileName.left(fileName.lastIndexOf("/")));
-				currItem->EmProfile = "";
-				currItem->pixm.imgInfo.isRequest = false;
-				currItem->UseEmbedded = true;
-				currItem->IProfile = doc->cmsSettings().DefaultImageRGBProfile;
-				currItem->IRender = doc->cmsSettings().DefaultIntentImages;
-				qApp->changeOverrideCursor( QCursor(Qt::WaitCursor) );
-				qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
-				doc->loadPict(fileName, currItem, false, true);
-				propertiesPalette->imagePal->displayScaleAndOffset(currItem->imageXScale(), currItem->imageYScale(), currItem->imageXOffset(), currItem->imageYOffset());
-				qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
-				view->DrawNew();
-				emit UpdateRequest(reqColorsUpdate | reqCmsOptionsUpdate);
-				currItem->emitAllToGUI();
-			}
-		}
-		if (currItem->asTextFrame())
+
+			QStringList fileNames;
+			fileNames.clear();
+			CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), docDir, tr("Open"), formatD, fdShowPreview | fdExistingFilesI);
+			if (dia->exec() == QDialog::Accepted)
+				fileNames = dia->fileDialog->selectedFiles();
+			delete dia;
+			//QStringList fileNames = CFileDialog( docDir, tr("Open"), formatD, "", fdShowPreview | fdExistingFiles);
+			if (!fileNames.isEmpty())
+			{
+				prefsManager->prefsFile->getContext("dirs")->set("images", fileNames[0].left(fileNames[0].lastIndexOf("/")));
+				view->requestMode(modeImportImage);
+				dynamic_cast<CanvasMode_ImageImport*>(view->canvasMode())->setImageList(fileNames);
+			}
+		}
+		else if (currItem->asTextFrame())
 		{
 			gtGetText* gt = new gtGetText(doc);
 			ImportSetup impsetup=gt->run();
@@ -6478,7 +6477,7 @@
 			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))
+		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))
 		{
 			SimpleState *ss = new SimpleState(Um::Mode);
 			ss->set("CHANGE_MODE","change_mode");

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue Jul 24 22:01:01 2012
@@ -13588,6 +13588,7 @@
 
 void ScribusDoc::AdjustItemSize(PageItem *currItem, bool includeGroup, bool moveInGroup)
 {
+	undoManager->setUndoEnabled(false);
 	bool siz = currItem->Sizing;
 	currItem->Sizing = false;
 	if ((!(currItem->isGroup() || currItem->isSymbol())) || includeGroup)
@@ -13659,6 +13660,7 @@
 		currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
 	currItem->updateGradientVectors();
 	currItem->Sizing = siz;
+	undoManager->setUndoEnabled(true);
 }
 
 void ScribusDoc::moveGroup(double x, double y, bool fromMP, Selection* customSelection)

Modified: trunk/Scribus/scribus/scribusstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/scribusstructs.h
==============================================================================
--- trunk/Scribus/scribus/scribusstructs.h (original)
+++ trunk/Scribus/scribus/scribusstructs.h Tue Jul 24 22:01:01 2012
@@ -295,6 +295,7 @@
 	modeDrawLine,
 	modeRotation,
 	modeLinkFrames,
+	modeImportImage,
 	modeUnlinkFrames,
 	modeDrawRegularPolygon,
 	modeDrawBezierLine,

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Tue Jul 24 22:01:01 2012
@@ -75,6 +75,7 @@
 #include "canvasgesture.h"
 #include "canvasmode.h"
 #include "canvasmode_objimport.h"
+#include "canvasmode_imageimport.h"
 #include "actionmanager.h"
 #include "commonstrings.h"
 #include "filewatcher.h"
@@ -164,6 +165,7 @@
 	m_groupTransaction(NULL),
 	_isGlobalMode(true),
 	linkAfterDraw(false),
+	ImageAfterDraw(false),
 	m_vhRulerHW(17)
 {
 	setObjectName("s");
@@ -591,9 +593,9 @@
 				 return;
 				 */
 		case submodeLoadPic:         // open GetImage dialog
+			m_ScMW->slotGetContent();
 			appMode = Doc->appMode;
 			m_previousMode = appMode;
-			m_ScMW->slotGetContent();
 			break;
 		case submodeStatusPic:       // open ManageImages dialog
 			appMode = Doc->appMode;
@@ -3817,6 +3819,7 @@
 									chma.scale(-1, 1);
 								if (currItem->imageFlippedV())
 									chma.scale(1, -1);
+								undoManager->setUndoEnabled(false);
 								pts.map(chma);
 								if ((charStyle.effects() & ScStyle_Shadowed) && (charStyle.strokeColor() != CommonStrings::None))
 								{
@@ -3874,7 +3877,6 @@
 								}
 								uint z = Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, currItem->xPos(), currItem->yPos(), currItem->width(), currItem->height(), currItem->lineWidth(), currItem->lineColor(), currItem->fillColor(), true);
 								bb = Doc->Items->at(z);
-								undoManager->setUndoEnabled(false);
 								//bb->setTextFlowsAroundFrame(currItem->textFlowsAroundFrame());
 								//bb->setTextFlowUsesBoundingBox(currItem->textFlowUsesBoundingBox());
 								bb->setTextFlowMode(currItem->textFlowMode());
@@ -4249,6 +4251,18 @@
 			}
 			linkAfterDraw = false;
 		}
+		if (ImageAfterDraw)
+		{
+			//user creates new frame using linking tool
+			PageItem * frame = Doc->m_Selection->itemAt(0);
+			if (frame)
+			{
+				requestMode(modeImportImage);
+				dynamic_cast<CanvasMode_ImageImport*>(canvasMode())->setImage(frame);
+				dynamic_cast<CanvasMode_ImageImport*>(canvasMode())->updateList();
+			}
+			ImageAfterDraw = false;
+		}
 		return true;
 	}
 	else if (obj == widget() && event->type() == QEvent::MouseButtonPress)
@@ -4268,6 +4282,12 @@
 		}
 		else
 			firstFrame = NULL;
+		if(Doc->appMode == modeImportImage && ImageAfterDraw)
+		{
+			//switch to drawing new text frame
+			requestMode(modeDrawImage);
+			m_canvasMode->mousePressEvent(m);
+		}
 		m_canvas->m_viewMode.m_MouseButtonPressed = true;
 		return true;
 	}

Modified: trunk/Scribus/scribus/scribusview.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/scribusview.h
==============================================================================
--- trunk/Scribus/scribus/scribusview.h (original)
+++ trunk/Scribus/scribus/scribusview.h Tue Jul 24 22:01:01 2012
@@ -107,6 +107,7 @@
 	friend class CanvasMode_EditArc;
 	friend class CanvasMode_EditSpiral;
 	friend class CanvasMode_FrameLinks;
+	friend class CanvasMode_ImageImport;
 	friend class CanvasMode_Magnifier;
 	friend class CanvasMode_NodeEdit;
 	friend class CanvasMode_Normal;
@@ -318,6 +319,7 @@
 	UndoTransaction*  m_groupTransaction;
 	bool _isGlobalMode;
 	bool linkAfterDraw;
+	bool ImageAfterDraw;
 
 	double oldItemX;
 	double oldItemY;

Modified: trunk/Scribus/scribus/ui/customfdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/ui/customfdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/customfdialog.cpp (original)
+++ trunk/Scribus/scribus/ui/customfdialog.cpp Tue Jul 24 22:01:01 2012
@@ -380,6 +380,8 @@
 		}
 		if (flags & fdExistingFiles)
 			fileDialog->setFileMode(QFileDialog::ExistingFile);
+		else if (flags & fdExistingFilesI)
+			fileDialog->setFileMode(QFileDialog::ExistingFiles);
 		else
 		{
 			fileDialog->setFileMode(QFileDialog::AnyFile);

Modified: trunk/Scribus/scribus/ui/customfdialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/ui/customfdialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/customfdialog.h (original)
+++ trunk/Scribus/scribus/ui/customfdialog.h Tue Jul 24 22:01:01 2012
@@ -75,7 +75,8 @@
 	fdCompressFile = 4, // Show and handle the "Compress" behaviour and CheckBox (true)
 	fdShowCodecs = 8, // Show and handle text codecs and ComboBox (true)
 	fdDirectoriesOnly = 16, // Show only directories
-	fdHidePreviewCheckBox = 32 // Hide preview Checkbox
+	fdHidePreviewCheckBox = 32, // Hide preview Checkbox
+	fdExistingFilesI = 64 // For multiple files
 } fdFlags;
 
 /*! \brief A Scribus own file dialog.

Modified: trunk/Scribus/scribus/ui/spiralvectordialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/ui/spiralvectordialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/spiralvectordialog.cpp (original)
+++ trunk/Scribus/scribus/ui/spiralvectordialog.cpp Tue Jul 24 22:01:01 2012
@@ -34,7 +34,7 @@
 	connect(startAngle,   SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
 	connect(sweepAngle,   SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
 	connect(arcFactor,   SIGNAL(valueChanged(double)), this, SLOT(changeVectors()));
-	connect(exitButton, SIGNAL(clicked()), this, SIGNAL(endEdit()));
+	connect(exitButton, SIGNAL(clicked()), this, SLOT(accept()));
 	languageChange();
 	resize(minimumSizeHint());
 }

Modified: trunk/Scribus/scribus/undogui.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/undogui.cpp
==============================================================================
--- trunk/Scribus/scribus/undogui.cpp (original)
+++ trunk/Scribus/scribus/undogui.cpp Tue Jul 24 22:01:01 2012
@@ -37,9 +37,9 @@
 #include "scraction.h"
 #include "util_icon.h"
 
-UndoGui::UndoGui(QWidget* parent, const char* name, Qt::WFlags f) : ScrPaletteBase(parent, name, f)
-{
-
+UndoGui::UndoGui(QWidget* parent, const char* name, Qt::WFlags f) : ScDockPalette(parent, name, f)
+{
+	setWindowTitle( tr("Action History"));
 }
 
 /*** UndoWidget ***************************************************************/
@@ -228,9 +228,13 @@
 UndoPalette::UndoPalette(QWidget* parent, const char* name)
 : UndoGui(parent, name)
 {
+	setObjectName(QString::fromLocal8Bit(name));
+	setSizePolicy( QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
+
+	container = new QWidget(this);
 	currentSelection = 0;
 	redoItems = 0;
-	QVBoxLayout* layout = new QVBoxLayout(this);
+	QVBoxLayout* layout = new QVBoxLayout(container);
 	layout->setMargin(5);
 	layout->setSpacing(5);
 	objectBox = new QCheckBox(this);
@@ -255,6 +259,7 @@
 	initialUndoKS = undoButton->shortcut();
 	initialRedoKS = redoButton->shortcut();
 	layout->addLayout(buttonLayout);
+	setWidget(container);
 
 	updateFromPrefs();
 	languageChange();
@@ -306,7 +311,6 @@
 
 void UndoPalette::languageChange()
 {
-	setWindowTitle( tr("Action History"));
 	objectBox->setText( tr("Show Selected Object Only"));
 	undoButton->setText( tr("&Undo"));
 	redoButton->setText( tr("&Redo"));

Modified: trunk/Scribus/scribus/undogui.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/undogui.h
==============================================================================
--- trunk/Scribus/scribus/undogui.h (original)
+++ trunk/Scribus/scribus/undogui.h Tue Jul 24 22:01:01 2012
@@ -28,10 +28,12 @@
 #define UNDOGUI_H
 
 #include <QListWidgetItem>
+#include <QPushButton>
+
 #include "scribusapi.h"
 #include "undoobject.h"
 #include "undostate.h"
-#include "ui/scrpalettebase.h"
+#include "ui/scdockpalette.h"
 
 class QEvent;
 class QMenu;
@@ -54,7 +56,7 @@
  * @author Riku Leino  tsoots at gmail.com
  * @date December 2004
  */
-class SCRIBUS_API UndoGui : public ScrPaletteBase
+class SCRIBUS_API UndoGui : public ScDockPalette
 {
 	Q_OBJECT
 
@@ -256,6 +258,7 @@
 	Q_OBJECT
 
 private:
+	QWidget* container;
 	int currentSelection;
 	int redoItems;
 	QListWidget* undoList;

Modified: trunk/Scribus/scribus/undomanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/undomanager.cpp
==============================================================================
--- trunk/Scribus/scribus/undomanager.cpp (original)
+++ trunk/Scribus/scribus/undomanager.cpp Tue Jul 24 22:01:01 2012
@@ -834,6 +834,7 @@
 
 void UndoManager::languageChange()
 {
+	UndoManager::ConnectPath        = tr("Connect path");
 	UndoManager::AddVGuide          = tr("Add vertical guide");
 	UndoManager::AddHGuide          = tr("Add horizontal guide");
 	UndoManager::DelVGuide          = tr("Remove vertical guide");
@@ -939,6 +940,8 @@
 	UndoManager::LatexFrame         = tr("Render frame");
 	UndoManager::Polygon            = tr("Polygon");
 	UndoManager::EditPolygon        = tr("Edit polygon");
+	UndoManager::EditArc            = tr("Edit arc");
+	UndoManager::EditSpiral         = tr("Edit spiral");
 	UndoManager::BezierCurve        = tr("Bezier curve");
 	UndoManager::Polyline           = tr("Polyline");
 	UndoManager::PathText           = tr("Text on a Path");
@@ -1094,6 +1097,7 @@
 // 	UndoManager::IGetImage        = new QPixmap(iconDir + "u_get_image.png");
 	UndoManager::IMultipleDuplicate = new QPixmap(iconDir + "u_multiple.png");
 }
+QString UndoManager::ConnectPath        = "";
 QString UndoManager::AddVGuide          = "";
 QString UndoManager::AddHGuide          = "";
 QString UndoManager::DelVGuide          = "";
@@ -1204,6 +1208,8 @@
 QString UndoManager::LatexFrame         = "";
 QString UndoManager::Polygon            = "";
 QString UndoManager::EditPolygon        = "";
+QString UndoManager::EditArc            = "";
+QString UndoManager::EditSpiral         = "";
 QString UndoManager::BezierCurve        = "";
 QString UndoManager::Polyline           = "";
 QString UndoManager::PathText           = "";

Modified: trunk/Scribus/scribus/undomanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/undomanager.h
==============================================================================
--- trunk/Scribus/scribus/undomanager.h (original)
+++ trunk/Scribus/scribus/undomanager.h Tue Jul 24 22:01:01 2012
@@ -74,7 +74,7 @@
 	/** @brief Destroys the TransactionState instance */
 	~TransactionState();
 	/** @brief To know if the state is a Transaction */
-	bool isTransaction(){return true;};
+	bool isTransaction(){return true;}
 
 	/**
 	 * @brief Add a new <code>UndoState</code> object to the transaction.
@@ -444,6 +444,7 @@
 	* Strings describing undo actions
 	*/
 	/*@{*/
+	static QString ConnectPath;
 	static QString AddVGuide;
 	static QString AddHGuide;
 	static QString DelVGuide;
@@ -539,6 +540,8 @@
 	static QString ResTyp;
 	static QString Polygon;
 	static QString EditPolygon;
+	static QString EditArc;
+	static QString EditSpiral;
 	static QString BezierCurve;
 	static QString ShowImage;
 	static QString Polyline;

Modified: trunk/Scribus/scribus/undostack.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/undostack.cpp
==============================================================================
--- trunk/Scribus/scribus/undostack.cpp (original)
+++ trunk/Scribus/scribus/undostack.cpp Tue Jul 24 22:01:01 2012
@@ -63,6 +63,16 @@
 					undoActions_.erase(it);
 					break;
 				}
+				else if((*it)->isTransaction())
+				{
+					TransactionState *ts = dynamic_cast<TransactionState*>(*it);
+					if(ts->containsOnly(objectId))
+					{
+						tmpUndoState = *it;
+						undoActions_.erase(it);
+						break;
+					}
+				}
 			}
 		}
 
@@ -93,6 +103,16 @@
 					tmpRedoState = *it;
 					redoActions_.erase(it);
 					break;
+				}
+				else if((*it)->isTransaction())
+				{
+					TransactionState *ts = dynamic_cast<TransactionState*>(*it);
+					if(ts->containsOnly(objectId))
+					{
+						tmpRedoState = *it;
+						redoActions_.erase(it);
+						break;
+					}
 				}
 			}
 		}
@@ -170,14 +190,14 @@
 			{
 				UndoState*  tmp  = *it;
 				TransactionState *ts = dynamic_cast<TransactionState*>(tmp);
-				if (ts && ts->contains(objectId))
-					break;
-				else if (!ts && tmp->undoObject() && 
-				         tmp->undoObject()->getUId() == static_cast<ulong>(objectId))
+				if ((tmp && tmp->undoObject() &&
+						 tmp->undoObject()->getUId() == static_cast<ulong>(objectId)) || (ts && ts->containsOnly(objectId)))
 				{
 					state = tmp;
 					break;
 				}
+				else if (ts && ts->contains(objectId))
+					break;
 			}
 		}
 	}
@@ -198,14 +218,14 @@
 			{
 				UndoState*  tmp  = *it;
 				TransactionState *ts = dynamic_cast<TransactionState*>(tmp);
-				if (ts && ts->contains(objectId))
-					break;
-				else if (!ts && tmp->undoObject() && 
-				         tmp->undoObject()->getUId() == static_cast<ulong>(objectId))
+				if ((tmp && tmp->undoObject() &&
+						 tmp->undoObject()->getUId() == static_cast<ulong>(objectId)) || (ts && ts->containsOnly(objectId)))
 				{
 					state = tmp;
 					break;
 				}
+				else if (ts && ts->contains(objectId))
+					break;
 			}
 		}
 	}

Modified: trunk/Scribus/scribus/undostack.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17735&path=/trunk/Scribus/scribus/undostack.h
==============================================================================
--- trunk/Scribus/scribus/undostack.h (original)
+++ trunk/Scribus/scribus/undostack.h Tue Jul 24 22:01:01 2012
@@ -37,7 +37,7 @@
 class SCRIBUS_API UndoStack
 {
 public:
-    explicit UndoStack(int maxSize = 20);
+	explicit UndoStack(int maxSize = 100);
     ~UndoStack();
 
     /* Used to push a new action to the stack. UndoState in the parameter will then




More information about the scribus-commit mailing list