Difference between revisions of "Anatomy of a Scribus Plugin"

From Scribus Wiki
Jump to navigation Jump to search
Line 5: Line 5:
 
=== Requirements ===
 
=== Requirements ===
 
* Knowledge of c++
 
* 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);
 +
}

Revision as of 20:14, 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);

}