#define PLUGININTERFACE_H
#include <QObject>
-#include <QPluginLoader>
+#include <QVariant>
+//#include <QPluginLoader>
namespace qtrapids
{
* that implement the additional functionality
* @note Implementing plugin host should inherit QObject.
*/
- class PluginHostInterface {
+ class PluginHostInterface
+ {
public:
+
+
/// @enum PluginWidgetType Allows plugin host to differentiate actions
/// when passed as parameter to addWidget(). E.g. Popup a dialog or append tab etc.
/// @todo add new types
enum PluginWidgetType {
BASE_WIDGET,
TAB_PAGE,
- UNKNOWN
+ UNKNOWN_TYPE
+ };
+
+ /// @enum PluginRequest for requesting host application functionality
+ /// E.g. open torrent file etc.
+ /// @todo Additional functionality request constants.
+ enum PluginRequest {
+ OPEN_FILE,
+ READ_BUFFER,
+ UNKNOWN_REQUEST
};
/// @brief Sets the plugin GUI element to host application
/// @note It is up to the host application to decide how to manage
/// and show the actual widget.
- virtual bool setGui(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0;
+ virtual bool setGui(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE) = 0;
/// @brief Adds additional plugin wigdets to the host application.
/// This functio can be called by the plugin recursively, i.e. when GUI events occur
/// The host application must handle placing the additional widgets.
/// @todo Could we implement this using in a more manageable way, e.g. signal-slot?
- virtual void addPluginWidget(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0;
- virtual void addToolbar(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0;
- virtual void addToolItem(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0;
- virtual void addMenu(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0;
- virtual void addMenuItem(QWidget* widget, PluginWidgetType type = UNKNOWN) = 0;
+ virtual void addPluginWidget(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE) = 0;
+ virtual void addToolbar(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE) = 0;
+ virtual void addToolItem(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE) = 0;
+ virtual void addMenu(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE) = 0;
+ virtual void addMenuItem(QWidget* widget, PluginWidgetType type = UNKNOWN_TYPE) = 0;
+
+ /// @brief Plugin can request to host application functionality.
+ /// Host application defines the service policy for plugin requests.
+ /// @todo Sending events would benefit from Qt signal, how to define
+ /// signal in an abstract interface?
+ virtual bool eventRequest(QVariant param, PluginRequest req = UNKNOWN_REQUEST) = 0;
};
* The host application uses PluginInterface interface for calling the plugins
* that extend the Host functionality
*/
- class PluginInterface : public QObject {
+ class PluginInterface : public QObject
+ {
public:
+
+ /// @struct Info Used to supply information from the host application to the plugin
+ /// for initialization.
+ struct Info {
+ Info() : directory("") {} //Constructor
+ QString directory; ///< directory from which the plugin is loaded
+ // ...
+ };
+
/// @brief Initializes the plugin instance.
- virtual void initialize(PluginHostInterface* host) = 0;
+ virtual void initialize(PluginHostInterface* host, Info info = Info()) = 0;
virtual QWidget* getGui() = 0;
};