r17517 by jghali - fix some issues in page palette when switching between documents

scribus-commit scribus-commit at lists.scribus.net
Sun May 20 00:06:30 UTC 2012


Author: jghali
Date: Sun May 20 00:06:30 2012
New Revision: 17517

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17517
Log:
fix some issues in page palette when switching between documents

Modified:
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribuswin.cpp
    trunk/Scribus/scribus/scribuswin.h
    trunk/Scribus/scribus/ui/pagepalette.cpp
    trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17517&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sun May 20 00:06:30 2012
@@ -2180,24 +2180,7 @@
 	alignDistributePalette->setDoc(doc);
 	if (!doc->isLoading())
 	{
-//		scanDocument();
-//		docCheckerPalette->buildErrorList(doc);
 		SwitchWin();
-		QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
-		ScribusWin* swin;
-		for ( int i = 0; i < static_cast<int>(windows.count()); ++i )
-		{
-			swin = dynamic_cast<ScribusWin *>(windows.at(i)->widget());
-			if (swin)
-			{
-				if (swin==ActWin && doc->masterPageMode())
-					swin->setMasterPagesPaletteShown(true);
-				else
-					swin->setMasterPagesPaletteShown(false);
-			}
-		}
-		//if (doc->masterPageMode())
-		//	ActWin->setMasterPagesPaletteShown(true);
 		view->requestMode(doc->appMode);
 	}
 	view->setFocus();
@@ -8588,50 +8571,50 @@
 
 void ScribusMainWindow::manageMasterPages(QString temp)
 {
-	if (HaveDoc)
-	{
-		view->Deselect(true);
-
-		if (doc->masterPageMode())
-		{
-			pagePalette->startMasterPageMode(temp);
-			return;
-		}
-
-		storedPageNum = doc->currentPageNumber();
-		storedViewXCoor = view->contentsX();
-		storedViewYCoor = view->contentsY();
-		storedViewScale = view->scale();
-
+	if (!HaveDoc)
+		return;
+
+	view->Deselect(true);
+
+	if (doc->masterPageMode())
+	{
 		pagePalette->startMasterPageMode(temp);
-
-		scrActions["pageInsert"]->setEnabled(false);
-		scrActions["pageImport"]->setEnabled(false);
-		scrActions["pageDelete"]->setEnabled(false);
-		scrActions["pageCopy"]->setEnabled(false);
-		scrActions["pageMove"]->setEnabled(false);
-		scrActions["pageApplyMasterPage"]->setEnabled(false);
-		scrActions["pageCopyToMasterPage"]->setEnabled(false);
-		scrActions["editMasterPages"]->setEnabled(false);
-		scrActions["fileNew"]->setEnabled(false);
-		scrActions["fileNewFromTemplate"]->setEnabled(false);
-		scrActions["fileOpen"]->setEnabled(false);
-		scrActions["fileClose"]->setEnabled(false);
-		scrMenuMgr->setMenuEnabled("FileOpenRecent", false);
-		scrActions["fileRevert"]->setEnabled(false);
-		scrActions["fileDocSetup150"]->setEnabled(false);
-		scrActions["filePrint"]->setEnabled(false);
-		scrActions["PrintPreview"]->setEnabled(false);
-		scrActions["toolsPDFPushButton"]->setEnabled(false);
-		scrActions["toolsPDFTextField"]->setEnabled(false);
-		scrActions["toolsPDFCheckBox"]->setEnabled(false);
-		scrActions["toolsPDFComboBox"]->setEnabled(false);
-		scrActions["toolsPDFListBox"]->setEnabled(false);
-		scrActions["toolsPDFAnnotText"]->setEnabled(false);
+		return;
+	}
+
+	storedPageNum = doc->currentPageNumber();
+	storedViewXCoor = view->contentsX();
+	storedViewYCoor = view->contentsY();
+	storedViewScale = view->scale();
+
+	pagePalette->startMasterPageMode(temp);
+
+	scrActions["pageInsert"]->setEnabled(false);
+	scrActions["pageImport"]->setEnabled(false);
+	scrActions["pageDelete"]->setEnabled(false);
+	scrActions["pageCopy"]->setEnabled(false);
+	scrActions["pageMove"]->setEnabled(false);
+	scrActions["pageApplyMasterPage"]->setEnabled(false);
+	scrActions["pageCopyToMasterPage"]->setEnabled(false);
+	scrActions["editMasterPages"]->setEnabled(false);
+	scrActions["fileNew"]->setEnabled(false);
+	scrActions["fileNewFromTemplate"]->setEnabled(false);
+	scrActions["fileOpen"]->setEnabled(false);
+	scrActions["fileClose"]->setEnabled(false);
+	scrMenuMgr->setMenuEnabled("FileOpenRecent", false);
+	scrActions["fileRevert"]->setEnabled(false);
+	scrActions["fileDocSetup150"]->setEnabled(false);
+	scrActions["filePrint"]->setEnabled(false);
+	scrActions["PrintPreview"]->setEnabled(false);
+	scrActions["toolsPDFPushButton"]->setEnabled(false);
+	scrActions["toolsPDFTextField"]->setEnabled(false);
+	scrActions["toolsPDFCheckBox"]->setEnabled(false);
+	scrActions["toolsPDFComboBox"]->setEnabled(false);
+	scrActions["toolsPDFListBox"]->setEnabled(false);
+	scrActions["toolsPDFAnnotText"]->setEnabled(false);
 #ifdef HAVE_OSG
-		scrActions["toolsPDFAnnot3D"]->setEnabled(false);
+	scrActions["toolsPDFAnnot3D"]->setEnabled(false);
 #endif
-	}
 }
 
 void ScribusMainWindow::manageMasterPagesEnd()

Modified: trunk/Scribus/scribus/scribuswin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17517&path=/trunk/Scribus/scribus/scribuswin.cpp
==============================================================================
--- trunk/Scribus/scribus/scribuswin.cpp (original)
+++ trunk/Scribus/scribus/scribuswin.cpp Sun May 20 00:06:30 2012
@@ -156,21 +156,6 @@
 	statusBar()->setSizeGripEnabled(!isMaximized());
 }
 
-void ScribusWin::setMasterPagesPaletteShown(bool isShown) const
-{
-	QString pageName;
-	PagePalette* pagePalette = m_MainWindow->pagePalette;
-	if (isShown && m_Doc->masterPageMode())
-	{
-		pageName = m_Doc->currentPage()->pageName();
-		pagePalette->startMasterPageMode(pageName);
-	}
-	else if (pagePalette->masterPageMode())
-	{
-		pagePalette->endMasterPageMode();
-	}
-}
-
 void ScribusWin::windowActivationChange ( bool oldActive )
 {
 	if( isActiveWindow() )

Modified: trunk/Scribus/scribus/scribuswin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17517&path=/trunk/Scribus/scribus/scribuswin.h
==============================================================================
--- trunk/Scribus/scribus/scribuswin.h (original)
+++ trunk/Scribus/scribus/scribuswin.h Sun May 20 00:06:30 2012
@@ -58,7 +58,6 @@
 	void setSubWin(QMdiSubWindow *win) { subWindow = win; }
 	void setMenuStatus(int index, bool value) { if (index>=0 && index <=6) MenuStat[index]=value;}
 	bool menuStatus(int index) const { if (index>=0 && index <=6) return MenuStat[index]; else return false; }
-	void setMasterPagesPaletteShown(bool isShown) const;
 	
 public slots:
 	void slotAutoSave();

Modified: trunk/Scribus/scribus/ui/pagepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17517&path=/trunk/Scribus/scribus/ui/pagepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/pagepalette.cpp Sun May 20 00:06:30 2012
@@ -124,6 +124,20 @@
 	if (mpWidget)
 		mpWidget->setView(view);
 	m_view = view;
+
+	if (!m_view)
+		return;
+
+	ScribusDoc* doc = m_view->Doc;
+	if (doc->masterPageMode())
+	{
+		QString pageName = doc->currentPage()->pageName();
+		startMasterPageMode(pageName);
+	}
+	else if (masterPageMode())
+	{
+		endMasterPageMode();
+	}
 }
 
 void PagePalette::updateMasterPageList()

Modified: trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17517&path=/trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp (original)
+++ trunk/Scribus/scribus/ui/pagepalette_masterpages.cpp Sun May 20 00:06:30 2012
@@ -69,14 +69,13 @@
 
 	disconnectSignals();
 	currentView = view;
+	currentDoc = currentView ? currentView->Doc : 0;
 
 	if (!view)
 	{
 		this->setEnabled(false);
 		return;
 	}
-
-	currentDoc = currentView->Doc;
 
 	if (masterPageName.isEmpty() && currentDoc->masterPageMode())
 		currentPage = currentDoc->currentPage()->pageName();
@@ -88,10 +87,10 @@
 	QString currentPageName;
 	if (currentDoc->masterPageMode())
 		currentPageName = currentDoc->currentPage()->pageName();
-	if (!currentDoc->masterPageMode() || currentPage != currentPageName)
+	if (currentDoc->masterPageMode() && currentPage != currentPageName)
 		currentView->showMasterPage(currentDoc->MasterNames[currentPage]);
 
-	this->setEnabled(true);
+	this->setEnabled(currentDoc->masterPageMode());
 	connectSignals();
 }
 
@@ -369,7 +368,6 @@
 
 void PagePalette_MasterPages::importPage()
 {
-	//bool atf;
 	MergeDoc *dia = new MergeDoc(this, true);
 	if (dia->exec())
 	{
@@ -377,10 +375,7 @@
 			currentView->requestMode(submodeEndNodeEdit);
 		qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
 		int nr = currentDoc->Pages->count();
-		//currentDoc->pageCount = 0;
-		//atf = currentDoc->usesAutomaticTextFrames();
-		//currentDoc->setUsesAutomaticTextFrames(false);
-		//emit createNew(nr);
+
 		QString MasterPageName(dia->getMasterPageNameText());
 		QString MasterPageName2(MasterPageName);
 		int copyC = 1;
@@ -395,24 +390,10 @@
 		//FileLoader::PasteItem as this call doesnt pass in the new destination page
 		currentDoc->scMW()->loadPage(dia->getFromDoc(), dia->getMasterPageNameItem(), true, MasterPageName2);
 		qApp->processEvents();
-		/*
-		MasterPageName = currentDoc->Pages->at(nr)->PageNam;
-		MasterPageName2 = MasterPageName;
-		int copyC = 1;
-		while (currentDoc->MasterNames.contains(MasterPageName2))
-		{
-			MasterPageName2 = tr("Copy #%1 of ").arg(copyC)+MasterPageName;
-			copyC++;
-		}
-		currentDoc->MasterNames.insert(MasterPageName2, nr);
-		currentDoc->Pages->at(nr)->setPageName(MasterPageName2);
-		currentDoc->Pages->at(nr)->MPageNam = "";
-		*/
+
 		updateMasterPageList(MasterPageName2);
-		//currentDoc->setUsesAutomaticTextFrames(atf);
 		currentView->showMasterPage(currentDoc->MasterNames[MasterPageName2]);
 		qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
-		//currentDoc->MasterPages = currentDoc->Pages;
 	}
 	delete dia;
 }
@@ -422,10 +403,7 @@
 	currentPage = item->text();
 	deleteButton->setEnabled(currentDoc->MasterNames.count() == 1 ? false : true);
 	if (currentPage == CommonStrings::trMasterPageNormal || currentPage == CommonStrings::masterPageNormal)
-	{
-// 		currentPage = CommonStrings::masterPageNormal;
 		deleteButton->setEnabled(false);
-	}
 	else
 		deleteButton->setEnabled(true);
 	if (currentDoc->appMode == modeEditClip)
@@ -433,6 +411,8 @@
 	else if (currentDoc->appMode == modeEdit || currentDoc->appMode == modeEditGradientVectors)
 		currentView->requestMode(modeNormal);
 	currentView->showMasterPage(currentDoc->MasterNames[currentPage]);
+
+	this->setEnabled(true);
 }
 
 void PagePalette_MasterPages::selectMasterPage(QString name)
@@ -452,6 +432,8 @@
 	if (currentDoc->appMode == modeEditClip)
 		currentView->requestMode(submodeEndNodeEdit);
 	currentView->showMasterPage(currentDoc->MasterNames[currentPage]);
+
+	this->setEnabled(true);
 }
 
 void PagePalette_MasterPages::updateMasterPageList(void)




More information about the scribus-commit mailing list