Changed: #1206 Added example plugin.

This commit is contained in:
dnk-88 2010-12-01 14:40:21 +02:00
parent f7374c55cf
commit fb171701a6
4 changed files with 92 additions and 1 deletions

View file

@ -31,7 +31,7 @@ namespace NLQT
class IPlugin
{
public:
virtual ~IPlugin();
virtual ~IPlugin() {}
virtual bool initialize(IPluginManager *pluginManager, QString *errorString) = 0;
virtual void extensionsInitialized() = 0;

View file

@ -0,0 +1,12 @@
TEMPLATE = lib
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += plugin
# Input
HEADERS += plugin1.h \
../../extension_system/iplugin.h \
../../extension_system/iplugin_manager.h \
../../extension_system/plugin_spec.h
SOURCES += plugin1.cpp \
../../extension_system/plugin_spec.cpp

View file

@ -0,0 +1,50 @@
#include "plugin1.h"
#include <QtCore/QObject>
#include <QtGui/QMessageBox>
using namespace Plugin;
bool MyPlugin::initialize(NLQT::IPluginManager *pluginManager, QString *errorString)
{
Q_UNUSED(errorString);
QString str;
QList<NLQT::CPluginSpec *> listPlug = pluginManager->plugins();
Q_FOREACH (NLQT::CPluginSpec *plugSpec, listPlug)
str += plugSpec->name();
QMessageBox msgBox;
msgBox.setText(str);
msgBox.exec();
return true;
}
void MyPlugin::extensionsInitialized()
{
QMessageBox msgBox;
msgBox.setText("extensionsInitialize Example Plugin.");
msgBox.exec();
}
QString MyPlugin::name() const
{
return "ExamplePlugin";
}
QString MyPlugin::version() const
{
return "0.1";
}
QString MyPlugin::vendor() const
{
return "dnk";
}
QString MyPlugin::description() const
{
return "Example plugin";
}
Q_EXPORT_PLUGIN(MyPlugin)

View file

@ -0,0 +1,29 @@
#ifndef PLUGIN1_H
#define PLUGIN1_H
#include "../../extension_system/iplugin.h"
#include "../../extension_system/plugin_spec.h"
#include <QtCore/QObject>
namespace Plugin
{
class MyPlugin : public QObject, public NLQT::IPlugin
{
Q_OBJECT
Q_INTERFACES(NLQT::IPlugin)
public:
bool initialize(NLQT::IPluginManager *pluginManager, QString *errorString);
void extensionsInitialized();
QString name() const;
QString version() const;
QString vendor() const;
QString description() const;
};
} // namespace Plugin1
#endif // PLUGIN1_H