Difference between revisions of "Anatomy of a Scribus Plugin"

From Scribus Wiki
Jump to navigation Jump to search
 
Line 8: Line 8:
 
== Calling plugin A within plugin B ==
 
== Calling plugin A within plugin B ==
  
below is an example how to call the "subdivide" plugin from the tools plugins :
+
below is an example how to call the "subdivide" plugin from the "tools" plugins :
  
 
<pre class='C'>
 
<pre class='C'>

Latest revision as of 20:15, 3 March 2015


Creating a plugin for Scribus

Requirements

  • Knowledge of c++

Calling plugin A within plugin B

below is an example how to call the "subdivide" plugin from the "tools" plugins :

// Plugin names are lowercase
QString pName = "subdivide";
// get list of installed plugins
PluginManager& pluginManager(PluginManager::instance());
QStringList pluginNames(pluginManager.pluginNames(false));
// if your plugin is in the list
if (pluginNames.contains(pName))
{
    // get the plugin
    ScActionPlugin* plugin = dynamic_cast<ScActionPlugin*>
(pluginManager.getPlugin(pName, false));
    // now you can call the plugins "run" method
    // with your doc as argument
    if (plugin)
        plugin->run(doc);
}