Anatomy of a Scribus Plugin: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
Line 10: Line 10:
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'>
// Plugin names are lowercase
// Plugin names are lowercase
QString pName = "subdivide";
QString pName = "subdivide";
Line 26: Line 27:
         plugin->run(doc);
         plugin->run(doc);
}
}
</pre>

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);
}