Changed: #1206 Update ovqt_example plugin.

This commit is contained in:
dnk-88 2010-12-01 17:48:43 +02:00
parent 1fe9422521
commit 1abd47afdb
6 changed files with 29 additions and 11 deletions

View file

@ -96,14 +96,11 @@ sint main(int argc, char **argv)
Modules::config().configSearchPaths();
Modules::mainWin().showMaximized();
Modules::plugMan().addObject(&Modules::mainWin());
Modules::plugMan().setPluginPaths(QStringList() << QString("./plugins"));
Modules::plugMan().loadPlugins();
QList<NLQT::CPluginSpec *> listPlug = Modules::plugMan().plugins();
Q_FOREACH (NLQT::CPluginSpec *plugSpec, listPlug)
nlinfo(plugSpec->errorString().toStdString().c_str());
splash->finish(&Modules::mainWin());
int result = app.exec();
Modules::release();

View file

@ -60,6 +60,7 @@ CMainWindow::CMainWindow(QWidget *parent)
_GraphicsViewport(NULL), _lastDir(".")
{
nldebug("CMainWindow::CMainWindow:");
setObjectName("CMainWindow");
// create NeL viewport
_GraphicsViewport = new CGraphicsViewport(this);

View file

@ -33,12 +33,12 @@ void Modules::init()
if (_configuration == NULL) _configuration = new NLQT::CConfiguration;
config().init();
if (_pluginManager == NULL) _pluginManager = new NLQT::CPluginManager;
if (_objectViewer == NULL) _objectViewer = new NLQT::CObjectViewer;
if (_soundSystem == NULL) _soundSystem = new NLQT::CSoundSystem;
if (_particleEditor == NULL) _particleEditor = new NLQT::CParticleEditor;
if (_vegetableEditor == NULL) _vegetableEditor = new NLQT::CVegetableEditor;
if (_mainWindow == NULL) _mainWindow = new NLQT::CMainWindow;
if (_pluginManager == NULL) _pluginManager = new NLQT::CPluginManager;
}
void Modules::release()

View file

@ -2,13 +2,19 @@
#include <QtCore/QObject>
#include <QtGui/QMessageBox>
#include <QtGui/QMainWindow>
#include <QtGui/QMenuBar>
#include "../../extension_system/plugin_spec.h"
using namespace Plugin;
bool MyPlugin::initialize(NLQT::IPluginManager *pluginManager, QString *errorString)
{
Q_UNUSED(errorString);
_plugMan = pluginManager;
QString str;
QList<NLQT::CPluginSpec *> listPlug = pluginManager->plugins();
Q_FOREACH (NLQT::CPluginSpec *plugSpec, listPlug)
@ -22,8 +28,20 @@ bool MyPlugin::initialize(NLQT::IPluginManager *pluginManager, QString *errorStr
void MyPlugin::extensionsInitialized()
{
QString str;
QList<QObject *> listObjects = _plugMan->allObjects();
Q_FOREACH (QObject *qobj, listObjects)
{
if (qobj->objectName() == "CMainWindow")
{
QMainWindow *wnd = qobject_cast< QMainWindow* >(qobj);
str += qobj->objectName() + QString(": width=%1,height=%2").arg(wnd->width()).arg(wnd->height());
}
}
QMessageBox msgBox;
msgBox.setText("extensionsInitialize Example Plugin.");
msgBox.setText(str);
msgBox.exec();
}

View file

@ -2,7 +2,6 @@
#define PLUGIN1_H
#include "../../extension_system/iplugin.h"
#include "../../extension_system/plugin_spec.h"
#include <QtCore/QObject>
@ -22,6 +21,9 @@ public:
QString version() const;
QString vendor() const;
QString description() const;
private:
NLQT::IPluginManager *_plugMan;
};
} // namespace Plugin1