r19907 by craig - #12020: Properly restore page orientation, plus rename the action and clean some code

scribus-commit scribus-commit at lists.scribus.net
Tue Mar 10 21:01:43 UTC 2015


Author: craig
Date: Tue Mar 10 21:01:43 2015
New Revision: 19907

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19907
Log:
#12020: Properly restore page orientation, plus rename the action and clean some code

Modified:
    trunk/Scribus/scribus/actionmanager.cpp
    trunk/Scribus/scribus/appmodehelper.cpp
    trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp
    trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
    trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribus.h
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/ui/contextmenu.cpp
    trunk/Scribus/scribus/ui/margindialog.h

Modified: trunk/Scribus/scribus/actionmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/actionmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/actionmanager.cpp (original)
+++ trunk/Scribus/scribus/actionmanager.cpp Tue Mar 10 21:01:43 2015
@@ -629,7 +629,7 @@
 	name="pageManageGuides";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 	(*scrActions)["pageManageGuides"]->setToggleAction(true);
-	name="pageManageMargins";
+	name="pageManageProperties";
 	scrActions->insert(name, new ScrAction("", defaultKey(name), mainWindow));
 
 	connect( (*scrActions)["pageInsert"], SIGNAL(triggered()), mainWindow, SLOT(slotNewPageM()) );
@@ -639,7 +639,7 @@
 	connect( (*scrActions)["pageMove"], SIGNAL(triggered()), mainWindow, SLOT(movePage()) );
 	connect( (*scrActions)["pageApplyMasterPage"], SIGNAL(triggered()), mainWindow, SLOT(ApplyMasterPage()) );
 	connect( (*scrActions)["pageCopyToMasterPage"], SIGNAL(triggered()), mainWindow, SLOT(duplicateToMasterPage()) );
-	connect( (*scrActions)["pageManageMargins"], SIGNAL(triggered()), mainWindow, SLOT(changePageMargins()) );
+	connect( (*scrActions)["pageManageProperties"], SIGNAL(triggered()), mainWindow, SLOT(changePageProperties()) );
 }
 
 void ActionManager::initViewMenuActions()
@@ -1629,7 +1629,7 @@
 	(*scrActions)["pageApplyMasterPage"]->setTexts( tr("&Apply Master Page..."));
 	(*scrActions)["pageCopyToMasterPage"]->setTexts( tr("Convert to Master Page..."));
 	(*scrActions)["pageManageGuides"]->setTexts( tr("Manage &Guides..."));
-	(*scrActions)["pageManageMargins"]->setTexts( tr("Manage Page Properties..."));
+	(*scrActions)["pageManageProperties"]->setTexts( tr("Manage Page Properties..."));
 
 	//View Menu
 	(*scrActions)["viewFitInWindow"]->setTexts( tr("&Fit to Height"));
@@ -2265,7 +2265,7 @@
 		<< "pageApplyMasterPage"
 		<< "pageCopyToMasterPage"
 		<< "pageManageGuides"
-		<< "pageManageMargins"
+		<< "pageManageProperties"
 		<< "viewSnapToGrid"
 		<< "viewSnapToGuides"
 		<< "viewSnapToElements";

Modified: trunk/Scribus/scribus/appmodehelper.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/appmodehelper.cpp
==============================================================================
--- trunk/Scribus/scribus/appmodehelper.cpp (original)
+++ trunk/Scribus/scribus/appmodehelper.cpp Tue Mar 10 21:01:43 2015
@@ -1430,7 +1430,7 @@
 	(*a_scrActions)["pageApplyMasterPage"]->setEnabled(true);
 	(*a_scrActions)["pageCopyToMasterPage"]->setEnabled(true);
 	(*a_scrActions)["pageManageGuides"]->setEnabled(true);
-	(*a_scrActions)["pageManageMargins"]->setEnabled(true);
+	(*a_scrActions)["pageManageProperties"]->setEnabled(true);
 }
 
 void AppModeHelper::mainWindowSwitchWin(ScribusDoc *doc)
@@ -1492,7 +1492,7 @@
 		(*a_scrActions)["pageApplyMasterPage"]->setEnabled(true);
 		(*a_scrActions)["pageCopyToMasterPage"]->setEnabled(true);
 		(*a_scrActions)["pageManageGuides"]->setEnabled(true);
-		(*a_scrActions)["pageManageMargins"]->setEnabled(true);
+		(*a_scrActions)["pageManageProperties"]->setEnabled(true);
 
 		(*a_scrActions)["fileSaveAs"]->setEnabled(true);
 		(*a_scrActions)["fileCollect"]->setEnabled(true);
@@ -1585,7 +1585,7 @@
 	(*a_scrActions)["pageImport"]->setEnabled(false);
 	(*a_scrActions)["pageInsert"]->setEnabled(false);
 	(*a_scrActions)["pageManageGuides"]->setEnabled(false);
-	(*a_scrActions)["pageManageMargins"]->setEnabled(false);
+	(*a_scrActions)["pageManageProperties"]->setEnabled(false);
 	(*a_scrActions)["pageMove"]->setEnabled(false);
 	(*a_scrActions)["toolsCopyProperties"]->setEnabled(false);
 	(*a_scrActions)["toolsEditContents"]->setEnabled(false);
@@ -1717,7 +1717,7 @@
 	(*a_scrActions)["pageApplyMasterPage"]->setEnabled(false);
 	(*a_scrActions)["pageCopyToMasterPage"]->setEnabled(false);
 	(*a_scrActions)["pageManageGuides"]->setEnabled(false);
-	(*a_scrActions)["pageManageMargins"]->setEnabled(false);
+	(*a_scrActions)["pageManageProperties"]->setEnabled(false);
 	(*a_scrActions)["editUndoAction"]->setEnabled(false);
 	(*a_scrActions)["editRedoAction"]->setEnabled(false);
 	(*a_scrActions)["editCut"]->setEnabled(false);

Modified: trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/cgm/importcgm.cpp Tue Mar 10 21:01:43 2015
@@ -3326,7 +3326,7 @@
 			else
 				m_Doc->setPageOrientation(0);
 			m_Doc->setPageSize("Custom");
-			m_Doc->changePageMargins(0, 0, 0, 0, height, width, height, width, m_Doc->pageOrientation(), m_Doc->pageSize(), m_Doc->currentPage()->pageNr(), 0);
+			m_Doc->changePageProperties(0, 0, 0, 0, height, width, height, width, m_Doc->pageOrientation(), m_Doc->pageSize(), m_Doc->currentPage()->pageNr(), 0);
 		}
 		else
 		{

Modified: trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/drw/importdrw.cpp Tue Mar 10 21:01:43 2015
@@ -791,7 +791,7 @@
 				else
 					m_Doc->setPageOrientation(0);
 				m_Doc->setPageSize("Custom");
-				m_Doc->changePageMargins(0, 0, 0, 0, docHeight, docWidth, docHeight, docWidth, m_Doc->pageOrientation(), m_Doc->pageSize(), m_Doc->currentPage()->pageNr(), 0);
+				m_Doc->changePageProperties(0, 0, 0, 0, docHeight, docWidth, docHeight, docWidth, m_Doc->pageOrientation(), m_Doc->pageSize(), m_Doc->currentPage()->pageNr(), 0);
 				cmdText = QString("DRW Page  Width %1  Height %2").arg(docWidth).arg(docHeight);
 			}
 			break;

Modified: trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/wpg/importwpg.cpp Tue Mar 10 21:01:43 2015
@@ -89,7 +89,7 @@
 		else
 			m_Doc->setPageOrientation(0);
 		m_Doc->setPageSize("Custom");
-		m_Doc->changePageMargins(0, 0, 0, 0, 72 * height, 72 * width, 72 * height, 72 * width, m_Doc->pageOrientation(), m_Doc->pageSize(), m_Doc->currentPage()->pageNr(), 0);
+		m_Doc->changePageProperties(0, 0, 0, 0, 72 * height, 72 * width, 72 * height, 72 * width, m_Doc->pageOrientation(), m_Doc->pageSize(), m_Doc->currentPage()->pageNr(), 0);
 	}
 	firstLayer = true;
 }

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Mar 10 21:01:43 2015
@@ -1036,7 +1036,7 @@
 	scrMenuMgr->addMenuItemString("pageApplyMasterPage", "Page");
 	scrMenuMgr->addMenuItemString("pageCopyToMasterPage", "Page");
 	scrMenuMgr->addMenuItemString("pageManageGuides", "Page");
-	scrMenuMgr->addMenuItemString("pageManageMargins", "Page");
+	scrMenuMgr->addMenuItemString("pageManageProperties", "Page");
 	scrMenuMgr->addMenuItemString("SEPARATOR", "Page");
 	scrMenuMgr->addMenuItemString("viewSnapToGrid", "Page");
 	scrMenuMgr->addMenuItemString("viewSnapToGuides", "Page");
@@ -6068,7 +6068,7 @@
 	delete dia;
 }
 
-void ScribusMainWindow::changePageMargins()
+void ScribusMainWindow::changePageProperties()
 {
 	if (!HaveDoc)
 		return;
@@ -6079,28 +6079,17 @@
 	if (dia->exec())
 	{
 		int orientation = dia->getPageOrientation();
-		double ph = dia->getPageHeight();
-		double pw = dia->getPageWidth();
-		QString sizeName = dia->getpPrefsPageSizeName();
-		if (doc->masterPageMode())
-		{
-			int lp=0;
-			if (doc->pagePositioning() != singlePage)
-				lp = dia->pageOrder();
-			doc->changePageMargins(dia->top(), dia->bottom(),
-								   dia->left(), dia->right(),
-								   ph, pw, ph, pw, orientation,
-								   sizeName, dia->getMarginPreset(), dia->getMoveObjects(), doc->currentPage()->pageNr(), lp);
-		}
-		else
-		{
-			doc->changePageMargins(dia->top(), dia->bottom(),
-								   dia->left(), dia->right(),
-								   ph, pw, ph, pw, orientation,
-								   sizeName, dia->getMarginPreset(), dia->getMoveObjects(), doc->currentPage()->pageNr());
-			if (dia->masterPage() != currPageMasterPageName)
-				Apply_MasterPage(dia->masterPage(), doc->currentPage()->pageNr());
-		}
+		double pageHeight = dia->getPageHeight();
+		double pageWidth = dia->getPageWidth();
+		QString pageSizeName = dia->getpPrefsPageSizeName();
+		int lp=0;
+		if (doc->masterPageMode() && doc->pagePositioning() != singlePage)
+			lp = dia->pageOrder();
+		doc->changePageProperties(dia->top(), dia->bottom(), dia->left(), dia->right(),
+							   pageHeight, pageWidth, pageHeight, pageWidth, orientation,
+							   pageSizeName, dia->getMarginPreset(), dia->getMoveObjects(), doc->currentPage()->pageNr(), lp);
+		if (!doc->masterPageMode() && dia->masterPage() != currPageMasterPageName)
+			Apply_MasterPage(dia->masterPage(), doc->currentPage()->pageNr());
 		doc->updateEndnotesFrames();
 	}
 	delete dia;
@@ -7676,6 +7665,8 @@
 
 void ScribusMainWindow::restoreAddPage(SimpleState *state, bool isUndo)
 {
+	if (!HaveDoc)
+		return;
 	int wo    = state->getInt("PAGE");
 	int where = state->getInt("WHERE");
 	int count = state->getInt("COUNT");
@@ -7722,7 +7713,7 @@
 			undoManager->replaceObject(doc->Pages->at(i)->getUId(), duo);
 			state->set(QString("Page%1").arg(i), static_cast<uint>(did));
 		}
-		if (HaveDoc && doc->appMode == modeEditClip)
+		if (doc->appMode == modeEditClip)
 			view->requestMode(submodeEndNodeEdit);
 		view->Deselect(true);
 		deletePage(delFrom, delTo);

Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Tue Mar 10 21:01:43 2015
@@ -420,7 +420,7 @@
 	/** \brief Verschiebt Seiten */
 	void movePage();
 	void copyPage();
-	void changePageMargins();
+	void changePageProperties();
 	/*!
 	\author Craig Bradney
 	\date Sun 30 Jan 2005

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue Mar 10 21:01:43 2015
@@ -1880,24 +1880,7 @@
 		else if (ss->contains("LEVEL_TOP"))
 			restoreLevelBottom(ss,!isUndo);
 		else if (ss->contains("PAGE_CHANGEPROPS"))
-		{
-			if (isUndo)
-			{
-				changePageMargins(ss->getDouble("OLD_PAGE_INITIALTOP"), ss->getDouble("OLD_PAGE_INITIALBOTTOM"),
-						ss->getDouble("OLD_PAGE_INITIALLEFT"), ss->getDouble("OLD_PAGE_INITIALRIGHT"),
-						ss->getDouble("OLD_PAGE_INITIALHEIGHT"), ss->getDouble("OLD_PAGE_INITIALWIDTH"),
-						ss->getDouble("OLD_PAGE_HEIGHT"), ss->getDouble("OLD_PAGE_WIDTH"), ss->getInt("OLD_PAGE_ORIENTATION"),
-						ss->get("OLD_PAGE_SIZE"), ss->getInt("OLD_PAGE_MARGINPRESET"), ss->getBool("OLD_PAGE_MOVEOBJECTS"), ss->getInt("PAGE_NUM"), ss->getInt("OLD_PAGE_TYPE"));
-			}
-			else
-			{
-				changePageMargins(ss->getDouble("NEW_PAGE_INITIALTOP"), ss->getDouble("NEW_PAGE_INITIALBOTTOM"),
-						ss->getDouble("NEW_PAGE_INITIALLEFT"), ss->getDouble("NEW_PAGE_INITIALRIGHT"),
-						ss->getDouble("NEW_PAGE_INITIALHEIGHT"), ss->getDouble("NEW_PAGE_INITIALWIDTH"),
-						ss->getDouble("NEW_PAGE_HEIGHT"), ss->getDouble("NEW_PAGE_WIDTH"), ss->getInt("NEW_PAGE_ORIENTATION"),
-						ss->get("NEW_PAGE_SIZE"), ss->getInt("NEW_PAGE_MARGINPRESET"), ss->getBool("OLD_PAGE_MOVEOBJECTS"), ss->getInt("PAGE_NUM"), ss->getInt("NEW_PAGE_TYPE"));
-			}
-		}
+			restoreChangePageProperties(ss,isUndo);
 		else if (ss->contains("DELETE_FRAMETEXT"))
 		{
 			PageItem * nF = getItemFromName(ss->get("noteframeName"));
@@ -2379,6 +2362,35 @@
 	m_View->reformPages();
 }
 
+void ScribusDoc::restoreChangePageProperties(SimpleState* state, bool isUndo)
+{
+	bool oldMPMode  = masterPageMode();
+	ScPage* oldPage = currentPage();
+
+	setMasterPageMode(state->getBool("MASTER_PAGE_MODE"));
+	setCurrentPage(Pages->at(state->getInt("PAGE_NUM")));
+	if (isUndo)
+	{
+		//qDebug()<<"undo setting orientation to"<<state->getInt("OLD_PAGE_ORIENTATION");
+		changePageProperties(state->getDouble("OLD_PAGE_INITIALTOP"), state->getDouble("OLD_PAGE_INITIALBOTTOM"),
+				state->getDouble("OLD_PAGE_INITIALLEFT"), state->getDouble("OLD_PAGE_INITIALRIGHT"),
+				state->getDouble("OLD_PAGE_INITIALHEIGHT"), state->getDouble("OLD_PAGE_INITIALWIDTH"),
+				state->getDouble("OLD_PAGE_HEIGHT"), state->getDouble("OLD_PAGE_WIDTH"), state->getInt("OLD_PAGE_ORIENTATION"),
+				state->get("OLD_PAGE_SIZE"), state->getInt("OLD_PAGE_MARGINPRESET"), state->getBool("OLD_PAGE_MOVEOBJECTS"), state->getInt("PAGE_NUM"), state->getInt("OLD_PAGE_TYPE"));
+	}
+	else
+	{
+		//qDebug()<<"redo setting orientation to"<<state->getInt("NEW_PAGE_ORIENTATION");
+		changePageProperties(state->getDouble("NEW_PAGE_INITIALTOP"), state->getDouble("NEW_PAGE_INITIALBOTTOM"),
+				state->getDouble("NEW_PAGE_INITIALLEFT"), state->getDouble("NEW_PAGE_INITIALRIGHT"),
+				state->getDouble("NEW_PAGE_INITIALHEIGHT"), state->getDouble("NEW_PAGE_INITIALWIDTH"),
+				state->getDouble("NEW_PAGE_HEIGHT"), state->getDouble("NEW_PAGE_WIDTH"), state->getInt("NEW_PAGE_ORIENTATION"),
+				state->get("NEW_PAGE_SIZE"), state->getInt("NEW_PAGE_MARGINPRESET"), state->getBool("OLD_PAGE_MOVEOBJECTS"), state->getInt("PAGE_NUM"), state->getInt("NEW_PAGE_TYPE"));
+	}
+	setMasterPageMode(oldMPMode);
+	setCurrentPage(oldPage);
+}
+
 void ScribusDoc::restoreGrouping(SimpleState *state, bool isUndo)
 {
 	double x, y, w, h;
@@ -4964,7 +4976,7 @@
 }
 
 
-bool ScribusDoc::changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double height, const double width, const int orientation, const QString& pageSize, const int marginPreset, const bool moveObjects, const int pageNumber, const int pageType)
+bool ScribusDoc::changePageProperties(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double height, const double width, const int orientation, const QString& pageSize, const int marginPreset, const bool moveObjects, const int pageNumber, const int pageType)
 {
 	bool retVal=true;
 	if (pageNumber==-1)
@@ -5009,6 +5021,7 @@
 				ss->set("NEW_PAGE_SIZE", pageSize);
 				ss->set("NEW_PAGE_TYPE", pageType);
 				ss->set("NEW_PAGE_MARGINPRESET", marginPreset);
+				ss->set("MASTER_PAGE_MODE", masterPageMode());
 				undoManager->action(this, ss);
 			}
 			//set the current page's values

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Tue Mar 10 21:01:43 2015
@@ -756,6 +756,7 @@
 	void restoreMovePage(SimpleState *state, bool isUndo);
 	void restoreSwapPage(SimpleState *state, bool isUndo);
 	void restoreAddMasterPage(SimpleState *state, bool isUndo);
+	void restoreChangePageProperties(SimpleState *state, bool isUndo);
 	/**
 	 * @brief Undo function for grouping/ungrouping
 	 */
@@ -772,7 +773,7 @@
 	/**
 	 * @brief Set the page margins. Current code uses current page only, also provide a (currently, TODO) option for this.
 	 */
-	bool changePageMargins(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double Height, const double width, const int orientation, const QString& pageSize, const int marginPreset, const bool moveObjects, const int pageNumber=-1, const int pageType = 0);
+	bool changePageProperties(const double initialTop, const double initialBottom, const double initialLeft, const double initialRight, const double initialHeight, const double initialWidth, const double Height, const double width, const int orientation, const QString& pageSize, const int marginPreset, const bool moveObjects, const int pageNumber=-1, const int pageType = 0);
 	/**
 	 * @brief Recalculate the colors after CMS settings change. Update the items in the doc accordingly.
 	 */

Modified: trunk/Scribus/scribus/ui/contextmenu.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/ui/contextmenu.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/contextmenu.cpp (original)
+++ trunk/Scribus/scribus/ui/contextmenu.cpp Tue Mar 10 21:01:43 2015
@@ -601,7 +601,7 @@
 		addSeparator();
 		addAction(m_ScMW->scrActions["pageApplyMasterPage"]);
 		addAction(m_ScMW->scrActions["pageManageGuides"]);
-		addAction(m_ScMW->scrActions["pageManageMargins"]);
+		addAction(m_ScMW->scrActions["pageManageProperties"]);
 		if (m_ScMW->scrActions["pageDelete"]->isEnabled())
 		{
 			addSeparator();

Modified: trunk/Scribus/scribus/ui/margindialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19907&path=/trunk/Scribus/scribus/ui/margindialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/margindialog.h (original)
+++ trunk/Scribus/scribus/ui/margindialog.h Tue Mar 10 21:01:43 2015
@@ -24,7 +24,7 @@
 class ScribusDoc;
 
 /*! \brief A dialog to setup the existing document margins.
-In modal mode called from void ScribusMainWindow::changePageMargins() */
+In modal mode called from void ScribusMainWindow::changePageProperties() */
 class SCRIBUS_API MarginDialog : public QDialog
 {
 	Q_OBJECT




More information about the scribus-commit mailing list