The PluginConnectionInterface allows to connect signals and slots across different OpenFlipper plugins.
Usually you should implement the BaseInterface::pluginsInitialized() function from BaseInterface. In this function you can setup your connections. Don't try to setup your connections earlier as the plugins you try to connect may not exist yet.
WARNING! Never connect SIGNALS and SLOTS which are already defined in other Interfaces!! WARNING!
This might result in endless loops and breaks OpenFlippers control loops. You have to keep track of your connections yourself. If you call slots which call updatedOject which in turn call your original slot you get a loop and OpenFlipper is not responsible for your endless loops! Be careful!
The following code shows a simple example to connect signals and slots. For the signal and slot definition you have to use the common QT macros SIGNAL and SLOT.
void ExamplePlugin::pluginsInitialized()
{
emit crossPluginConnect(pluginA,SIGNAL(signalA(QString)),pluginB,SLOT(slotB(QString)));
}
The next example shows how to use a queued connection between two plugins:
ExamplePlugin.hh:
{
Q_OBJECT
[...]
signals:
void void dataControlGroupObjects(
IdList, QString);
[...]
void exampleFunction();
}
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Interface class from which all plugins have to be created.
Allow to connect slots between plugins.
virtual void crossPluginConnectQueued(QString _pluginName1, const char *_signal, QString _pluginName2, const char *_slot)
connect signals and slots of plugins across plugins using Qt::QueuedConnection
ExamplePlugin.cc:
[...]
void ExamplePlugin::pluginsInitialized()
{
[...]
emit crossPluginConnectQueued(
"exampleplugin",SIGNAL(dataControlGroupObjects(
IdList, QString)),
"datacontrol",SLOT(groupObjects(
IdList, QString)));
}
void ExamplePlugin::exampleFunction()
{
[...]
emit dataControlGroupObjects(ids, "fancy group name");
}
To use the PluginConnectionInterface:
-
include PluginConnectionInterface.hh in your plugins header file
-
derive your plugin from the class PluginConnectionInterface
-
add Q_INTERFACES(PluginConnectionInterface) to your plugin class
-
And add the signals or slots you want to use to your plugin class (You don't need to implement all of them)