r18548 by craig - Fix up most parts of Scripts menu

scribus-commit scribus-commit at lists.scribus.net
Sat Oct 12 16:41:29 UTC 2013


Author: craig
Date: Sat Oct 12 16:41:29 2013
New Revision: 18548

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18548
Log:
Fix up most parts of Scripts menu

Modified:
    trunk/Scribus/scribus/menumanager.cpp
    trunk/Scribus/scribus/menumanager.h
    trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribus.h

Modified: trunk/Scribus/scribus/menumanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18548&path=/trunk/Scribus/scribus/menumanager.cpp
==============================================================================
--- trunk/Scribus/scribus/menumanager.cpp (original)
+++ trunk/Scribus/scribus/menumanager.cpp Sat Oct 12 16:41:29 2013
@@ -58,22 +58,22 @@
 	return retVal;
 }
 
-bool MenuManager::addMenuToMenu(const QString &child, const QString &parent)
-{
-	bool retVal=false;
-	if (child==parent)
-	{
-		qDebug("%s", QString("Cannot add %1 menu to %2 menu (itself)").arg(child, parent).toLatin1().constData());
-		return false;	
-	}
-	if ((menuList.contains(child) && menuList[child]!=NULL) &&
-		(menuList.contains(parent) && menuList[parent]!=NULL))
-	{
-		menuList.insert(child, menuList[child]);
-		retVal=menuList[parent]->insertSubMenu(menuList[child]);
-	}
-	return retVal;
-}
+//bool MenuManager::addMenuToMenu(const QString &child, const QString &parent)
+//{
+//	bool retVal=false;
+//	if (child==parent)
+//	{
+//		qDebug("%s", QString("Cannot add %1 menu to %2 menu (itself)").arg(child, parent).toLatin1().constData());
+//		return false;
+//	}
+//	if ((menuList.contains(child) && menuList[child]!=NULL) &&
+//		(menuList.contains(parent) && menuList[parent]!=NULL))
+//	{
+//		menuList.insert(child, menuList[child]);
+//		retVal=menuList[parent]->insertSubMenu(menuList[child]);
+//	}
+//	return retVal;
+//}
 
 bool MenuManager::clearMenu(const QString &menuName)
 {
@@ -117,16 +117,16 @@
 	return NULL;
 }
 
-bool MenuManager::deleteMenu(const QString &menuName, const QString &parent)
-{
-	if (!parent.isNull())
-	{
-		if (menuList[parent] && menuList[parent]->hasSubMenu(menuList[menuName]))
-			menuList[parent]->removeSubMenu(menuList[menuName]);
-	}
-	menuList.remove(menuName);
-	return true;
-}
+//bool MenuManager::deleteMenu(const QString &menuName, const QString &parent)
+//{
+//	if (!parent.isNull())
+//	{
+//		if (menuList[parent] && menuList[parent]->hasSubMenu(menuList[menuName]))
+//			menuList[parent]->removeSubMenu(menuList[menuName]);
+//	}
+//	menuList.remove(menuName);
+//	return true;
+//}
 
 void MenuManager::setMenuEnabled(const QString &menuName, const bool enabled)
 {
@@ -134,20 +134,20 @@
 		menuList[menuName]->setEnabled(enabled);
 }
 
-bool MenuManager::addMenuToMenuBar(const QString &menuName)
-{
-	bool retVal=false;
-	if (menuList.contains(menuName) && menuList[menuName]!=NULL)
-	{
-		QAction* t=scribusMenuBar->addMenu(menuList[menuName]->getLocalPopupMenu());
-		if (t!=NULL)
-		{
-			t->setText(menuList[menuName]->getMenuText());
-			retVal=true;
-		}
-	}
-	return retVal;
-}
+//bool MenuManager::addMenuToMenuBar(const QString &menuName)
+//{
+//	bool retVal=false;
+//	if (menuList.contains(menuName) && menuList[menuName]!=NULL)
+//	{
+//		QAction* t=scribusMenuBar->addMenu(menuList[menuName]->getLocalPopupMenu());
+//		if (t!=NULL)
+//		{
+//			t->setText(menuList[menuName]->getMenuText());
+//			retVal=true;
+//		}
+//	}
+//	return retVal;
+//}
 
 bool MenuManager::addMenuStringToMenuBar(const QString &menuName)
 {
@@ -165,51 +165,53 @@
 	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 MenuManager::addMenuStringToMenuBarBefore(const QString &menuName, const QString &beforeMenuName)
 {
 	bool retVal=false;
 	if (menuStrings.contains(menuName))
 	{
-		QMenu *m=scribusMenuBar->addMenu(menuStringTexts[menuName]);
+		QList<QAction*> mba=scribusMenuBar->actions();
+		QAction* beforeAct;
+		foreach (beforeAct, mba) {
+			if (beforeMenuName==beforeAct->text().remove('&').remove("..."))
+				break;
+		}
+		QMenu *m=new QMenu(menuName);
+		scribusMenuBar->insertMenu(beforeAct, m);
 		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;
-}
+//bool MenuManager::addMenuToMenuBarBefore(const QString &menuName, const QString &beforeMenuName)
+//{
+//	bool retVal=false;
+//	if (menuList.contains(menuName) && menuList[menuName]!=NULL)
+//	{
+//		if (menuList[beforeMenuName])
+//		{
+//			QAction* t=scribusMenuBar->insertMenu(menuList[beforeMenuName]->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;
+//}
 
 void MenuManager::addMenuItemStringstoMenuBar(const QString &menuName, const QMap<QString, QPointer<ScrAction> > &menuActions)
 {

Modified: trunk/Scribus/scribus/menumanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18548&path=/trunk/Scribus/scribus/menumanager.h
==============================================================================
--- trunk/Scribus/scribus/menumanager.h (original)
+++ trunk/Scribus/scribus/menumanager.h Sat Oct 12 16:41:29 2013
@@ -51,18 +51,18 @@
 		enum MenuType {Normal, DLL};
 
 		bool createMenu(const QString &menuName, const QString &menuText = QString::null, const QString parent = QString::null, bool checkable = false);
-		bool addMenuToMenu(const QString & child, const QString &parent);
-		bool deleteMenu(const QString &menuName, const QString &parent = QString::null);
+//		bool addMenuToMenu(const QString & child, const QString &parent);
+//		bool deleteMenu(const QString &menuName, const QString &parent = QString::null);
 		bool clearMenu(const QString &menuName);
 		void setText(const QString &menuName, const QString &menuText);
 		void setMenuIcon(const QString &menuName, const QIcon &menuIcon);
 		QMenu *getLocalPopupMenu(const QString &menuName);
 		void setMenuEnabled(const QString &menuName, const bool enabled);
-		bool addMenuToMenuBar(const QString &menuName);
+//		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 addMenuToMenuBarBefore(const QString &, const QString &beforeMenuName);
+		bool addMenuStringToMenuBarBefore(const QString &, const QString &beforeMenuName);
+//		bool removeMenuFromMenuBar(const QString &menuName);
 		bool addMenuToWidgetOfAction(const QString &menuName, ScrAction *action);
 
 		bool addMenuItem(ScrAction *menuAction, const QString &parent, bool enabled);

Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18548&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp Sat Oct 12 16:41:29 2013
@@ -77,15 +77,23 @@
 {
 	menuMgr = mw->scrMenuMgr;
 	menuMgr->createMenu("Scripter", QObject::tr("&Script"));
-	menuMgr->addMenuToMenuBarBefore("Scripter","Windows");
 	menuMgr->createMenu("ScribusScripts", QObject::tr("&Scribus Scripts"), "Scripter");
-	menuMgr->addMenuItem(scrScripterActions["scripterExecuteScript"], "Scripter", true);
+	menuMgr->addMenuItemString("ScribusScripts", "Scripter");
+	menuMgr->addMenuItemString("scripterExecuteScript", "Scripter");
 	menuMgr->createMenu("RecentScripts", QObject::tr("&Recent Scripts"), "Scripter");
-	menuMgr->addMenuSeparator("Scripter");
-	menuMgr->addMenuItem(scrScripterActions["scripterShowConsole"], "Scripter", true);
-	menuMgr->addMenuItem(scrScripterActions["scripterAboutScript"], "Scripter", true);
+	menuMgr->addMenuItemString("scripterExecuteScript", "Scripter");
+	menuMgr->addMenuItemString("SEPARATOR", "Scripter");
+//	menuMgr->addMenuItem(scrScripterActions["scripterShowConsole"], "Scripter", true);
+//	menuMgr->addMenuItem(scrScripterActions["scripterAboutScript"], "Scripter", true);
+	menuMgr->addMenuItemString("scripterShowConsole", "Scripter");
+	menuMgr->addMenuItemString("scripterAboutScript", "Scripter");
+
+
 	buildScribusScriptsMenu();
 	buildRecentScriptsMenu();
+
+	menuMgr->addMenuStringToMenuBarBefore("Scripter","Windows");
+	menuMgr->addMenuItemStringstoMenuBar("Scripter", scrScripterActions);
 }
 
 void ScripterCore::enableMainWindowMenu()
@@ -120,7 +128,8 @@
 			QString strippedName=fs.baseName();
 			scrScripterActions.insert(strippedName, new ScrAction( ScrAction::RecentScript, strippedName, QKeySequence(), this));
 			connect( scrScripterActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(StdScript(QString)) );
-			menuMgr->addMenuItem(scrScripterActions[strippedName], "ScribusScripts", true);
+			//menuMgr->addMenuItem(scrScripterActions[strippedName], "ScribusScripts", true);
+			menuMgr->addMenuItemString(strippedName, "ScribusScripts");
 		}
 	}
 
@@ -140,7 +149,8 @@
 		strippedName.remove(QDir::separator());
 		scrRecentScriptActions.insert(strippedName, new ScrAction( ScrAction::RecentScript, RecentScripts[m], QKeySequence(), this));
 		connect( scrRecentScriptActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(RecentScript(QString)) );
-		menuMgr->addMenuItem(scrRecentScriptActions[strippedName], "RecentScripts", true);
+//		menuMgr->addMenuItem(scrRecentScriptActions[strippedName], "RecentScripts", true);
+		menuMgr->addMenuItemString(strippedName, "RecentScripts");
 	}
 }
 

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18548&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Sat Oct 12 16:41:29 2013
@@ -361,10 +361,12 @@
 //	prefsManager->applyLoadedShortCuts();
 //	initKeyboardShortcuts();
 	initMenuBar();
+	createMenuBar();
 	initToolBars();
 	ScCore->pluginManager->setupPluginActions(this);
 	ScCore->pluginManager->enableOnlyStartupPluginActions(this);
 	ScCore->pluginManager->languageChange();
+
 	if (primaryMainWindow)
 		ScCore->setSplashStatus( tr("Applying User Shortcuts") );
 	prefsManager->applyLoadedShortCuts();
@@ -1099,7 +1101,10 @@
 	scrMenuMgr->addMenuItemString("helpAboutScribus", "Help");
 	scrMenuMgr->addMenuItemString("helpAboutPlugins", "Help");
 	scrMenuMgr->addMenuItemString("helpAboutQt", "Help");
-
+}
+
+void ScribusMainWindow::createMenuBar()
+{
 	scrMenuMgr->addMenuStringToMenuBar("File");
 	scrMenuMgr->addMenuItemStringstoMenuBar("File", scrActions);
 	scrMenuMgr->addMenuStringToMenuBar("Edit");
@@ -1121,7 +1126,6 @@
 	menuBar()->addSeparator();
 	scrMenuMgr->addMenuStringToMenuBar("Help");
 	scrMenuMgr->addMenuItemStringstoMenuBar("Help", scrActions);
-
 }
 
 

Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18548&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Sat Oct 12 16:41:29 2013
@@ -560,6 +560,7 @@
     /** init methods */
 	void initSplash(bool showSplash);
 	void initMenuBar(); // initMenuBar creates the menu_bar and inserts the menuitems
+	void createMenuBar();
 	void addDefaultWindowMenuItems(); // addDefaultWindowMenuItems adds the basic Windows menu items, excluding the actual list of windows
 	void initStatusBar(); // setup the statusbar
 	void initToolBars(); // setup the toolbars




More information about the scribus-commit mailing list