r21905 by jghali - fix bad view positioning after importing patterns via "Colors & Fill" dialog

scribus-commit scribus-commit at lists.scribus.net
Fri Apr 14 22:53:01 UTC 2017


Author: jghali
Date: Fri Apr 14 22:53:01 2017
New Revision: 21905

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21905
Log:
fix bad view positioning after importing patterns via "Colors & Fill" dialog

Modified:
    trunk/Scribus/scribus/ui/paintmanager.cpp

Modified: trunk/Scribus/scribus/ui/paintmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21905&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp	(original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp	Fri Apr 14 22:53:01 2017
@@ -56,6 +56,7 @@
 #include "scpainter.h"
 #include "scpaths.h"
 #include "scribus.h"
+#include "scribusview.h"
 #include "scribusXml.h"
 #include "sctextstream.h"
 #include "ui/customfdialog.h"
@@ -1186,37 +1187,35 @@
 			PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
 			QString wdir = dirs->get("patterns", ".");
 			CustomFDialog dia(this, wdir, tr("Open"), allFormats, fdHidePreviewCheckBox | fdExistingFiles | fdDisableOk);
-			if (dia.exec() == QDialog::Accepted)
-				fileName = dia.selectedFile();
-			else
+			if (dia.exec() != QDialog::Accepted)
 				return;
-			if (!fileName.isEmpty())
-			{
-				qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
-				PrefsManager::instance()->prefsFile->getContext("dirs")->set("patterns", fileName.left(fileName.lastIndexOf("/")));
-				QFileInfo fi(fileName);
-				if ((fi.suffix().toLower() == "sce") || (!imgFormats.contains(fi.suffix().toLower())))
-				{
-					loadVectors(fileName);
-				}
-				else
-				{
-					QString patNam = fi.baseName().trimmed().simplified().replace(" ", "_");
-					ScPattern pat = ScPattern();
-					pat.setDoc(m_doc);
-					pat.setPattern(fileName);
-					if (!dialogPatterns.contains(patNam))
-					{
-						dialogPatterns.insert(patNam, pat);
-						origNamesPatterns.insert(patNam, patNam);
-					}
-				}
-				updateColorList();
-				updateGradientList();
-				updatePatternList();
-				itemSelected(0);
-				qApp->restoreOverrideCursor();
-			}
+			fileName = dia.selectedFile();
+			if (fileName.isEmpty())
+				return;
+			qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
+			PrefsManager::instance()->prefsFile->getContext("dirs")->set("patterns", fileName.left(fileName.lastIndexOf("/")));
+			QFileInfo fi(fileName);
+			if ((fi.suffix().toLower() == "sce") || (!imgFormats.contains(fi.suffix().toLower())))
+			{
+				loadVectors(fileName);
+			}
+			else
+			{
+				QString patNam = fi.baseName().trimmed().simplified().replace(" ", "_");
+				ScPattern pat = ScPattern();
+				pat.setDoc(m_doc);
+				pat.setPattern(fileName);
+				if (!dialogPatterns.contains(patNam))
+				{
+					dialogPatterns.insert(patNam, pat);
+					origNamesPatterns.insert(patNam, patNam);
+				}
+			}
+			updateColorList();
+			updateGradientList();
+			updatePatternList();
+			itemSelected(0);
+			qApp->restoreOverrideCursor();
 		}
 	}
 }
@@ -1301,6 +1300,13 @@
 
 void PaintManagerDialog::loadVectors(QString data)
 {
+	int storedPageNum = m_doc->currentPageNumber();
+	int storedContentsX = m_doc->view()->contentsX();
+	int storedContentsY = m_doc->view()->contentsY();
+	double storedViewScale = m_doc->view()->scale();
+	FPoint stored_minCanvasCoordinate = m_doc->minCanvasCoordinate;
+	FPoint stored_maxCanvasCoordinate = m_doc->maxCanvasCoordinate;
+
 	m_doc->PageColors = m_colorList;
 	m_doc->docGradients = dialogGradients;
 	UndoManager::instance()->setUndoEnabled(false);
@@ -1408,6 +1414,12 @@
 	m_colorList = m_doc->PageColors;
 	dialogGradients = m_doc->docGradients;
 	UndoManager::instance()->setUndoEnabled(true);
+
+	m_doc->minCanvasCoordinate = stored_minCanvasCoordinate;
+	m_doc->maxCanvasCoordinate = stored_maxCanvasCoordinate;
+	m_doc->view()->setScale(storedViewScale);
+	m_doc->setCurrentPage(m_doc->DocPages.at(storedPageNum));
+	m_doc->view()->setContentsPos(static_cast<int>(storedContentsX * storedViewScale), static_cast<int>(storedContentsY * storedViewScale));
 }
 
 bool PaintManagerDialog::isMandatoryColor(QString colorName)




More information about the scribus-commit mailing list