Changed: #1206 Update ovqt_example plugin.
This commit is contained in:
parent
a2dd91019a
commit
1c69bb9409
6 changed files with 29 additions and 11 deletions
|
@ -52,7 +52,7 @@ void CPluginManager::addObject(QObject *obj)
|
||||||
nlwarning("trying to add duplicate object");
|
nlwarning("trying to add duplicate object");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nlinfo(QString("addObject:" + obj->objectName()).toStdString().c_str());
|
nlinfo(QString("addObject: " + obj->objectName()).toStdString().c_str());
|
||||||
|
|
||||||
_allObjects.append(obj);
|
_allObjects.append(obj);
|
||||||
|
|
||||||
|
@ -69,10 +69,10 @@ void CPluginManager::removeObject(QObject *obj)
|
||||||
|
|
||||||
if (!_allObjects.contains(obj))
|
if (!_allObjects.contains(obj))
|
||||||
{
|
{
|
||||||
nlinfo(QString("object not in list:" + obj->objectName()).toStdString().c_str());
|
nlinfo(QString("object not in list: " + obj->objectName()).toStdString().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
nlinfo(QString("removeObject:" + obj->objectName()).toStdString().c_str());
|
nlinfo(QString("removeObject: " + obj->objectName()).toStdString().c_str());
|
||||||
|
|
||||||
Q_EMIT aboutToRemoveObject(obj);
|
Q_EMIT aboutToRemoveObject(obj);
|
||||||
QWriteLocker lock(&_lock);
|
QWriteLocker lock(&_lock);
|
||||||
|
|
|
@ -96,14 +96,11 @@ sint main(int argc, char **argv)
|
||||||
Modules::config().configSearchPaths();
|
Modules::config().configSearchPaths();
|
||||||
|
|
||||||
Modules::mainWin().showMaximized();
|
Modules::mainWin().showMaximized();
|
||||||
|
Modules::plugMan().addObject(&Modules::mainWin());
|
||||||
|
|
||||||
Modules::plugMan().setPluginPaths(QStringList() << QString("./plugins"));
|
Modules::plugMan().setPluginPaths(QStringList() << QString("./plugins"));
|
||||||
Modules::plugMan().loadPlugins();
|
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());
|
splash->finish(&Modules::mainWin());
|
||||||
int result = app.exec();
|
int result = app.exec();
|
||||||
Modules::release();
|
Modules::release();
|
||||||
|
|
|
@ -60,6 +60,7 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||||
_GraphicsViewport(NULL), _lastDir(".")
|
_GraphicsViewport(NULL), _lastDir(".")
|
||||||
{
|
{
|
||||||
nldebug("CMainWindow::CMainWindow:");
|
nldebug("CMainWindow::CMainWindow:");
|
||||||
|
setObjectName("CMainWindow");
|
||||||
|
|
||||||
// create NeL viewport
|
// create NeL viewport
|
||||||
_GraphicsViewport = new CGraphicsViewport(this);
|
_GraphicsViewport = new CGraphicsViewport(this);
|
||||||
|
|
|
@ -33,12 +33,12 @@ void Modules::init()
|
||||||
if (_configuration == NULL) _configuration = new NLQT::CConfiguration;
|
if (_configuration == NULL) _configuration = new NLQT::CConfiguration;
|
||||||
config().init();
|
config().init();
|
||||||
|
|
||||||
|
if (_pluginManager == NULL) _pluginManager = new NLQT::CPluginManager;
|
||||||
if (_objectViewer == NULL) _objectViewer = new NLQT::CObjectViewer;
|
if (_objectViewer == NULL) _objectViewer = new NLQT::CObjectViewer;
|
||||||
if (_soundSystem == NULL) _soundSystem = new NLQT::CSoundSystem;
|
if (_soundSystem == NULL) _soundSystem = new NLQT::CSoundSystem;
|
||||||
if (_particleEditor == NULL) _particleEditor = new NLQT::CParticleEditor;
|
if (_particleEditor == NULL) _particleEditor = new NLQT::CParticleEditor;
|
||||||
if (_vegetableEditor == NULL) _vegetableEditor = new NLQT::CVegetableEditor;
|
if (_vegetableEditor == NULL) _vegetableEditor = new NLQT::CVegetableEditor;
|
||||||
if (_mainWindow == NULL) _mainWindow = new NLQT::CMainWindow;
|
if (_mainWindow == NULL) _mainWindow = new NLQT::CMainWindow;
|
||||||
if (_pluginManager == NULL) _pluginManager = new NLQT::CPluginManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Modules::release()
|
void Modules::release()
|
||||||
|
|
|
@ -2,15 +2,21 @@
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
|
#include <QtGui/QMainWindow>
|
||||||
|
#include <QtGui/QMenuBar>
|
||||||
|
|
||||||
|
#include "../../extension_system/plugin_spec.h"
|
||||||
|
|
||||||
using namespace Plugin;
|
using namespace Plugin;
|
||||||
|
|
||||||
bool MyPlugin::initialize(NLQT::IPluginManager *pluginManager, QString *errorString)
|
bool MyPlugin::initialize(NLQT::IPluginManager *pluginManager, QString *errorString)
|
||||||
{
|
{
|
||||||
Q_UNUSED(errorString);
|
Q_UNUSED(errorString);
|
||||||
|
_plugMan = pluginManager;
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
QList<NLQT::CPluginSpec *> listPlug = pluginManager->plugins();
|
QList<NLQT::CPluginSpec *> listPlug = pluginManager->plugins();
|
||||||
|
|
||||||
Q_FOREACH (NLQT::CPluginSpec *plugSpec, listPlug)
|
Q_FOREACH (NLQT::CPluginSpec *plugSpec, listPlug)
|
||||||
str += plugSpec->name();
|
str += plugSpec->name();
|
||||||
|
|
||||||
|
@ -22,8 +28,20 @@ bool MyPlugin::initialize(NLQT::IPluginManager *pluginManager, QString *errorStr
|
||||||
|
|
||||||
void MyPlugin::extensionsInitialized()
|
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;
|
QMessageBox msgBox;
|
||||||
msgBox.setText("extensionsInitialize Example Plugin.");
|
msgBox.setText(str);
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#define PLUGIN1_H
|
#define PLUGIN1_H
|
||||||
|
|
||||||
#include "../../extension_system/iplugin.h"
|
#include "../../extension_system/iplugin.h"
|
||||||
#include "../../extension_system/plugin_spec.h"
|
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
@ -22,6 +21,9 @@ public:
|
||||||
QString version() const;
|
QString version() const;
|
||||||
QString vendor() const;
|
QString vendor() const;
|
||||||
QString description() const;
|
QString description() const;
|
||||||
|
private:
|
||||||
|
NLQT::IPluginManager *_plugMan;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Plugin1
|
} // namespace Plugin1
|
||||||
|
|
Loading…
Reference in a new issue