Changed: #1206 correct fix is to load the plugins and update ovqt example plugin.
This commit is contained in:
parent
f2dd3cd061
commit
21edaf9861
15 changed files with 170 additions and 85 deletions
|
@ -3,7 +3,7 @@ INCLUDE( ${QT_USE_FILE} )
|
||||||
|
|
||||||
FILE(GLOB OBJECT_VIEWER_SRC configuration.h entity.h object_viewer.h particle_editor.h modules.h sound_system.h
|
FILE(GLOB OBJECT_VIEWER_SRC configuration.h entity.h object_viewer.h particle_editor.h modules.h sound_system.h
|
||||||
particle_node.h ps_initial_pos.h dup_ps.h vegetable_editor.h vegetable_node.h
|
particle_node.h ps_initial_pos.h dup_ps.h vegetable_editor.h vegetable_node.h
|
||||||
extension_system/plugin_spec.h
|
extension_system/iplugin_spec.h extension_system/plugin_spec.h
|
||||||
extension_system/*.cpp *.cpp)
|
extension_system/*.cpp *.cpp)
|
||||||
|
|
||||||
SET(OBJECT_VIEWER_HDR main_window.h graphics_viewport.h animation_dialog.h
|
SET(OBJECT_VIEWER_HDR main_window.h graphics_viewport.h animation_dialog.h
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#ifndef IPLUGIN_H
|
#ifndef IPLUGIN_H
|
||||||
#define IPLUGIN_H
|
#define IPLUGIN_H
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtCore/QtPlugin>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
#include "iplugin_manager.h"
|
#include "iplugin_manager.h"
|
||||||
|
@ -52,6 +52,6 @@ public:
|
||||||
|
|
||||||
}; //namespace NLQT
|
}; //namespace NLQT
|
||||||
|
|
||||||
Q_DECLARE_INTERFACE(NLQT::IPlugin, "com.ryzom.dev.ObjectViewerQt.IPlugin/0.8")
|
Q_DECLARE_INTERFACE(NLQT::IPlugin, "com.ryzom.dev.ObjectViewerQt.IPlugin/0.9")
|
||||||
|
|
||||||
#endif // IPLUGIN_H
|
#endif // IPLUGIN_H
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
namespace NLQT
|
namespace NLQT
|
||||||
{
|
{
|
||||||
class CPluginSpec;
|
class IPluginSpec;
|
||||||
|
|
||||||
class IPluginManager: public QObject
|
class IPluginManager: public QObject
|
||||||
{
|
{
|
||||||
|
@ -44,9 +44,7 @@ public:
|
||||||
virtual void loadPlugins() = 0;
|
virtual void loadPlugins() = 0;
|
||||||
virtual QStringList getPluginPaths() const = 0;
|
virtual QStringList getPluginPaths() const = 0;
|
||||||
virtual void setPluginPaths(const QStringList &paths) = 0;
|
virtual void setPluginPaths(const QStringList &paths) = 0;
|
||||||
virtual QList<NLQT::CPluginSpec *> plugins() const = 0;
|
virtual QList<NLQT::IPluginSpec *> plugins() const = 0;
|
||||||
|
|
||||||
virtual CPluginSpec *pluginByName(const QString &name) const = 0;
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void objectAdded(QObject *obj);
|
void objectAdded(QObject *obj);
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
Object Viewer Qt
|
||||||
|
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IPLUGINSPEC_H
|
||||||
|
#define IPLUGINSPEC_H
|
||||||
|
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
|
namespace NLQT
|
||||||
|
{
|
||||||
|
class IPlugin;
|
||||||
|
class IPluginManager;
|
||||||
|
|
||||||
|
struct State
|
||||||
|
{
|
||||||
|
enum List
|
||||||
|
{
|
||||||
|
Invalid = 1,
|
||||||
|
Read,
|
||||||
|
Loaded,
|
||||||
|
Initialized,
|
||||||
|
Running,
|
||||||
|
Stopped,
|
||||||
|
Deleted
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
class IPluginSpec
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IPluginSpec() {}
|
||||||
|
|
||||||
|
virtual QString name() const = 0;
|
||||||
|
virtual QString version() const = 0;
|
||||||
|
virtual QString vendor() const = 0;
|
||||||
|
virtual QString description() const = 0;
|
||||||
|
|
||||||
|
virtual QString location() const = 0;
|
||||||
|
virtual QString filePath() const = 0;
|
||||||
|
virtual QString fileName() const = 0;
|
||||||
|
|
||||||
|
virtual IPlugin *plugin() const = 0;
|
||||||
|
|
||||||
|
// state
|
||||||
|
virtual int getState() const = 0;
|
||||||
|
virtual bool hasError() const = 0;
|
||||||
|
virtual QString errorString() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace NLQT
|
||||||
|
|
||||||
|
#endif // IPLUGINSPEC_H
|
||||||
|
|
|
@ -109,15 +109,16 @@ void CPluginManager::setPluginPaths(const QStringList &paths)
|
||||||
readPluginPaths();
|
readPluginPaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<CPluginSpec *> CPluginManager::plugins() const
|
QList<IPluginSpec *> CPluginManager::plugins() const
|
||||||
{
|
{
|
||||||
return _pluginSpecs;
|
return _ipluginSpecs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginManager::readPluginPaths()
|
void CPluginManager::readPluginPaths()
|
||||||
{
|
{
|
||||||
qDeleteAll(_pluginSpecs);
|
qDeleteAll(_pluginSpecs);
|
||||||
_pluginSpecs.clear();
|
_pluginSpecs.clear();
|
||||||
|
_ipluginSpecs.clear();
|
||||||
|
|
||||||
QStringList pluginsList;
|
QStringList pluginsList;
|
||||||
QStringList searchPaths = _pluginPaths;
|
QStringList searchPaths = _pluginPaths;
|
||||||
|
@ -144,19 +145,12 @@ void CPluginManager::readPluginPaths()
|
||||||
spec->setFileName(pluginFile);
|
spec->setFileName(pluginFile);
|
||||||
spec->_pluginManager = this;
|
spec->_pluginManager = this;
|
||||||
_pluginSpecs.append(spec);
|
_pluginSpecs.append(spec);
|
||||||
|
_ipluginSpecs.append(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EMIT pluginsChanged();
|
Q_EMIT pluginsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginSpec *CPluginManager::pluginByName(const QString &name) const
|
|
||||||
{
|
|
||||||
Q_FOREACH (CPluginSpec *spec, _pluginSpecs)
|
|
||||||
if (spec->name() == name)
|
|
||||||
return spec;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CPluginManager::setPluginState(CPluginSpec *spec, int destState)
|
void CPluginManager::setPluginState(CPluginSpec *spec, int destState)
|
||||||
{
|
{
|
||||||
if (spec->hasError())
|
if (spec->hasError())
|
||||||
|
|
|
@ -30,6 +30,7 @@ namespace NLQT
|
||||||
{
|
{
|
||||||
|
|
||||||
class IPlugin;
|
class IPlugin;
|
||||||
|
class CPluginSpec;
|
||||||
|
|
||||||
class CPluginManager : public IPluginManager
|
class CPluginManager : public IPluginManager
|
||||||
{
|
{
|
||||||
|
@ -48,9 +49,7 @@ public:
|
||||||
virtual void loadPlugins();
|
virtual void loadPlugins();
|
||||||
virtual QStringList getPluginPaths() const;
|
virtual QStringList getPluginPaths() const;
|
||||||
virtual void setPluginPaths(const QStringList &paths);
|
virtual void setPluginPaths(const QStringList &paths);
|
||||||
virtual QList<CPluginSpec *> plugins() const;
|
virtual QList<IPluginSpec *> plugins() const;
|
||||||
|
|
||||||
virtual CPluginSpec *pluginByName(const QString &name) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setPluginState(CPluginSpec *spec, int destState);
|
void setPluginState(CPluginSpec *spec, int destState);
|
||||||
|
@ -60,6 +59,7 @@ private:
|
||||||
mutable QReadWriteLock _lock;
|
mutable QReadWriteLock _lock;
|
||||||
|
|
||||||
QList<CPluginSpec *> _pluginSpecs;
|
QList<CPluginSpec *> _pluginSpecs;
|
||||||
|
QList<IPluginSpec *> _ipluginSpecs;
|
||||||
QStringList _pluginPaths;
|
QStringList _pluginPaths;
|
||||||
QList<QObject *> _allObjects;
|
QList<QObject *> _allObjects;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "plugin_spec.h"
|
#include "plugin_spec.h"
|
||||||
|
|
||||||
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
#include <QtCore/QPluginLoader>
|
#include <QtCore/QPluginLoader>
|
||||||
|
@ -40,10 +41,6 @@ CPluginSpec::CPluginSpec():
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CPluginSpec::~CPluginSpec()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CPluginSpec::name() const
|
QString CPluginSpec::name() const
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
|
|
|
@ -20,48 +20,29 @@
|
||||||
#ifndef PLUGINSPEC_H
|
#ifndef PLUGINSPEC_H
|
||||||
#define PLUGINSPEC_H
|
#define PLUGINSPEC_H
|
||||||
|
|
||||||
#include <QtCore/QString>
|
#include "iplugin_spec.h"
|
||||||
#include <QtCore/QList>
|
|
||||||
|
|
||||||
namespace NLQT
|
namespace NLQT
|
||||||
{
|
{
|
||||||
class IPlugin;
|
|
||||||
class IPluginManager;
|
|
||||||
|
|
||||||
struct State
|
class CPluginSpec: public IPluginSpec
|
||||||
{
|
|
||||||
enum List
|
|
||||||
{
|
|
||||||
Invalid = 1,
|
|
||||||
Read,
|
|
||||||
Loaded,
|
|
||||||
Initialized,
|
|
||||||
Running,
|
|
||||||
Stopped,
|
|
||||||
Deleted
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
class CPluginSpec
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~CPluginSpec();
|
virtual QString name() const;
|
||||||
|
virtual QString version() const;
|
||||||
|
virtual QString vendor() const;
|
||||||
|
virtual QString description() const;
|
||||||
|
|
||||||
QString name() const;
|
virtual QString location() const;
|
||||||
QString version() const;
|
virtual QString filePath() const;
|
||||||
QString vendor() const;
|
virtual QString fileName() const;
|
||||||
QString description() const;
|
|
||||||
|
|
||||||
QString location() const;
|
virtual IPlugin *plugin() const;
|
||||||
QString filePath() const;
|
|
||||||
QString fileName() const;
|
|
||||||
|
|
||||||
IPlugin *plugin() const;
|
|
||||||
|
|
||||||
// state
|
// state
|
||||||
int getState() const;
|
virtual int getState() const;
|
||||||
bool hasError() const;
|
virtual bool hasError() const;
|
||||||
QString errorString() const;
|
virtual QString errorString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CPluginSpec();
|
CPluginSpec();
|
||||||
|
|
|
@ -19,12 +19,24 @@
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0" colspan="4">
|
<item row="0" column="0" colspan="4">
|
||||||
<widget class="QTreeWidget" name="pluginTreeWidget">
|
<widget class="QTreeWidget" name="pluginTreeWidget">
|
||||||
|
<property name="alternatingRowColors">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="indentation">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<property name="rootIsDecorated">
|
<property name="rootIsDecorated">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="uniformRowHeights">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="itemsExpandable">
|
<property name="itemsExpandable">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sortingEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>State</string>
|
<string>State</string>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
#include <QtGui/QTreeWidgetItem>
|
#include <QtGui/QTreeWidgetItem>
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "plugin_spec.h"
|
#include "iplugin_spec.h"
|
||||||
#include "iplugin_manager.h"
|
#include "iplugin_manager.h"
|
||||||
|
|
||||||
namespace NLQT
|
namespace NLQT
|
||||||
|
@ -55,7 +55,7 @@ void CPluginView::updateList()
|
||||||
static QIcon errorIcon = QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton);
|
static QIcon errorIcon = QApplication::style()->standardIcon(QStyle::SP_DialogCancelButton);
|
||||||
|
|
||||||
QList<QTreeWidgetItem *> items;
|
QList<QTreeWidgetItem *> items;
|
||||||
Q_FOREACH (CPluginSpec *spec, _pluginManager->plugins())
|
Q_FOREACH (IPluginSpec *spec, _pluginManager->plugins())
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList()
|
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList()
|
||||||
<< ""
|
<< ""
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <nel/misc/file.h>
|
#include <nel/misc/file.h>
|
||||||
#include <nel/misc/path.h>
|
#include <nel/misc/path.h>
|
||||||
#include <nel/misc/command.h>
|
#include <nel/misc/command.h>
|
||||||
#include "extension_system/plugin_spec.h"
|
#include "extension_system/iplugin_spec.h"
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "modules.h"
|
#include "modules.h"
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ sint main(int argc, char **argv)
|
||||||
Modules::plugMan().loadPlugins();
|
Modules::plugMan().loadPlugins();
|
||||||
|
|
||||||
QStringList errors;
|
QStringList errors;
|
||||||
Q_FOREACH (NLQT::CPluginSpec *spec, Modules::plugMan().plugins())
|
Q_FOREACH (NLQT::IPluginSpec *spec, Modules::plugMan().plugins())
|
||||||
if (spec->hasError())
|
if (spec->hasError())
|
||||||
errors.append(spec->fileName() + " : " + spec->errorString());
|
errors.append(spec->fileName() + " : " + spec->errorString());
|
||||||
|
|
||||||
|
|
|
@ -354,19 +354,23 @@ void CMainWindow::createActions()
|
||||||
void CMainWindow::createMenus()
|
void CMainWindow::createMenus()
|
||||||
{
|
{
|
||||||
_fileMenu = menuBar()->addMenu(tr("&File"));
|
_fileMenu = menuBar()->addMenu(tr("&File"));
|
||||||
|
_fileMenu->setObjectName("ovqt.Menu.File");
|
||||||
_fileMenu->addAction(_openAction);
|
_fileMenu->addAction(_openAction);
|
||||||
_fileMenu->addSeparator();
|
_fileMenu->addSeparator();
|
||||||
_fileMenu->addAction(_exitAction);
|
_fileMenu->addAction(_exitAction);
|
||||||
|
|
||||||
_viewMenu = menuBar()->addMenu(tr("&View"));
|
_viewMenu = menuBar()->addMenu(tr("&View"));
|
||||||
|
_viewMenu->setObjectName("ovqt.Menu.View");
|
||||||
_viewMenu->addAction(_setBackColorAction);
|
_viewMenu->addAction(_setBackColorAction);
|
||||||
_viewMenu->addAction(_SetupFog->toggleViewAction());
|
_viewMenu->addAction(_SetupFog->toggleViewAction());
|
||||||
|
|
||||||
_sceneMenu = menuBar()->addMenu(tr("&Scene"));
|
_sceneMenu = menuBar()->addMenu(tr("&Scene"));
|
||||||
|
_sceneMenu->setObjectName("ovqt.Menu.Scene");
|
||||||
_sceneMenu->addAction(_resetSceneAction);
|
_sceneMenu->addAction(_resetSceneAction);
|
||||||
_sceneMenu->addAction(_saveScreenshotAction);
|
_sceneMenu->addAction(_saveScreenshotAction);
|
||||||
|
|
||||||
_toolsMenu = menuBar()->addMenu(tr("&Tools"));
|
_toolsMenu = menuBar()->addMenu(tr("&Tools"));
|
||||||
|
_toolsMenu->setObjectName("ovqt.Menu.Tools");
|
||||||
|
|
||||||
_toolsMenu->addAction(_AnimationDialog->toggleViewAction());
|
_toolsMenu->addAction(_AnimationDialog->toggleViewAction());
|
||||||
_AnimationDialog->toggleViewAction()->setIcon(QIcon(":/images/anim.png"));
|
_AnimationDialog->toggleViewAction()->setIcon(QIcon(":/images/anim.png"));
|
||||||
|
@ -411,9 +415,16 @@ void CMainWindow::createMenus()
|
||||||
menuBar()->addSeparator();
|
menuBar()->addSeparator();
|
||||||
|
|
||||||
_helpMenu = menuBar()->addMenu(tr("&Help"));
|
_helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||||
|
_helpMenu->setObjectName("ovqt.Menu.Help");
|
||||||
_helpMenu->addAction(_aboutAction);
|
_helpMenu->addAction(_aboutAction);
|
||||||
_helpMenu->addAction(_aboutQtAction);
|
_helpMenu->addAction(_aboutQtAction);
|
||||||
_helpMenu->addAction(_pluginViewAction);
|
_helpMenu->addAction(_pluginViewAction);
|
||||||
|
|
||||||
|
Modules::plugMan().addObject(_fileMenu);
|
||||||
|
Modules::plugMan().addObject(_viewMenu);
|
||||||
|
Modules::plugMan().addObject(_sceneMenu);
|
||||||
|
Modules::plugMan().addObject(_toolsMenu);
|
||||||
|
Modules::plugMan().addObject(_helpMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::createToolBars()
|
void CMainWindow::createToolBars()
|
||||||
|
|
|
@ -6,8 +6,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
FILE(GLOB SRC *.cpp *.h)
|
FILE(GLOB SRC *.cpp *.h)
|
||||||
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
|
SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h
|
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_manager.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/plugin_spec.h
|
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/plugin_spec.cpp)
|
|
||||||
|
|
||||||
SET(OVQT_PLUG_EXAMPLE_HDR plugin1.h)
|
SET(OVQT_PLUG_EXAMPLE_HDR plugin1.h)
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,11 @@
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QtGui/QMessageBox>
|
||||||
#include <QtGui/QMainWindow>
|
#include <QtGui/QMainWindow>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
#include <QtGui/QAction>
|
||||||
#include <QtGui/QMenuBar>
|
#include <QtGui/QMenuBar>
|
||||||
|
|
||||||
#include "../../extension_system/plugin_spec.h"
|
#include "../../extension_system/iplugin_spec.h"
|
||||||
|
|
||||||
#include "nel/misc/debug.h"
|
#include "nel/misc/debug.h"
|
||||||
|
|
||||||
|
@ -17,36 +19,30 @@ bool MyPlugin::initialize(NLQT::IPluginManager *pluginManager, QString *errorStr
|
||||||
_plugMan = pluginManager;
|
_plugMan = pluginManager;
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
QList<NLQT::CPluginSpec *> listPlug = pluginManager->plugins();
|
QList<NLQT::IPluginSpec *> listPlug = pluginManager->plugins();
|
||||||
|
|
||||||
Q_FOREACH (NLQT::CPluginSpec *plugSpec, listPlug)
|
Q_FOREACH (NLQT::IPluginSpec *plugSpec, listPlug)
|
||||||
str += plugSpec->name();
|
str += plugSpec->name();
|
||||||
|
|
||||||
QMessageBox msgBox;
|
nlinfo(str.toStdString().c_str());
|
||||||
msgBox.setText(str);
|
|
||||||
msgBox.exec();
|
|
||||||
|
|
||||||
nlinfo("test message");
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyPlugin::extensionsInitialized()
|
void MyPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
QString str;
|
QMenu *helpMenu = qobject_cast<QMenu *>(objectByName("ovqt.Menu.Help"));
|
||||||
QList<QObject *> listObjects = _plugMan->allObjects();
|
helpMenu->addSeparator();
|
||||||
|
QAction *newAction = helpMenu->addAction("MyPlugin");
|
||||||
|
|
||||||
Q_FOREACH (QObject *qobj, listObjects)
|
connect(newAction, SIGNAL(triggered()), this, SLOT(execMessageBox()));
|
||||||
{
|
|
||||||
if (qobj->objectName() == "CMainWindow")
|
|
||||||
{
|
|
||||||
QMainWindow *wnd = qobject_cast< QMainWindow* >(qobj);
|
|
||||||
str += qobj->objectName() + QString(": width=%1,height=%2").arg(wnd->width()).arg(wnd->height());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyPlugin::execMessageBox()
|
||||||
|
{
|
||||||
|
QMainWindow *wnd = qobject_cast<QMainWindow *>(objectByName("CMainWindow"));
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setText(str);
|
msgBox.setText(wnd->objectName() + QString(": width=%1,height=%2").arg(wnd->width()).arg(wnd->height()));
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,17 +59,33 @@ QString MyPlugin::name() const
|
||||||
|
|
||||||
QString MyPlugin::version() const
|
QString MyPlugin::version() const
|
||||||
{
|
{
|
||||||
return "0.1";
|
return "0.2";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MyPlugin::vendor() const
|
QString MyPlugin::vendor() const
|
||||||
{
|
{
|
||||||
return "dnk";
|
return "dnk-88";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MyPlugin::description() const
|
QString MyPlugin::description() const
|
||||||
{
|
{
|
||||||
return "Example plugin";
|
return "Example ovqt plugin.";
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject* MyPlugin::objectByName(const QString &name) const
|
||||||
|
{
|
||||||
|
Q_FOREACH (QObject *qobj, _plugMan->allObjects())
|
||||||
|
if (qobj->objectName() == name)
|
||||||
|
return qobj;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
NLQT::IPluginSpec *MyPlugin::pluginByName(const QString &name) const
|
||||||
|
{
|
||||||
|
Q_FOREACH (NLQT::IPluginSpec *spec, _plugMan->plugins())
|
||||||
|
if (spec->name() == name)
|
||||||
|
return spec;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(MyPlugin)
|
Q_EXPORT_PLUGIN(MyPlugin)
|
||||||
|
|
|
@ -11,6 +11,12 @@ namespace NLMISC
|
||||||
{
|
{
|
||||||
class CLibraryContext;
|
class CLibraryContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace NLQT
|
||||||
|
{
|
||||||
|
class IPluginSpec;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Plugin
|
namespace Plugin
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -30,6 +36,12 @@ public:
|
||||||
QString vendor() const;
|
QString vendor() const;
|
||||||
QString description() const;
|
QString description() const;
|
||||||
|
|
||||||
|
QObject *objectByName(const QString &name) const;
|
||||||
|
NLQT::IPluginSpec *pluginByName(const QString &name) const;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void execMessageBox();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NLMISC::CLibraryContext *_LibContext;
|
NLMISC::CLibraryContext *_LibContext;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue