From 03f92217ee2336adcbf9b1343ea03edac490ade5 Mon Sep 17 00:00:00 2001 From: craig Date: Mon, 30 Apr 2012 21:42:55 +0000 Subject: Update hunspell plugin, plugin manager to allow SE to see plugins, scplugin to have SE plugin attributes git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17485 11d20701-8431-0410-a711-e3c959e3b870 --- scribus/pluginmanager.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'scribus/pluginmanager.cpp') diff --git a/scribus/pluginmanager.cpp b/scribus/pluginmanager.cpp index 7c04eae..d1666b1 100644 --- a/scribus/pluginmanager.cpp +++ b/scribus/pluginmanager.cpp @@ -25,6 +25,7 @@ for which a new license (GPL+exception) is in place. #include "prefsfile.h" #include "scpaths.h" #include "commonstrings.h" +#include "storyeditor.h" #ifdef HAVE_DLFCN_H #include @@ -354,6 +355,65 @@ bool PluginManager::setupPluginActions(ScribusMainWindow *mw) return true; } +bool PluginManager::setupPluginActions(StoryEditor *sew) +{ + Q_CHECK_PTR(sew); + ScActionPlugin* plugin = 0; + + //sew->seMenuMgr->addMenuSeparator("Extras"); + for (PluginMap::Iterator it = pluginMap.begin(); it != pluginMap.end(); ++it) + { + if (it.value().plugin->inherits("ScActionPlugin")) + { + //Add in ScrAction based plugin linkage + //Insert DLL Action into Dictionary with values from plugin interface + plugin = dynamic_cast(it.value().plugin); + assert(plugin); + ScActionPlugin::ActionInfo ai(plugin->actionInfo()); + if (ai.enabledForStoryEditor) + { + ScrAction* action = new ScrAction(ScrAction::ActionDLLSE, ai.icon1, ai.icon2, ai.text, ai.keySequence, sew); + Q_CHECK_PTR(action); + sew->seActions.insert(ai.name, action); + + // then enable and connect up the action + sew->seActions[ai.name]->setEnabled(ai.enabledForStoryEditor); + + // Connect action's activated signal with the plugin's run method + it.value().enabled = connect( sew->seActions[ai.name], SIGNAL(triggeredData(QWidget*, ScribusDoc*)), + plugin, SLOT(run(QWidget*, ScribusDoc*)) ); + //Get the menu manager to add the DLL's menu item to the right menu, after the chosen existing item + if ( ai.menuAfterName.isEmpty() ) + { + if (!ai.seMenu.isEmpty()) + { + if ((!ai.subMenuName.isEmpty()) && (!ai.parentMenu.isEmpty())) + { + if (!sew->seMenuMgr->menuExists(ai.seMenu)) + sew->seMenuMgr->createMenu(ai.seMenu, ai.subMenuName, ai.parentMenu); + } + sew->seMenuMgr->addMenuItem(sew->seActions[ai.name], ai.seMenu); + } + } + else + { + QString actionName(ai.seMenu.toLower()+ai.menuAfterName); + ScrAction* afterAction=0; + if (sew->seActions.contains(actionName)) + afterAction=sew->seActions[actionName]; + if ((!ai.subMenuName.isEmpty()) && (!ai.parentMenu.isEmpty())) + { + if (!sew->seMenuMgr->menuExists(ai.seMenu)) + sew->seMenuMgr->createMenu(ai.seMenu, ai.subMenuName, ai.parentMenu); + } + sew->seMenuMgr->addMenuItemAfter(sew->seActions[ai.name], ai.seMenu, afterAction); + } + } + } + } + return true; +} + void PluginManager::enableOnlyStartupPluginActions(ScribusMainWindow* mw) { Q_CHECK_PTR(mw); -- cgit