r18580 by craig - #11823: Add some new APIs to MenuManager and fix Scripter Recent Scripts menu
scribus-commit
scribus-commit at lists.scribus.net
Tue Oct 29 22:00:36 UTC 2013
Author: craig
Date: Tue Oct 29 22:00:35 2013
New Revision: 18580
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18580
Log:
#11823: Add some new APIs to MenuManager and fix Scripter Recent Scripts menu
Modified:
trunk/Scribus/scribus/menumanager.cpp
trunk/Scribus/scribus/menumanager.h
trunk/Scribus/scribus/pluginmanager.cpp
trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.h
trunk/Scribus/scribus/scribus.cpp
Modified: trunk/Scribus/scribus/menumanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18580&path=/trunk/Scribus/scribus/menumanager.cpp
==============================================================================
--- trunk/Scribus/scribus/menumanager.cpp (original)
+++ trunk/Scribus/scribus/menumanager.cpp Tue Oct 29 22:00:35 2013
@@ -37,6 +37,7 @@
windowsMenu=NULL;
m_undoMenu=new QMenu("undo");
m_redoMenu=new QMenu("redo");
+ rememberedMenus.clear();
}
MenuManager::~MenuManager()
@@ -45,12 +46,16 @@
m_redoMenu->deleteLater();
}
-bool MenuManager::createMenu(const QString &menuName, const QString &menuText, const QString parent, bool checkable)
+bool MenuManager::createMenu(const QString &menuName, const QString &menuText, const QString parent, bool checkable, bool rememberMenu)
{
bool retVal=false;
QList<QString> menuEntries;
menuStrings.insert(menuName, menuEntries);
menuStringTexts.insert(menuName, menuText);
+ if (rememberMenu)
+ {
+ rememberedMenus.insert(menuName, NULL);
+ }
return retVal;
}
@@ -148,6 +153,10 @@
if (menuStrings.contains(menuStrings[menuName].at(i)))
{
QMenu *subMenu=menuBarMenus[menuName]->addMenu(menuStringTexts[menuStrings[menuName].at(i)]);
+ if (rememberedMenus.contains(menuStrings[menuName].at(i)))
+ {
+ rememberedMenus.insert(menuStrings[menuName].at(i), subMenu);
+ }
if (menuStrings[menuName].at(i)=="FileOpenRecent")
{
recentFileMenu=subMenu;
@@ -187,6 +196,10 @@
QMenu *subMenu=menuToAddTo->addMenu(menuStringTexts[menuStrings[menuName].at(i)]);
if (subMenu)
{
+ if (rememberedMenus.contains(menuStrings[menuName].at(i)))
+ {
+ rememberedMenus.insert(menuStrings[menuName].at(i), subMenu);
+ }
if (menuStrings[menuName].at(i)=="ItemSendToScrapbook")
{
itemSendtoScrapbookMenu=subMenu;
@@ -208,6 +221,13 @@
}
}
+void MenuManager::addMenuItemStringstoRememberedMenu(const QString &menuName, const QMap<QString, QPointer<ScrAction> > &menuActions)
+{
+ if (rememberedMenus.contains(menuName))
+ if (rememberedMenus.value(menuName)!=NULL)
+ addMenuItemStringstoMenu(menuName, rememberedMenus.value(menuName), menuActions);
+}
+
void MenuManager::addMenuItemStringstoSpecialMenu(const QString &menuName, const QMap<QString, QPointer<ScrAction> > &menuActions)
{
@@ -246,6 +266,12 @@
void MenuManager::clearMenuStrings(const QString &menuName)
{
+ if (rememberedMenus.contains(menuName))
+ {
+ if (rememberedMenus.value(menuName)!=NULL)
+ rememberedMenus.value(menuName)->clear();
+ }
+ else
if (menuName=="FileOpenRecent" && recentFileMenu!=NULL)
{
recentFileMenu->clear();
Modified: trunk/Scribus/scribus/menumanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18580&path=/trunk/Scribus/scribus/menumanager.h
==============================================================================
--- trunk/Scribus/scribus/menumanager.h (original)
+++ trunk/Scribus/scribus/menumanager.h Tue Oct 29 22:00:35 2013
@@ -50,7 +50,7 @@
enum MenuType {Normal, DLL};
bool addMenuToWidgetOfAction(const QString &menuName, ScrAction *action);
- bool createMenu(const QString &menuName, const QString &menuText = QString::null, const QString parent = QString::null, bool checkable = false);
+ bool createMenu(const QString &menuName, const QString &menuText = QString::null, const QString parent = QString::null, bool checkable = false, bool rememberMenu = false);
bool removeMenuItem(ScrAction *menuAction, const QString &parent);
void generateKeyManList(QStringList *actionNames);
void runMenuAtPos(const QString &, const QPoint);
@@ -68,6 +68,7 @@
void addMenuItemString(const QString& s, const QString &parent);
void addMenuItemStringAfter(const QString &s, const QString &after, const QString &parent);
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);
@@ -84,6 +85,8 @@
QMap<QString, QList<QString> > menuStrings;
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;
Modified: trunk/Scribus/scribus/pluginmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18580&path=/trunk/Scribus/scribus/pluginmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/pluginmanager.cpp (original)
+++ trunk/Scribus/scribus/pluginmanager.cpp Tue Oct 29 22:00:35 2013
@@ -319,9 +319,7 @@
mw->scrMenuMgr->createMenu(ai.menu, ai.subMenuName, ai.parentMenu);
}
}
-// mw->scrMenuMgr->addMenuItem(mw->scrActions[ai.name], ai.menu, true);
mw->scrMenuMgr->addMenuItemString(ai.name, ai.menu);
- qDebug()<<ai.name<<ai.menu;
}
}
else
@@ -337,8 +335,6 @@
mw->scrMenuMgr->createMenu(ai.menu, ai.subMenuName, ai.parentMenu);
}
mw->scrMenuMgr->addMenuItemStringAfter(ai.name, ai.menuAfterName, ai.menu);
-// mw->scrMenuMgr->addMenuItemAfter(mw->scrActions[ai.name], ai.menu, true, afterAction);
-// mw->scrMenuMgr->addMenuItem(mw->scrActions[ai.name], ai.menu, true);
}
if (!ai.toolbar.isEmpty())
{
Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18580&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.cpp Tue Oct 29 22:00:35 2013
@@ -80,20 +80,19 @@
menuMgr->createMenu("ScribusScripts", QObject::tr("&Scribus Scripts"), "Scripter");
menuMgr->addMenuItemString("ScribusScripts", "Scripter");
menuMgr->addMenuItemString("scripterExecuteScript", "Scripter");
- menuMgr->createMenu("RecentScripts", QObject::tr("&Recent Scripts"), "Scripter");
+ menuMgr->createMenu("RecentScripts", QObject::tr("&Recent Scripts"), "Scripter", false, true);
+ menuMgr->addMenuItemString("RecentScripts", "Scripter");
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);
+ RecentScripts = SavedRecentScripts;
+ rebuildRecentScriptsMenu();
}
void ScripterCore::enableMainWindowMenu()
@@ -128,17 +127,14 @@
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->addMenuItemString(strippedName, "ScribusScripts");
}
}
-
-
}
void ScripterCore::rebuildRecentScriptsMenu()
{
- menuMgr->clearMenu("RecentScripts");
+ menuMgr->clearMenuStrings("RecentScripts");
scrRecentScriptActions.clear();
uint max = qMin(PrefsManager::instance()->appPrefs.uiPrefs.recentDocCount, RecentScripts.count());
for (uint m = 0; m < max; ++m)
@@ -149,8 +145,10 @@
connect( scrRecentScriptActions[strippedName], SIGNAL(triggeredData(QString)), this, SLOT(RecentScript(QString)) );
menuMgr->addMenuItemString(strippedName, "RecentScripts");
}
-}
-
+ menuMgr->addMenuItemStringstoRememberedMenu("RecentScripts", scrRecentScriptActions);
+}
+
+/*
void ScripterCore::buildRecentScriptsMenu()
{
RecentScripts = SavedRecentScripts;
@@ -170,8 +168,10 @@
menuMgr->addMenuItemString(strippedName, "RecentScripts");
}
}
- }
-}
+ menuMgr->addMenuItemStringstoRememberedMenu("RecentScripts", scrRecentScriptActions);
+ }
+}
+*/
void ScripterCore::FinishScriptRun()
{
@@ -493,7 +493,10 @@
}
// Load recent scripts from the prefs
for (int i = 0; i < prefRecentScripts->getRowCount(); i++)
- SavedRecentScripts.append(prefRecentScripts->get(i,0));
+ {
+ QString rs(prefRecentScripts->get(i,0));
+ SavedRecentScripts.append(rs);
+ }
// then get more general preferences
m_enableExtPython = prefs->getBool("extensionscripts",false);
m_importAllNames = prefs->getBool("importall",true);
@@ -516,7 +519,9 @@
return;
}
for (int i = 0; i < RecentScripts.count(); i++)
+ {
prefRecentScripts->set(i, 0, RecentScripts[i]);
+ }
// then save more general preferences
prefs->set("extensionscripts", m_enableExtPython);
prefs->set("importall", m_importAllNames);
Modified: trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18580&path=/trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.h
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.h (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/scriptercore.h Tue Oct 29 22:00:35 2013
@@ -68,7 +68,7 @@
void SavePlugPrefs();
void rebuildRecentScriptsMenu();
void buildScribusScriptsMenu();
- void buildRecentScriptsMenu();
+ //void buildRecentScriptsMenu();
void rebuildScribusScriptsMenu();
//Internal members
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18580&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Oct 29 22:00:35 2013
@@ -3553,8 +3553,6 @@
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->addMenuItem(scrRecentFileActions[strippedName], "FileOpenRecent", true);
-
}
scrMenuMgr->addMenuItemStringstoSpecialMenu("FileOpenRecent", scrRecentFileActions);
fileToolBar->rebuildRecentFileMenu();
More information about the scribus-commit
mailing list