r18544 by craig - MenuManager: recent file menu now working again from the toolbar open button

scribus-commit scribus-commit at lists.scribus.net
Sat Oct 12 10:00:26 UTC 2013


Author: craig
Date: Sat Oct 12 10:00:26 2013
New Revision: 18544

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18544
Log:
MenuManager: recent file menu now working again from the toolbar open button

Modified:
    trunk/Scribus/scribus/menumanager.cpp
    trunk/Scribus/scribus/menumanager.h
    trunk/Scribus/scribus/pluginmanager.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/ui/filetoolbar.cpp
    trunk/Scribus/scribus/ui/filetoolbar.h

Modified: trunk/Scribus/scribus/menumanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18544&path=/trunk/Scribus/scribus/menumanager.cpp
==============================================================================
--- trunk/Scribus/scribus/menumanager.cpp (original)
+++ trunk/Scribus/scribus/menumanager.cpp Sat Oct 12 10:00:26 2013
@@ -33,6 +33,7 @@
 	menuStrings.clear();
 	recentFileMenu=NULL;
 	editPasteRecentMenu=NULL;
+	itemLayerMenu=NULL;
 	itemSendtoScrapbookMenu=NULL;
 	windowsMenu=NULL;
 }
@@ -159,6 +160,52 @@
 		{
 			windowsMenu=m;
 		}
+		retVal=true;
+	}
+	return retVal;
+}
+
+bool MenuManager::addMenuToMenuBarBefore(const QString &menuName, const QString &afterMenuName)
+{
+	bool retVal=false;
+	if (menuList.contains(menuName) && menuList[menuName]!=NULL)
+	{
+		if (menuList[afterMenuName])
+		{
+			QAction* t=scribusMenuBar->insertMenu(menuList[afterMenuName]->getLocalPopupMenu()->menuAction(), menuList[menuName]->getLocalPopupMenu());
+			if (t!=NULL)
+			{
+				t->setText(menuList[menuName]->getMenuText());
+				retVal=true;
+			}
+		}
+	}
+	return retVal;
+}
+
+bool MenuManager::addMenuStringToMenuBarBefore(const QString &menuName, const QString &afterMenuName)
+{
+	bool retVal=false;
+	if (menuStrings.contains(menuName))
+	{
+		QMenu *m=scribusMenuBar->addMenu(menuStringTexts[menuName]);
+		menuBarMenus.insert(menuName, m);
+		if (menuName=="Windows" && m!=NULL)
+		{
+			windowsMenu=m;
+		}
+		retVal=true;
+	}
+	return retVal;
+}
+
+bool MenuManager::removeMenuFromMenuBar(const QString &menuName)
+{
+	bool retVal=false;
+	if (menuList.contains(menuName) && menuList[menuName]!=NULL)
+	{
+		if (menuList[menuName]->getLocalPopupMenu()->menuAction())
+			scribusMenuBar->removeAction(menuList[menuName]->getLocalPopupMenu()->menuAction());
 		retVal=true;
 	}
 	return retVal;
@@ -194,10 +241,6 @@
 						{
 							editPasteRecentMenu=subMenu;
 						}
-						else if (menuStrings[menuName].at(i)=="ItemLayer")
-						{
-							itemLayerMenu=subMenu;
-						}
 						addMenuItemStringstoMenu(menuStrings[menuName].at(i), subMenu, menuActions);
 					}
 				}
@@ -233,6 +276,14 @@
 							{
 								itemSendtoScrapbookMenu=subMenu;
 							}
+							else if (menuStrings[menuName].at(i)=="ItemLayer")
+							{
+								itemLayerMenu=subMenu;
+							}
+							else if (menuStrings[menuName].at(i)=="EditPasteRecent")
+							{
+								editPasteRecentMenu=subMenu;
+							}
 							addMenuItemStringstoMenu(menuStrings[menuName].at(i), subMenu, menuActions);
 						}
 					}
@@ -262,6 +313,20 @@
 			itemSendtoScrapbookMenu->addAction(*it);
 		}
 	}
+	else if (menuName=="ItemLayer" && itemLayerMenu!=NULL)
+	{
+		for( QMap<QString, QPointer<ScrAction> >::ConstIterator it = menuActions.begin(); it!=menuActions.end(); ++it )
+		{
+			itemLayerMenu->addAction(*it);
+		}
+	}
+	else if (menuName=="EditPasteRecent" && editPasteRecentMenu!=NULL)
+	{
+		for( QMap<QString, QPointer<ScrAction> >::ConstIterator it = menuActions.begin(); it!=menuActions.end(); ++it )
+		{
+			editPasteRecentMenu->addAction(*it);
+		}
+	}
 }
 
 void MenuManager::clearMenuStrings(const QString &menuName)
@@ -278,37 +343,17 @@
 	{
 		itemSendtoScrapbookMenu->clear();
 	}
-}
-
-bool MenuManager::addMenuToMenuBarBefore(const QString &menuName, const QString &afterMenuName)
-{
-	bool retVal=false;
-	if (menuList.contains(menuName) && menuList[menuName]!=NULL)
-	{
-		if (menuList[afterMenuName])
-		{
-			QAction* t=scribusMenuBar->insertMenu(menuList[afterMenuName]->getLocalPopupMenu()->menuAction(), menuList[menuName]->getLocalPopupMenu());
-			if (t!=NULL)
-			{
-				t->setText(menuList[menuName]->getMenuText());
-				retVal=true;
-			}
-		}
-	}
-	return retVal;
-}
-
-bool MenuManager::removeMenuFromMenuBar(const QString &menuName)
-{
-	bool retVal=false;
-	if (menuList.contains(menuName) && menuList[menuName]!=NULL)
-	{
-		if (menuList[menuName]->getLocalPopupMenu()->menuAction())
-			scribusMenuBar->removeAction(menuList[menuName]->getLocalPopupMenu()->menuAction());
-		retVal=true;
-	}
-	return retVal;
-}
+	else if (menuName=="ItemLayer" && itemLayerMenu!=NULL)
+	{
+		itemLayerMenu->clear();
+	}
+	else if (menuName=="EditPasteRecent" && editPasteRecentMenu!=NULL)
+	{
+		editPasteRecentMenu->clear();
+	}
+}
+
+
 
 bool MenuManager::addMenuToWidgetOfAction(const QString &menuName, ScrAction *action)
 {

Modified: trunk/Scribus/scribus/menumanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18544&path=/trunk/Scribus/scribus/menumanager.h
==============================================================================
--- trunk/Scribus/scribus/menumanager.h (original)
+++ trunk/Scribus/scribus/menumanager.h Sat Oct 12 10:00:26 2013
@@ -61,6 +61,7 @@
 		bool addMenuToMenuBar(const QString &menuName);
 		bool addMenuStringToMenuBar(const QString &menuName);
 		bool addMenuToMenuBarBefore(const QString &, const QString &);
+		bool addMenuStringToMenuBarBefore(const QString &, const QString &);
 		bool removeMenuFromMenuBar(const QString &menuName);
 		bool addMenuToWidgetOfAction(const QString &menuName, ScrAction *action);
 

Modified: trunk/Scribus/scribus/pluginmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18544&path=/trunk/Scribus/scribus/pluginmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/pluginmanager.cpp (original)
+++ trunk/Scribus/scribus/pluginmanager.cpp Sat Oct 12 10:00:26 2013
@@ -408,7 +408,8 @@
 							if (!sew->seMenuMgr->menuExists(ai.seMenu))
 								sew->seMenuMgr->createMenu(ai.seMenu, ai.subMenuName, ai.parentMenu);
 						}
-						sew->seMenuMgr->addMenuItem(sew->seActions[ai.name], ai.seMenu, true);
+//						sew->seMenuMgr->addMenuItem(sew->seActions[ai.name], ai.seMenu, true);
+						sew->seMenuMgr->addMenuItemString(ai.name, ai.menu);
 					}
 				}
 				else
@@ -422,7 +423,8 @@
 						if (!sew->seMenuMgr->menuExists(ai.seMenu))
 							sew->seMenuMgr->createMenu(ai.seMenu, ai.subMenuName, ai.parentMenu);
 					}
-					sew->seMenuMgr->addMenuItemAfter(sew->seActions[ai.name], ai.seMenu, true, afterAction);
+//					sew->seMenuMgr->addMenuItemAfter(sew->seActions[ai.name], ai.seMenu, true, afterAction);
+					sew->seMenuMgr->addMenuItemStringAfter(ai.name, ai.menuAfterName, ai.menu);
 				}
 			}
 		}

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18544&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sat Oct 12 10:00:26 2013
@@ -3655,9 +3655,6 @@
 void ScribusMainWindow::rebuildRecentFileMenu()
 {
 	scrMenuMgr->clearMenuStrings("FileOpenRecent");
-	for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrRecentFileActions.begin(); it!=scrRecentFileActions.end(); ++it )
-		scrMenuMgr->removeMenuItem((*it), "FileOpenRecent");
-
 	scrRecentFileActions.clear();
 	uint max = qMin(prefsManager->appPrefs.uiPrefs.recentDocCount, RecentDocs.count());
 	QString strippedName, localName;
@@ -3665,18 +3662,19 @@
 	{
 		strippedName = localName = QDir::toNativeSeparators(RecentDocs[m]);
 		strippedName.remove(QDir::separator());
-		scrRecentFileActions.insert(strippedName, new ScrAction(ScrAction::RecentFile, QPixmap(), QPixmap(), QString("&%1").arg(localName.replace("&","&&")), QKeySequence(), this, 0,0.0,RecentDocs[m]));
+		strippedName.prepend(QString("%1").arg(m+1));
+		scrRecentFileActions.insert(strippedName, new ScrAction(ScrAction::RecentFile, QPixmap(), QPixmap(), QString("%1 &%2").arg(m+1).arg(localName.replace("&","&&")), QKeySequence(), this, 0,0.0,RecentDocs[m]));
 		connect( scrRecentFileActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(loadRecent(QString)) );
 //		scrMenuMgr->addMenuItem(scrRecentFileActions[strippedName], "FileOpenRecent", true);
 
 	}
 	scrMenuMgr->addMenuItemStringstoSpecialMenu("FileOpenRecent", scrRecentFileActions);
+	fileToolBar->rebuildRecentFileMenu();
 }
 
 void ScribusMainWindow::rebuildRecentPasteMenu()
 {
-	for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrRecentPasteActions.begin(); it!=scrRecentPasteActions.end(); ++it )
-		scrMenuMgr->removeMenuItem((*it), "EditPasteRecent");
+	scrMenuMgr->clearMenuStrings("EditPasteRecent");
 
 	scrRecentPasteActions.clear();
 	int max = qMin(prefsManager->appPrefs.scrapbookPrefs.numScrapbookCopies, scrapbookPalette->tempBView->objectMap.count());
@@ -3692,9 +3690,10 @@
 			QPixmap pm = it.value().Preview;
 			scrRecentPasteActions.insert(strippedName, new ScrAction(ScrAction::RecentPaste, pm, QPixmap(), QString("&%1 %2").arg(m+1).arg(strippedName), QKeySequence(), this, 0,0.0,it.key()));
 			connect( scrRecentPasteActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(pasteRecent(QString)) );
-			scrMenuMgr->addMenuItem(scrRecentPasteActions[strippedName], "EditPasteRecent", true);
+//			scrMenuMgr->addMenuItem(scrRecentPasteActions[strippedName], "EditPasteRecent", true);
 			it--;
 		}
+		scrMenuMgr->addMenuItemStringstoSpecialMenu("EditPasteRecent", scrRecentPasteActions);
 	}
 }
 
@@ -3873,8 +3872,7 @@
 {
 	if (HaveDoc)
 	{
-		for( QMap<QString, QPointer<ScrAction> >::Iterator it0 = scrLayersActions.begin(); it0 != scrLayersActions.end(); ++it0 )
-			scrMenuMgr->removeMenuItem((*it0), "ItemLayer");
+		scrMenuMgr->clearMenuStrings("ItemLayer");
 		scrLayersActions.clear();
 		ScLayers::iterator it;
 		if (doc->Layers.count()!= 0)
@@ -3903,9 +3901,11 @@
 
 		for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=scrLayersActions.end(); ++it )
 		{
-			scrMenuMgr->addMenuItem((*it), "ItemLayer", true);
+			//scrMenuMgr->addMenuItem((*it), "ItemLayer", true);
 			connect( (*it), SIGNAL(triggeredData(int)), doc, SLOT(itemSelection_SendToLayer(int)) );
 		}
+		scrMenuMgr->addMenuItemStringstoSpecialMenu("ItemLayer", scrRecentFileActions);
+
 	}
 }
 

Modified: trunk/Scribus/scribus/ui/filetoolbar.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18544&path=/trunk/Scribus/scribus/ui/filetoolbar.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/filetoolbar.cpp (original)
+++ trunk/Scribus/scribus/ui/filetoolbar.cpp Sat Oct 12 10:00:26 2013
@@ -21,6 +21,7 @@
  *                                                                         *
  ***************************************************************************/
 
+#include <QString>
 #include <QToolButton>
 
 #include "filetoolbar.h"
@@ -28,16 +29,25 @@
 #include "scraction.h"
 #include "scribus.h"
 
-FileToolBar::FileToolBar(ScribusMainWindow* parent) : ScToolBar( tr("File"), "File", parent)
+FileToolBar::FileToolBar(ScribusMainWindow* p) : ScToolBar( tr("File"), "File", p)
 {
-	addAction(parent->scrActions["fileNew"]);
-	addAction(parent->scrActions["fileOpen"]);
+	parent=p;
+	addAction(p->scrActions["fileNew"]);
+	addAction(p->scrActions["fileOpen"]);
+	addAction(p->scrActions["fileSave"]);
+	addAction(p->scrActions["fileClose"]);
+	addAction(p->scrActions["filePrint"]);
+	addAction(p->scrActions["toolsPreflightVerifier"]);
+	addAction(p->scrActions["fileExportAsPDF"]);
+}
+
+void FileToolBar::rebuildRecentFileMenu()
+{
 	QToolButton* tb = dynamic_cast<QToolButton*>(widgetForAction(parent->scrActions["fileOpen"]));
-	tb->setMenu(parent->scrMenuMgr->getLocalPopupMenu("FileOpenRecent"));
-	tb->setPopupMode(QToolButton::DelayedPopup);
-	addAction(parent->scrActions["fileSave"]);
-	addAction(parent->scrActions["fileClose"]);
-	addAction(parent->scrActions["filePrint"]);
-	addAction(parent->scrActions["toolsPreflightVerifier"]);
-	addAction(parent->scrActions["fileExportAsPDF"]);
+	QMenu *m=new QMenu(this);
+	ScrAction *recentFileAction;
+	foreach (recentFileAction, parent->scrRecentFileActions)
+		m->addAction(recentFileAction);
+	tb->setMenu(m);
+	tb->setPopupMode(QToolButton::MenuButtonPopup);
 }

Modified: trunk/Scribus/scribus/ui/filetoolbar.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18544&path=/trunk/Scribus/scribus/ui/filetoolbar.h
==============================================================================
--- trunk/Scribus/scribus/ui/filetoolbar.h (original)
+++ trunk/Scribus/scribus/ui/filetoolbar.h Sat Oct 12 10:00:26 2013
@@ -24,7 +24,11 @@
 #ifndef FILETOOLBAR_H
 #define FILETOOLBAR_H
 
+#include <QString>
+#include <QMap>
+#include <QPointer>
 #include "scribusapi.h"
+#include "scraction.h"
 #include "ui/sctoolbar.h"
 
 class ScribusMainWindow;
@@ -33,9 +37,13 @@
 {
 	Q_OBJECT
 
-public:
-	FileToolBar(ScribusMainWindow* parent);
-	~FileToolBar() {};
+	public:
+		FileToolBar(ScribusMainWindow* p);
+		~FileToolBar() {};
+		void rebuildRecentFileMenu();
+
+	protected:
+		ScribusMainWindow* parent;
 };
 
 #endif




More information about the scribus-commit mailing list