From 1abd47afdbc82bf26683aeaf56158601d802855d Mon Sep 17 00:00:00 2001 From: dnk-88 Date: Wed, 1 Dec 2010 17:48:43 +0200 Subject: [PATCH] Changed: #1206 Update ovqt_example plugin. --- .../src/extension_system/plugin_manager.cpp | 6 ++--- .../tools/3d/object_viewer_qt/src/main.cpp | 5 +---- .../3d/object_viewer_qt/src/main_window.cpp | 1 + .../tools/3d/object_viewer_qt/src/modules.cpp | 2 +- .../src/plugins/example/plugin1.cpp | 22 +++++++++++++++++-- .../src/plugins/example/plugin1.h | 4 +++- 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp index 03f4fe3ac..4d8371636 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/extension_system/plugin_manager.cpp @@ -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); diff --git a/code/nel/tools/3d/object_viewer_qt/src/main.cpp b/code/nel/tools/3d/object_viewer_qt/src/main.cpp index 415463f7a..ccdd1b3d4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/main.cpp @@ -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 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(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp index 7c8b96415..d175afec4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/main_window.cpp @@ -60,6 +60,7 @@ CMainWindow::CMainWindow(QWidget *parent) _GraphicsViewport(NULL), _lastDir(".") { nldebug("CMainWindow::CMainWindow:"); + setObjectName("CMainWindow"); // create NeL viewport _GraphicsViewport = new CGraphicsViewport(this); diff --git a/code/nel/tools/3d/object_viewer_qt/src/modules.cpp b/code/nel/tools/3d/object_viewer_qt/src/modules.cpp index 949af984f..204285d97 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/modules.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/modules.cpp @@ -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() diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.cpp index 669c441a6..3c71c77be 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.cpp @@ -2,15 +2,21 @@ #include #include +#include +#include + +#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 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 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(); } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h index 9f00f2828..1e130d4f6 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/plugin1.h @@ -2,7 +2,6 @@ #define PLUGIN1_H #include "../../extension_system/iplugin.h" -#include "../../extension_system/plugin_spec.h" #include @@ -22,6 +21,9 @@ public: QString version() const; QString vendor() const; QString description() const; +private: + NLQT::IPluginManager *_plugMan; + }; } // namespace Plugin1