mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-23 07:16:15 +00:00
Changed: #1206 Update ovqt_example plugin.
This commit is contained in:
parent
5e2722e0d6
commit
165c9c686a
6 changed files with 29 additions and 11 deletions
|
@ -52,7 +52,7 @@ void CPluginManager::addObject(QObject *obj)
|
|||
nlwarning("trying to add duplicate object");
|
||||
return;
|
||||
}
|
||||
nlinfo(QString("addObject:" + obj->objectName()).toStdString().c_str());
|
||||
nlinfo(QString("addObject: " + obj->objectName()).toStdString().c_str());
|
||||
|
||||
_allObjects.append(obj);
|
||||
|
||||
|
@ -69,10 +69,10 @@ void CPluginManager::removeObject(QObject *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;
|
||||
}
|
||||
nlinfo(QString("removeObject:" + obj->objectName()).toStdString().c_str());
|
||||
nlinfo(QString("removeObject: " + obj->objectName()).toStdString().c_str());
|
||||
|
||||
Q_EMIT aboutToRemoveObject(obj);
|
||||
QWriteLocker lock(&_lock);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -60,6 +60,7 @@ CMainWindow::CMainWindow(QWidget *parent)
|
|||
_GraphicsViewport(NULL), _lastDir(".")
|
||||
{
|
||||
nldebug("CMainWindow::CMainWindow:");
|
||||
setObjectName("CMainWindow");
|
||||
|
||||
// create NeL viewport
|
||||
_GraphicsViewport = new CGraphicsViewport(this);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -2,15 +2,21 @@
|
|||
|
||||
#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)
|
||||
str += plugSpec->name();
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue