r22415 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Mon Feb 26 18:34:43 UTC 2018


Author: jghali
Date: Mon Feb 26 18:34:43 2018
New Revision: 22415

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22415
Log:
#15173: Switching between documents resets guides

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

Modified: trunk/Scribus/scribus/ui/guidemanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22415&path=/trunk/Scribus/scribus/ui/guidemanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/guidemanager.cpp	(original)
+++ trunk/Scribus/scribus/ui/guidemanager.cpp	Mon Feb 26 18:34:43 2018
@@ -22,6 +22,8 @@
  *																	   *
  ***************************************************************************/
 
+#include <QSignalBlocker>
+
 #include "guidemanager.h"
 
 #include "commonstrings.h"
@@ -111,11 +113,19 @@
 
 void GuideManager::setDoc(ScribusDoc* doc)
 {
+	if (m_Doc && (m_Doc != doc))
+	{
+		if (currentPage && (currentPage->doc() == m_Doc))
+			storePageValues(currentPage);
+		currentPage = 0;
+	}
+
 	m_Doc = doc;
 	if (m_Doc)
 	{
-		docUnitIndex = m_Doc->unitIndex();
-		suffix = unitGetSuffixFromIndex(docUnitIndex);
+		int oldUnitIndex = docUnitIndex;
+		if (oldUnitIndex != docUnitIndex)
+			unitChange();
 	}
 
 	qobject_cast<GuidesHDelegate*>(horizontalView->itemDelegateForColumn(0))->setDoc(doc);
@@ -201,9 +211,14 @@
 	if (!page || !m_Doc)
 		return;
 
+	// Handle case where page to store values from does not belong
+	// to current doc, eg. when switching between documents
+	ScribusDoc* doc = page->doc();
+	int unitIndex   = doc->unitIndex();
+
 	double gapValue = 0.0;
 	if (horizontalAutoGapCheck->isChecked())
-		gapValue = value2pts(horizontalAutoGapSpin->value(), docUnitIndex);
+		gapValue = value2pts(horizontalAutoGapSpin->value(), unitIndex);
 	page->guides.setHorizontalAutoGap(gapValue);
 	page->guides.setHorizontalAutoCount(horizontalAutoCountSpin->value());
 	page->guides.setHorizontalAutoRefer(horizontalRefer());
@@ -211,7 +226,7 @@
 
 	gapValue = 0.0;
 	if (verticalAutoGapCheck->isChecked())
-		gapValue = value2pts(verticalAutoGapSpin->value(), docUnitIndex);
+		gapValue = value2pts(verticalAutoGapSpin->value(), unitIndex);
 	page->guides.setVerticalAutoGap(gapValue);
 	page->guides.setVerticalAutoCount(verticalAutoCountSpin->value());
 	page->guides.setVerticalAutoRefer(verticalRefer());
@@ -237,12 +252,15 @@
 {
 	if (!m_Doc)
 		return;
+
 	// a little bit magic to get Verticals (unit) into group boxes
 	horizontalGroupBox->setTitle(horizontalGroupBox->title().remove(" ("+suffix.trimmed()+")"));
 	verticalGroupBox->setTitle(verticalGroupBox->title().remove(" ("+suffix.trimmed()+")"));
 	docUnitIndex = m_Doc->unitIndex();
 	int docUnitDecimals = unitGetPrecisionFromIndex(docUnitIndex);
 
+	QSignalBlocker horizontalAutoGapSpinBlock(horizontalAutoGapSpin);
+	QSignalBlocker verticalAutoGapSpinBlock(verticalAutoGapSpin);
 	suffix = unitGetSuffixFromIndex(docUnitIndex);
 	horizontalAutoGapSpin->setNewUnit(docUnitIndex);
 	verticalAutoGapSpin->setNewUnit(docUnitIndex);
@@ -534,16 +552,21 @@
 {
 	GuideManagerCore guides;
 
+	// Handle case where page to store values from does not belong
+	// to current doc, eg. when switching between documents
+	ScribusDoc* doc = page->doc();
+	int unitIndex = doc->unitIndex();
+
 	double gapValue = 0.0;
 	if (horizontalAutoGapCheck->isChecked())
-		gapValue = value2pts(horizontalAutoGapSpin->value(), docUnitIndex);
+		gapValue = value2pts(horizontalAutoGapSpin->value(), unitIndex);
 	guides.setHorizontalAutoGap(gapValue);
 	guides.setHorizontalAutoCount(horizontalAutoCountSpin->value());
 	guides.setHorizontalAutoRefer(horizontalRefer());
 
 	gapValue = 0.0;
 	if (verticalAutoGapCheck->isChecked())
-		gapValue = value2pts(verticalAutoGapSpin->value(), docUnitIndex);
+		gapValue = value2pts(verticalAutoGapSpin->value(), unitIndex);
 	guides.setVerticalAutoGap(gapValue);
 	guides.setVerticalAutoCount(verticalAutoCountSpin->value());
 	guides.setVerticalAutoRefer(verticalRefer());
@@ -555,16 +578,21 @@
 {
 	GuideManagerCore guides;
 
+	// Handle case where page to store values from does not belong
+	// to current doc, eg. when switching between documents
+	ScribusDoc* doc = page->doc();
+	int unitIndex = doc->unitIndex();
+
 	double gapValue = 0.0;
 	if (horizontalAutoGapCheck->isChecked())
-		gapValue = value2pts(horizontalAutoGapSpin->value(), docUnitIndex);
+		gapValue = value2pts(horizontalAutoGapSpin->value(), unitIndex);
 	guides.setHorizontalAutoGap(gapValue);
 	guides.setHorizontalAutoCount(horizontalAutoCountSpin->value());
 	guides.setHorizontalAutoRefer(horizontalRefer());
 
 	gapValue = 0.0;
 	if (verticalAutoGapCheck->isChecked())
-		gapValue = value2pts(verticalAutoGapSpin->value(), docUnitIndex);
+		gapValue = value2pts(verticalAutoGapSpin->value(), unitIndex);
 	guides.setVerticalAutoGap(gapValue);
 	guides.setVerticalAutoCount(verticalAutoCountSpin->value());
 	guides.setVerticalAutoRefer(verticalRefer());




More information about the scribus-commit mailing list