r18583 by craig - Move hardcoded named menu to dynamic API
scribus-commit
scribus-commit at lists.scribus.net
Wed Oct 30 22:22:30 UTC 2013
Author: craig
Date: Wed Oct 30 22:22:30 2013
New Revision: 18583
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18583
Log:
Move hardcoded named menu to dynamic API
Modified:
trunk/Scribus/scribus/menumanager.cpp
trunk/Scribus/scribus/menumanager.h
trunk/Scribus/scribus/scribus.cpp
Modified: trunk/Scribus/scribus/menumanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18583&path=/trunk/Scribus/scribus/menumanager.cpp
==============================================================================
--- trunk/Scribus/scribus/menumanager.cpp (original)
+++ trunk/Scribus/scribus/menumanager.cpp Wed Oct 30 22:22:30 2013
@@ -30,10 +30,6 @@
{
scribusMenuBar=mb;
menuStrings.clear();
- recentFileMenu=NULL;
- editPasteRecentMenu=NULL;
- itemLayerMenu=NULL;
- windowsMenu=NULL;
m_undoMenu=new QMenu("undo");
m_redoMenu=new QMenu("redo");
rememberedMenus.clear();
@@ -94,16 +90,16 @@
menuBarMenus.value(menuName)->setEnabled(enabled);
}
-bool MenuManager::addMenuStringToMenuBar(const QString &menuName)
+bool MenuManager::addMenuStringToMenuBar(const QString &menuName, bool rememberMenu)
{
bool retVal=false;
if (menuStrings.contains(menuName))
{
QMenu *m=scribusMenuBar->addMenu(menuStringTexts[menuName]);
menuBarMenus.insert(menuName, m);
- if (menuName=="Windows" && m!=NULL)
- {
- windowsMenu=m;
+ if (rememberMenu)
+ {
+ rememberedMenus.insert(menuName, m);
}
retVal=true;
}
@@ -155,14 +151,6 @@
if (rememberedMenus.contains(menuStrings[menuName].at(i)))
{
rememberedMenus.insert(menuStrings[menuName].at(i), subMenu);
- }
- if (menuStrings[menuName].at(i)=="FileOpenRecent")
- {
- recentFileMenu=subMenu;
- }
- else if (menuStrings[menuName].at(i)=="EditPasteRecent")
- {
- editPasteRecentMenu=subMenu;
}
addMenuItemStringstoMenu(menuStrings[menuName].at(i), subMenu, menuActions);
}
@@ -198,16 +186,8 @@
if (rememberedMenus.contains(menuStrings[menuName].at(i)))
{
rememberedMenus.insert(menuStrings[menuName].at(i), subMenu);
+ addMenuItemStringstoMenu(menuStrings[menuName].at(i), subMenu, menuActions);
}
- 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);
}
}
}
@@ -235,31 +215,30 @@
for( QMap<QString, QPointer<ScrAction> >::ConstIterator it = menuActions.begin(); it!=menuActions.end(); ++it )
rememberedMenus.value(menuName)->addAction(*it);
}
- }
- }
- else
- if (menuName=="FileOpenRecent" && recentFileMenu!=NULL)
- {
- for( QMap<QString, QPointer<ScrAction> >::ConstIterator it = menuActions.begin(); it!=menuActions.end(); ++it )
- recentFileMenu->addAction(*it);
- }
- else if (menuName=="Windows" && windowsMenu!=NULL)
- {
- for( QMap<QString, QPointer<ScrAction> >::ConstIterator it = menuActions.begin(); it!=menuActions.end(); ++it )
- windowsMenu->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);
+ else if (menuName=="Windows")
+ {
+ for( QMap<QString, QPointer<ScrAction> >::ConstIterator it = menuActions.begin(); it!=menuActions.end(); ++it )
+ rememberedMenus.value(menuName)->addAction(*it);
+ }
+ else if (menuName=="FileOpenRecent")
+ {
+ for( QMap<QString, QPointer<ScrAction> >::ConstIterator it = menuActions.begin(); it!=menuActions.end(); ++it )
+ rememberedMenus.value(menuName)->addAction(*it);
+ }
+ else if (menuName=="EditPasteRecent")
+ {
+ for( QMap<QString, QPointer<ScrAction> >::ConstIterator it = menuActions.begin(); it!=menuActions.end(); ++it )
+ {
+ rememberedMenus.value(menuName)->addAction(*it);
+ }
+ }
+ else if (menuName=="ItemLayer")
+ {
+ for( QMap<QString, QPointer<ScrAction> >::ConstIterator it = menuActions.begin(); it!=menuActions.end(); ++it )
+ {
+ rememberedMenus.value(menuName)->addAction(*it);
+ }
+ }
}
}
}
@@ -270,23 +249,6 @@
{
if (rememberedMenus.value(menuName)!=NULL)
rememberedMenus.value(menuName)->clear();
- }
- else
- if (menuName=="FileOpenRecent" && recentFileMenu!=NULL)
- {
- recentFileMenu->clear();
- }
- else if (menuName=="Windows" && windowsMenu!=NULL)
- {
- windowsMenu->clear();
- }
- else if (menuName=="ItemLayer" && itemLayerMenu!=NULL)
- {
- itemLayerMenu->clear();
- }
- else if (menuName=="EditPasteRecent" && editPasteRecentMenu!=NULL)
- {
- editPasteRecentMenu->clear();
}
}
Modified: trunk/Scribus/scribus/menumanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18583&path=/trunk/Scribus/scribus/menumanager.h
==============================================================================
--- trunk/Scribus/scribus/menumanager.h (original)
+++ trunk/Scribus/scribus/menumanager.h Wed Oct 30 22:22:30 2013
@@ -60,7 +60,7 @@
QMenu *getLocalPopupMenu(const QString &menuName);
- bool addMenuStringToMenuBar(const QString &menuName);
+ bool addMenuStringToMenuBar(const QString &menuName, bool rememberMenu=false);
bool addMenuStringToMenuBarBefore(const QString &, const QString &beforeMenuName);
bool clearMenu(const QString &menuName);
bool empty();
@@ -70,7 +70,6 @@
void addMenuItemStringstoMenu(const QString &menuName, QMenu *menuToAddTo, const QMap<QString, QPointer<ScrAction> > &menuActions);
void addMenuItemStringstoRememberedMenu(const QString &menuName, const QMap<QString, QPointer<ScrAction> > &menuActions);
void addMenuItemStringstoMenuBar(const QString &menuName, const QMap<QString, QPointer<ScrAction> > &menuActions);
- void addMenuItemStringstoSpecialMenu(const QString &menuName, const QMap<QString, QPointer<ScrAction> > &menuActions);
void clearMenuStrings(const QString &menuName);
void dumpMenuStrings();
QMenu *undoMenu() {return m_undoMenu;}
@@ -86,11 +85,6 @@
QMap<QString, QString> menuStringTexts;
QMap<QString, QMenu*> menuBarMenus;
QMap<QString, QMenu*> rememberedMenus;
- //TODO move these static items into rememberedMenus
- QMenu *recentFileMenu;
- QMenu *editPasteRecentMenu;
- QMenu *itemLayerMenu;
- QMenu *windowsMenu;
//some hacks to keep undo menu functioning for now
QMenu *m_undoMenu;
QMenu *m_redoMenu;
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18583&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Wed Oct 30 22:22:30 2013
@@ -734,7 +734,7 @@
scrMenuMgr->addMenuItemString("fileNewFromTemplate", "File");
scrMenuMgr->addMenuItemString("fileOpen", "File");
scrMenuMgr->addMenuItemString("FileOpenRecent", "File");
- scrMenuMgr->createMenu("FileOpenRecent", tr("Open &Recent"), "File");
+ scrMenuMgr->createMenu("FileOpenRecent", tr("Open &Recent"), "File", false, true);
scrMenuMgr->addMenuItemString("SEPARATOR", "File");
scrMenuMgr->addMenuItemString("fileClose", "File");
scrMenuMgr->addMenuItemString("fileSave", "File");
@@ -773,7 +773,7 @@
scrMenuMgr->addMenuItemString("editCut", "Edit");
scrMenuMgr->addMenuItemString("editCopy", "Edit");
scrMenuMgr->addMenuItemString("editPaste", "Edit");
- scrMenuMgr->createMenu("EditPasteRecent", tr("Paste Recent"), "Edit");
+ scrMenuMgr->createMenu("EditPasteRecent", tr("Paste Recent"), "Edit",false,true);
scrMenuMgr->createMenu("EditContents", tr("Contents"), "Edit");
scrMenuMgr->addMenuItemString("editCopyContents", "EditContents");
scrMenuMgr->addMenuItemString("editPasteContents", "EditContents");
@@ -822,7 +822,7 @@
scrMenuMgr->addMenuItemString("itemLower", "ItemLevel");
scrMenuMgr->addMenuItemString("itemRaiseToTop", "ItemLevel");
scrMenuMgr->addMenuItemString("itemLowerToBottom", "ItemLevel");
- scrMenuMgr->createMenu("ItemLayer", tr("Send to La&yer"));
+ scrMenuMgr->createMenu("ItemLayer", tr("Send to La&yer"), "",false, true);
scrMenuMgr->addMenuItemString("ItemLayer", "Item");
// scrMenuMgr->addMenuToMenu("ItemLayer", "Item");
scrMenuMgr->createMenu("SendTo", tr("Send to"), "Item");
@@ -1120,7 +1120,7 @@
scrMenuMgr->addMenuItemStringstoMenuBar("Extras", scrActions);
scrMenuMgr->addMenuStringToMenuBar("View");
scrMenuMgr->addMenuItemStringstoMenuBar("View", scrActions);
- scrMenuMgr->addMenuStringToMenuBar("Windows");
+ scrMenuMgr->addMenuStringToMenuBar("Windows", true);
addDefaultWindowMenuItems();
menuBar()->addSeparator();
scrMenuMgr->addMenuStringToMenuBar("Help");
@@ -2214,8 +2214,6 @@
void ScribusMainWindow::windowsMenuAboutToShow()
{
- //for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrWindowsActions.begin(); it!=scrWindowsActions.end(); ++it )
- // scrMenuMgr->removeMenuItem((*it), "Windows");
scrWindowsActions.clear();
addDefaultWindowMenuItems();
QList<QMdiSubWindow *> windows = mdiArea->subWindowList();
@@ -2233,12 +2231,11 @@
scrWindowsActions.insert(docInWindow, new ScrAction( ScrAction::Window, QPixmap(), QPixmap(), docInWindow, QKeySequence(), this, i));
scrWindowsActions[docInWindow]->setToggleAction(true);
connect( scrWindowsActions[docInWindow], SIGNAL(triggeredData(int)), this, SLOT(windowsMenuActivated(int)) );
-// if (windowCount>1)
-// scrMenuMgr->addMenuItem(scrWindowsActions[docInWindow], "Windows", true);
scrWindowsActions[docInWindow]->setChecked(mdiArea->activeSubWindow() == windows.at(i));
+ scrMenuMgr->addMenuItemString(docInWindow, "Windows");
}
if (windowCount>1)
- scrMenuMgr->addMenuItemStringstoSpecialMenu("Windows", scrWindowsActions);
+ scrMenuMgr->addMenuItemStringstoRememberedMenu("Windows", scrWindowsActions);
}
}
@@ -3555,8 +3552,9 @@
strippedName.prepend(QString("%1").arg(m+1, 2, 10, QChar('0')));
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->addMenuItemStringstoSpecialMenu("FileOpenRecent", scrRecentFileActions);
+ scrMenuMgr->addMenuItemString(strippedName, "FileOpenRecent");
+ }
+ scrMenuMgr->addMenuItemStringstoRememberedMenu("FileOpenRecent", scrRecentFileActions);
fileToolBar->rebuildRecentFileMenu();
}
@@ -3578,10 +3576,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->addMenuItemString(strippedName, "EditPasteRecent");
it--;
}
- scrMenuMgr->addMenuItemStringstoSpecialMenu("EditPasteRecent", scrRecentPasteActions);
+ scrMenuMgr->addMenuItemStringstoRememberedMenu("EditPasteRecent", scrRecentPasteActions);
}
}
@@ -3789,11 +3787,10 @@
for( QMap<QString, QPointer<ScrAction> >::Iterator it = scrLayersActions.begin(); it!=scrLayersActions.end(); ++it )
{
- //scrMenuMgr->addMenuItem((*it), "ItemLayer", true);
+ scrMenuMgr->addMenuItemString(it.key(), "ItemLayer");
connect( (*it), SIGNAL(triggeredData(int)), doc, SLOT(itemSelection_SendToLayer(int)) );
}
- scrMenuMgr->addMenuItemStringstoSpecialMenu("ItemLayer", scrLayersActions);
-
+ scrMenuMgr->addMenuItemStringstoRememberedMenu("ItemLayer", scrLayersActions);
}
}
More information about the scribus-commit
mailing list