mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-25 02:10:53 +00:00
Changed: #1206 Added menu manager. Update core and example plugin.
This commit is contained in:
parent
6192d39d50
commit
b6aed0f876
21 changed files with 405 additions and 94 deletions
|
@ -20,6 +20,8 @@
|
||||||
#ifndef IPLUGINMANAGER_H
|
#ifndef IPLUGINMANAGER_H
|
||||||
#define IPLUGINMANAGER_H
|
#define IPLUGINMANAGER_H
|
||||||
|
|
||||||
|
#include "plugin_spec.h"
|
||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
@ -59,6 +61,68 @@ public:
|
||||||
virtual void setSettings(QSettings *settings) = 0;
|
virtual void setSettings(QSettings *settings) = 0;
|
||||||
virtual QSettings *settings() const = 0;
|
virtual QSettings *settings() const = 0;
|
||||||
|
|
||||||
|
// Auxiliary operations
|
||||||
|
template <typename T>
|
||||||
|
QList<T *> getObjects() const
|
||||||
|
{
|
||||||
|
QList<QObject *> all = allObjects();
|
||||||
|
QList<T *> objects;
|
||||||
|
Q_FOREACH(QObject *obj, all)
|
||||||
|
{
|
||||||
|
T *tObj = qobject_cast<T *>(obj);
|
||||||
|
if (tObj)
|
||||||
|
objects.append(tObj);
|
||||||
|
}
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T *getObject() const
|
||||||
|
{
|
||||||
|
QList<QObject *> all = allObjects();
|
||||||
|
T *result = 0;
|
||||||
|
Q_FOREACH(QObject *obj, all)
|
||||||
|
{
|
||||||
|
T *tObj = qobject_cast<T *>(obj);
|
||||||
|
if (tObj)
|
||||||
|
{
|
||||||
|
result = tObj;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject *objectByName(const QString &name) const
|
||||||
|
{
|
||||||
|
QList<QObject *> all = allObjects();
|
||||||
|
QObject *result = 0;
|
||||||
|
Q_FOREACH (QObject *qobj, all)
|
||||||
|
{
|
||||||
|
if (qobj->objectName() == name)
|
||||||
|
{
|
||||||
|
result = qobj;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const
|
||||||
|
{
|
||||||
|
QList<ExtensionSystem::IPluginSpec *> all = plugins();
|
||||||
|
ExtensionSystem::IPluginSpec *result = 0;
|
||||||
|
Q_FOREACH (ExtensionSystem::IPluginSpec *spec, all)
|
||||||
|
{
|
||||||
|
if (spec->name() == name)
|
||||||
|
{
|
||||||
|
result = spec;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void objectAdded(QObject *obj);
|
void objectAdded(QObject *obj);
|
||||||
void aboutToRemoveObject(QObject *obj);
|
void aboutToRemoveObject(QObject *obj);
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
|
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
#include "plugin_spec.h"
|
|
||||||
|
|
||||||
namespace ExtensionSystem
|
namespace ExtensionSystem
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,12 @@ SET(OVQT_EXT_SYS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin.
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
${CMAKE_CURRENT_SOURCE_DIR}/../../extension_system/iplugin_spec.h)
|
||||||
|
|
||||||
SET(OVQT_CORE_PLUGIN_HDR
|
SET(OVQT_CORE_PLUGIN_HDR
|
||||||
|
imenu_manager.h
|
||||||
|
icore_listener.h
|
||||||
|
ioptions_page.h
|
||||||
core_plugin.h
|
core_plugin.h
|
||||||
main_window.h
|
main_window.h
|
||||||
|
menu_manager.h
|
||||||
settings_dialog.h
|
settings_dialog.h
|
||||||
search_paths_settings_page.h
|
search_paths_settings_page.h
|
||||||
plugin_view_dialog.h)
|
plugin_view_dialog.h)
|
||||||
|
@ -34,7 +38,7 @@ SOURCE_GROUP(QtGeneratedMocSrc FILES ${OVQT_CORE_PLUGIN_MOC_SRC})
|
||||||
SOURCE_GROUP("Core Plugin" FILES ${SRC})
|
SOURCE_GROUP("Core Plugin" FILES ${SRC})
|
||||||
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
||||||
|
|
||||||
ADD_LIBRARY(ovqt_plugin_core MODULE ${SRC} ${OVQT_CORE_PLUGIN_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_CORE_PLUGIN_RC_SRCS} ${OVQT_CORE_PLUGIN_UI_HDRS})
|
ADD_LIBRARY(ovqt_plugin_core SHARED ${SRC} ${OVQT_CORE_PLUGIN_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_CORE_PLUGIN_RC_SRCS} ${OVQT_CORE_PLUGIN_UI_HDRS})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(ovqt_plugin_core nelmisc ${QT_LIBRARIES})
|
TARGET_LINK_LIBRARIES(ovqt_plugin_core nelmisc ${QT_LIBRARIES})
|
||||||
|
|
||||||
|
@ -42,6 +46,6 @@ NL_DEFAULT_PROPS(ovqt_plugin_core "NeL, Tools, 3D: Object Viewer Qt Plugin: Core
|
||||||
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_core)
|
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_core)
|
||||||
NL_ADD_LIB_SUFFIX(ovqt_plugin_core)
|
NL_ADD_LIB_SUFFIX(ovqt_plugin_core)
|
||||||
|
|
||||||
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
|
ADD_DEFINITIONS(-DCORE_LIBRARY ${LIBXML2_DEFINITIONS} -DQT_PLUGIN -DQT_SHARED ${QT_DEFINITIONS})
|
||||||
|
|
||||||
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d)
|
INSTALL(TARGETS ovqt_plugin_core LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d)
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
// Copyright (C) 2011 Dzmitry Kamiahin <dnk-88@tut.by>
|
||||||
|
// Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef CORE_GLOBAL_H
|
||||||
|
#define CORE_GLOBAL_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
#if defined(CORE_LIBRARY)
|
||||||
|
# define CORE_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define CORE_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // CORE_GLOBAL_H
|
|
@ -56,21 +56,13 @@ bool CorePlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStr
|
||||||
_plugMan = pluginManager;
|
_plugMan = pluginManager;
|
||||||
_oldOVQT = false;
|
_oldOVQT = false;
|
||||||
|
|
||||||
addAutoReleasedObject(new CSearchPathsSettingsPage(this));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CorePlugin::extensionsInitialized()
|
|
||||||
{
|
|
||||||
_pluginView = new ExtensionSystem::CPluginView(_plugMan);
|
|
||||||
|
|
||||||
// for old ovqt
|
// for old ovqt
|
||||||
QMainWindow *wnd = qobject_cast<QMainWindow *>(objectByName("CMainWindow"));
|
QMainWindow *wnd = qobject_cast<QMainWindow *>(_plugMan->objectByName("CMainWindow"));
|
||||||
if (wnd)
|
if (wnd)
|
||||||
{
|
{
|
||||||
_pluginView = new ExtensionSystem::CPluginView(_plugMan);
|
_pluginView = new ExtensionSystem::CPluginView(_plugMan);
|
||||||
QMenu *toolsMenu = qobject_cast<QMenu *>(objectByName("ovqt.Menu.Tools"));
|
QMenu *toolsMenu = qobject_cast<QMenu *>(_plugMan->objectByName("ovqt.Menu.Tools"));
|
||||||
QMenu *helpMenu = qobject_cast<QMenu *>(objectByName("ovqt.Menu.Help"));
|
QMenu *helpMenu = qobject_cast<QMenu *>(_plugMan->objectByName("ovqt.Menu.Help"));
|
||||||
nlassert(toolsMenu);
|
nlassert(toolsMenu);
|
||||||
nlassert(helpMenu);
|
nlassert(helpMenu);
|
||||||
|
|
||||||
|
@ -103,6 +95,14 @@ void CorePlugin::extensionsInitialized()
|
||||||
}
|
}
|
||||||
_mainWindow->show();
|
_mainWindow->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addAutoReleasedObject(new CSearchPathsSettingsPage(this));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CorePlugin::extensionsInitialized()
|
||||||
|
{
|
||||||
|
_pluginView = new ExtensionSystem::CPluginView(_plugMan);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CorePlugin::shutdown()
|
void CorePlugin::shutdown()
|
||||||
|
@ -162,20 +162,4 @@ void CorePlugin::addAutoReleasedObject(QObject *obj)
|
||||||
_autoReleaseObjects.prepend(obj);
|
_autoReleaseObjects.prepend(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject* CorePlugin::objectByName(const QString &name) const
|
|
||||||
{
|
|
||||||
Q_FOREACH (QObject *qobj, _plugMan->allObjects())
|
|
||||||
if (qobj->objectName() == name)
|
|
||||||
return qobj;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtensionSystem::IPluginSpec *CorePlugin::pluginByName(const QString &name) const
|
|
||||||
{
|
|
||||||
Q_FOREACH (ExtensionSystem::IPluginSpec *spec, _plugMan->plugins())
|
|
||||||
if (spec->name() == name)
|
|
||||||
return spec;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(CorePlugin)
|
Q_EXPORT_PLUGIN(CorePlugin)
|
||||||
|
|
|
@ -61,44 +61,11 @@ public:
|
||||||
|
|
||||||
void addAutoReleasedObject(QObject *obj);
|
void addAutoReleasedObject(QObject *obj);
|
||||||
|
|
||||||
QObject *objectByName(const QString &name) const;
|
|
||||||
ExtensionSystem::IPluginSpec *pluginByName(const QString &name) const;
|
|
||||||
ExtensionSystem::IPluginManager *pluginManager() const
|
ExtensionSystem::IPluginManager *pluginManager() const
|
||||||
{
|
{
|
||||||
return _plugMan;
|
return _plugMan;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
QList<T *> getObjects() const
|
|
||||||
{
|
|
||||||
QList<QObject *> all = _plugMan->allObjects();
|
|
||||||
QList<T *> objects;
|
|
||||||
Q_FOREACH(QObject *obj, all)
|
|
||||||
{
|
|
||||||
T *tObj = qobject_cast<T *>(obj);
|
|
||||||
if (tObj)
|
|
||||||
objects.append(tObj);
|
|
||||||
}
|
|
||||||
return objects;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
T *getObject() const
|
|
||||||
{
|
|
||||||
QList<QObject *> all = _plugMan->allObjects();
|
|
||||||
T *result = 0;
|
|
||||||
Q_FOREACH(QObject *obj, all)
|
|
||||||
{
|
|
||||||
T *tObj = qobject_cast<T *>(obj);
|
|
||||||
if (tObj)
|
|
||||||
{
|
|
||||||
result = tObj;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NLMISC::CLibraryContext *_LibContext;
|
NLMISC::CLibraryContext *_LibContext;
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,15 @@
|
||||||
#ifndef ICORE_LISTENER_H
|
#ifndef ICORE_LISTENER_H
|
||||||
#define ICORE_LISTENER_H
|
#define ICORE_LISTENER_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "core_global.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
@ -40,9 +46,11 @@ PluginManager->addObject(yourImplementingObject);
|
||||||
Don't forget to remove the object again at deconstruction (e.g. in the destructor of
|
Don't forget to remove the object again at deconstruction (e.g. in the destructor of
|
||||||
your plugin)
|
your plugin)
|
||||||
*/
|
*/
|
||||||
class ICoreListener
|
class CORE_EXPORT ICoreListener: public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
ICoreListener(QObject *parent = 0): QObject(parent) {}
|
||||||
virtual ~ICoreListener() {}
|
virtual ~ICoreListener() {}
|
||||||
|
|
||||||
/// Return false from the implemented method if you want to prevent the event.
|
/// Return false from the implemented method if you want to prevent the event.
|
||||||
|
@ -51,6 +59,5 @@ public:
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
Q_DECLARE_INTERFACE(Core::ICoreListener, "dev.ryzom.com.ICoreListener/0.1")
|
|
||||||
|
|
||||||
#endif // ICORE_LISTENER_H
|
#endif // ICORE_LISTENER_H
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
// Copyright (C) 2011 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 Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef IMENU_MANAGER_H
|
||||||
|
#define IMENU_MANAGER_H
|
||||||
|
|
||||||
|
#include "core_global.h"
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
|
#include <QtCore/QList>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QMenu;
|
||||||
|
class QAction;
|
||||||
|
class QString;
|
||||||
|
class QMenuBar;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
@interface IMenuManager
|
||||||
|
@brief The IMenuManager is an interface for providing a registration of menus and menu item.
|
||||||
|
@details The IMenuManager provides centralized access to menus and menu items.
|
||||||
|
All menus and menu items should be registered in the IMenuManager.
|
||||||
|
*/
|
||||||
|
class CORE_EXPORT IMenuManager : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
IMenuManager(QObject *parent = 0): QObject(parent) {}
|
||||||
|
virtual ~IMenuManager() {}
|
||||||
|
|
||||||
|
virtual void registerMenu(QMenu *menu, const QString &id) = 0;
|
||||||
|
virtual void registerAction(QAction *action, const QString &id) = 0;
|
||||||
|
|
||||||
|
virtual QMenu *menu(const QString &id) const = 0;
|
||||||
|
virtual QAction *action(const QString &id) const = 0;
|
||||||
|
|
||||||
|
virtual void unregisterMenu(const QString &id) = 0;
|
||||||
|
virtual void unregisterAction(const QString &id) = 0;
|
||||||
|
|
||||||
|
virtual QMenuBar *menuBar() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
#endif // IMENU_MANAGER_H
|
|
@ -19,9 +19,15 @@
|
||||||
#ifndef IOPTIONS_PAGE_H
|
#ifndef IOPTIONS_PAGE_H
|
||||||
#define IOPTIONS_PAGE_H
|
#define IOPTIONS_PAGE_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "core_global.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
@ -31,9 +37,11 @@ namespace Core
|
||||||
@details You need to subclass this interface and put an instance of your subclass
|
@details You need to subclass this interface and put an instance of your subclass
|
||||||
into the plugin manager object pool.
|
into the plugin manager object pool.
|
||||||
*/
|
*/
|
||||||
class IOptionsPage
|
class CORE_EXPORT IOptionsPage: public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
IOptionsPage(QObject *parent = 0): QObject(parent) {}
|
||||||
virtual ~IOptionsPage() {}
|
virtual ~IOptionsPage() {}
|
||||||
|
|
||||||
/// id() is a unique identifier for referencing this page
|
/// id() is a unique identifier for referencing this page
|
||||||
|
@ -61,6 +69,4 @@ public:
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
Q_DECLARE_INTERFACE(Core::IOptionsPage, "dev.ryzom.com.IOptionsPage/1.0")
|
|
||||||
|
|
||||||
#endif // IOPTIONS_PAGE_H
|
#endif // IOPTIONS_PAGE_H
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "main_window.h"
|
#include "main_window.h"
|
||||||
|
#include "menu_manager.h"
|
||||||
#include "core_plugin.h"
|
#include "core_plugin.h"
|
||||||
#include "iapp_page.h"
|
#include "iapp_page.h"
|
||||||
#include "icore_listener.h"
|
#include "icore_listener.h"
|
||||||
|
@ -34,7 +35,11 @@ namespace Core
|
||||||
|
|
||||||
CMainWindow::CMainWindow(CorePlugin *corePlugin, QWidget *parent)
|
CMainWindow::CMainWindow(CorePlugin *corePlugin, QWidget *parent)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
_lastDir(".")
|
_pluginManager(0),
|
||||||
|
_corePlugin(0),
|
||||||
|
_menuManager(0),
|
||||||
|
_lastDir("."),
|
||||||
|
_settings(0)
|
||||||
{
|
{
|
||||||
_corePlugin = corePlugin;
|
_corePlugin = corePlugin;
|
||||||
_pluginManager = _corePlugin->pluginManager();
|
_pluginManager = _corePlugin->pluginManager();
|
||||||
|
@ -42,11 +47,15 @@ CMainWindow::CMainWindow(CorePlugin *corePlugin, QWidget *parent)
|
||||||
|
|
||||||
setObjectName(Constants::MAIN_WINDOW);
|
setObjectName(Constants::MAIN_WINDOW);
|
||||||
|
|
||||||
|
_menuManager = new MenuManager(this);
|
||||||
|
_menuManager->setMenuBar(menuBar());
|
||||||
|
_pluginManager->addObject(_menuManager);
|
||||||
|
|
||||||
_tabWidget = new QTabWidget(this);
|
_tabWidget = new QTabWidget(this);
|
||||||
_tabWidget->setTabPosition(QTabWidget::South);
|
_tabWidget->setTabPosition(QTabWidget::South);
|
||||||
setCentralWidget(_tabWidget);
|
setCentralWidget(_tabWidget);
|
||||||
|
|
||||||
QList<IAppPage *> listAppPages = _corePlugin->getObjects<IAppPage>();
|
QList<IAppPage *> listAppPages = _pluginManager->getObjects<IAppPage>();
|
||||||
|
|
||||||
Q_FOREACH(IAppPage *appPage, listAppPages)
|
Q_FOREACH(IAppPage *appPage, listAppPages)
|
||||||
{
|
{
|
||||||
|
@ -72,7 +81,11 @@ CMainWindow::CMainWindow(CorePlugin *corePlugin, QWidget *parent)
|
||||||
|
|
||||||
CMainWindow::~CMainWindow()
|
CMainWindow::~CMainWindow()
|
||||||
{
|
{
|
||||||
delete _pluginView;
|
}
|
||||||
|
|
||||||
|
IMenuManager *CMainWindow::menuManager() const
|
||||||
|
{
|
||||||
|
return _menuManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::checkObject(QObject *obj)
|
void CMainWindow::checkObject(QObject *obj)
|
||||||
|
@ -102,7 +115,7 @@ void CMainWindow::about()
|
||||||
|
|
||||||
void CMainWindow::closeEvent(QCloseEvent *event)
|
void CMainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
QList<ICoreListener *> listeners = _corePlugin->getObjects<ICoreListener>();
|
QList<ICoreListener *> listeners = _pluginManager->getObjects<ICoreListener>();
|
||||||
Q_FOREACH(ICoreListener *listener, listeners)
|
Q_FOREACH(ICoreListener *listener, listeners)
|
||||||
{
|
{
|
||||||
if (!listener->closeMainWindow())
|
if (!listener->closeMainWindow())
|
||||||
|
@ -113,8 +126,7 @@ void CMainWindow::closeEvent(QCloseEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
writeSettings();
|
writeSettings();
|
||||||
|
event->accept();
|
||||||
QMainWindow::closeEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::addAppPage(IAppPage *appPage)
|
void CMainWindow::addAppPage(IAppPage *appPage)
|
||||||
|
@ -133,46 +145,52 @@ void CMainWindow::createActions()
|
||||||
_openAction->setIcon(QIcon(":/images/open-file.png"));
|
_openAction->setIcon(QIcon(":/images/open-file.png"));
|
||||||
_openAction->setShortcut(QKeySequence::Open);
|
_openAction->setShortcut(QKeySequence::Open);
|
||||||
_openAction->setStatusTip(tr("Open an existing file"));
|
_openAction->setStatusTip(tr("Open an existing file"));
|
||||||
|
menuManager()->registerAction(_openAction, Constants::OPEN);
|
||||||
// connect(_openAction, SIGNAL(triggered()), this, SLOT(open()));
|
// connect(_openAction, SIGNAL(triggered()), this, SLOT(open()));
|
||||||
|
|
||||||
_exitAction = new QAction(tr("E&xit"), this);
|
_exitAction = new QAction(tr("E&xit"), this);
|
||||||
_exitAction->setShortcut(tr("Ctrl+Q"));
|
_exitAction->setShortcut(tr("Ctrl+Q"));
|
||||||
_exitAction->setStatusTip(tr("Exit the application"));
|
_exitAction->setStatusTip(tr("Exit the application"));
|
||||||
|
menuManager()->registerAction(_exitAction, Constants::EXIT);
|
||||||
connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
|
connect(_exitAction, SIGNAL(triggered()), this, SLOT(close()));
|
||||||
|
|
||||||
_settingsAction = new QAction(tr("&Settings"), this);
|
_settingsAction = new QAction(tr("&Settings"), this);
|
||||||
_settingsAction->setIcon(QIcon(":/images/preferences.png"));
|
_settingsAction->setIcon(QIcon(":/images/preferences.png"));
|
||||||
_settingsAction->setStatusTip(tr("Open the settings dialog"));
|
_settingsAction->setStatusTip(tr("Open the settings dialog"));
|
||||||
|
menuManager()->registerAction(_settingsAction, Constants::SETTINGS);
|
||||||
connect(_settingsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog()));
|
connect(_settingsAction, SIGNAL(triggered()), this, SLOT(showOptionsDialog()));
|
||||||
|
|
||||||
_aboutAction = new QAction(tr("&About"), this);
|
_aboutAction = new QAction(tr("&About"), this);
|
||||||
_aboutAction->setStatusTip(tr("Show the application's About box"));
|
_aboutAction->setStatusTip(tr("Show the application's About box"));
|
||||||
|
menuManager()->registerAction(_aboutAction, Constants::ABOUT);
|
||||||
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about()));
|
||||||
|
|
||||||
_aboutQtAction = new QAction(tr("About &Qt"), this);
|
_aboutQtAction = new QAction(tr("About &Qt"), this);
|
||||||
_aboutQtAction->setStatusTip(tr("Show the Qt library's About box"));
|
_aboutQtAction->setStatusTip(tr("Show the Qt library's About box"));
|
||||||
|
menuManager()->registerAction(_aboutQtAction, Constants::ABOUT_QT);
|
||||||
connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
||||||
|
|
||||||
_pluginViewAction = new QAction(tr("About &Plugins"), this);
|
_pluginViewAction = new QAction(tr("About &Plugins"), this);
|
||||||
_pluginViewAction->setStatusTip(tr("Show the plugin view dialog"));
|
_pluginViewAction->setStatusTip(tr("Show the plugin view dialog"));
|
||||||
|
menuManager()->registerAction(_pluginViewAction, Constants::ABOUT_PLUGINS);
|
||||||
connect(_pluginViewAction, SIGNAL(triggered()), _pluginView, SLOT(show()));
|
connect(_pluginViewAction, SIGNAL(triggered()), _pluginView, SLOT(show()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMainWindow::createMenus()
|
void CMainWindow::createMenus()
|
||||||
{
|
{
|
||||||
_fileMenu = menuBar()->addMenu(tr("&File"));
|
_fileMenu = menuBar()->addMenu(tr("&File"));
|
||||||
_fileMenu->setObjectName(Constants::M_FILE);
|
menuManager()->registerMenu(_fileMenu, Constants::M_FILE);
|
||||||
_fileMenu->addSeparator();
|
_fileMenu->addSeparator();
|
||||||
_fileMenu->addAction(_exitAction);
|
_fileMenu->addAction(_exitAction);
|
||||||
|
|
||||||
_editMenu = menuBar()->addMenu(tr("&Edit"));
|
_editMenu = menuBar()->addMenu(tr("&Edit"));
|
||||||
_editMenu->setObjectName(Constants::M_EDIT);
|
menuManager()->registerMenu(_editMenu, Constants::M_EDIT);
|
||||||
|
|
||||||
_viewMenu = menuBar()->addMenu(tr("&View"));
|
_viewMenu = menuBar()->addMenu(tr("&View"));
|
||||||
_viewMenu->setObjectName(Constants::M_VIEW);
|
menuManager()->registerMenu(_viewMenu, Constants::M_VIEW);
|
||||||
|
|
||||||
_toolsMenu = menuBar()->addMenu(tr("&Tools"));
|
_toolsMenu = menuBar()->addMenu(tr("&Tools"));
|
||||||
_toolsMenu->setObjectName(Constants::M_TOOLS);
|
menuManager()->registerMenu(_toolsMenu, Constants::M_TOOLS);
|
||||||
|
|
||||||
|
|
||||||
_toolsMenu->addSeparator();
|
_toolsMenu->addSeparator();
|
||||||
|
@ -182,7 +200,7 @@ void CMainWindow::createMenus()
|
||||||
menuBar()->addSeparator();
|
menuBar()->addSeparator();
|
||||||
|
|
||||||
_helpMenu = menuBar()->addMenu(tr("&Help"));
|
_helpMenu = menuBar()->addMenu(tr("&Help"));
|
||||||
_helpMenu->setObjectName(Constants::M_HELP);
|
menuManager()->registerMenu(_helpMenu, Constants::M_HELP);
|
||||||
_helpMenu->addAction(_aboutAction);
|
_helpMenu->addAction(_aboutAction);
|
||||||
_helpMenu->addAction(_aboutQtAction);
|
_helpMenu->addAction(_aboutQtAction);
|
||||||
_helpMenu->addAction(_pluginViewAction);
|
_helpMenu->addAction(_pluginViewAction);
|
||||||
|
|
|
@ -33,6 +33,8 @@ namespace Core
|
||||||
class CSettingsDialog;
|
class CSettingsDialog;
|
||||||
class CorePlugin;
|
class CorePlugin;
|
||||||
class IAppPage;
|
class IAppPage;
|
||||||
|
class IMenuManager;
|
||||||
|
class MenuManager;
|
||||||
|
|
||||||
class CMainWindow : public QMainWindow
|
class CMainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -42,6 +44,8 @@ public:
|
||||||
CMainWindow(CorePlugin *corePlugin, QWidget *parent = 0);
|
CMainWindow(CorePlugin *corePlugin, QWidget *parent = 0);
|
||||||
~CMainWindow();
|
~CMainWindow();
|
||||||
|
|
||||||
|
IMenuManager *menuManager() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void checkObject(QObject *obj);
|
void checkObject(QObject *obj);
|
||||||
bool showOptionsDialog(const QString &group = QString(),
|
bool showOptionsDialog(const QString &group = QString(),
|
||||||
|
@ -65,6 +69,7 @@ private:
|
||||||
ExtensionSystem::IPluginManager *_pluginManager;
|
ExtensionSystem::IPluginManager *_pluginManager;
|
||||||
ExtensionSystem::CPluginView *_pluginView;
|
ExtensionSystem::CPluginView *_pluginView;
|
||||||
CorePlugin *_corePlugin;
|
CorePlugin *_corePlugin;
|
||||||
|
MenuManager *_menuManager;
|
||||||
|
|
||||||
QPalette _originalPalette;
|
QPalette _originalPalette;
|
||||||
QString _lastDir;
|
QString _lastDir;
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
// Copyright (C) 2011 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 Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "menu_manager.h"
|
||||||
|
|
||||||
|
// NeL includes
|
||||||
|
#include <nel/misc/debug.h>
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
#include <QtGui/QAction>
|
||||||
|
#include <QtGui/QMenuBar>
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
MenuManager::MenuManager(QObject *parent)
|
||||||
|
: IMenuManager(parent),
|
||||||
|
_menuBar(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuManager::~MenuManager()
|
||||||
|
{
|
||||||
|
_menuMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuManager::registerMenu(QMenu *menu, const QString &id)
|
||||||
|
{
|
||||||
|
menu->setObjectName(id);
|
||||||
|
_menuMap.insert(id, menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuManager::registerAction(QAction *action, const QString &id)
|
||||||
|
{
|
||||||
|
action->setObjectName(id);
|
||||||
|
_actionMap.insert(id, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenu *MenuManager::menu(const QString &id) const
|
||||||
|
{
|
||||||
|
QMenu *result = 0;
|
||||||
|
if (_menuMap.count(id) == 0)
|
||||||
|
nlwarning("QMenu %s not found", id.toStdString().c_str());
|
||||||
|
else
|
||||||
|
result = _menuMap.value(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
QAction *MenuManager::action(const QString &id) const
|
||||||
|
{
|
||||||
|
QAction *result = 0;
|
||||||
|
if (_actionMap.count(id) == 0)
|
||||||
|
nlwarning("QAction %s not found", id.toStdString().c_str());
|
||||||
|
else
|
||||||
|
result = _actionMap.value(id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuManager::unregisterMenu(const QString &id)
|
||||||
|
{
|
||||||
|
_menuMap.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuManager::unregisterAction(const QString &id)
|
||||||
|
{
|
||||||
|
_actionMap.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
QMenuBar *MenuManager::menuBar() const
|
||||||
|
{
|
||||||
|
return _menuBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuManager::setMenuBar(QMenuBar *menuBar)
|
||||||
|
{
|
||||||
|
_menuBar = menuBar;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace Core */
|
|
@ -0,0 +1,59 @@
|
||||||
|
// Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||||
|
// Copyright (C) 2010 Winch Gate Property Limited
|
||||||
|
// Copyright (C) 2011 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 Affero 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 Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef MENU_MANAGER_H
|
||||||
|
#define MENU_MANAGER_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
|
#include "imenu_manager.h"
|
||||||
|
|
||||||
|
// Qt includes
|
||||||
|
#include <QtCore/QHash>
|
||||||
|
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
|
||||||
|
class MenuManager : public IMenuManager
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MenuManager(QObject *parent = 0);
|
||||||
|
virtual ~MenuManager();
|
||||||
|
|
||||||
|
virtual void registerMenu(QMenu *menu, const QString &id);
|
||||||
|
virtual void registerAction(QAction *action, const QString &id);
|
||||||
|
|
||||||
|
virtual QMenu *menu(const QString &id) const;
|
||||||
|
virtual QAction *action(const QString &id) const;
|
||||||
|
|
||||||
|
virtual void unregisterMenu(const QString &id);
|
||||||
|
virtual void unregisterAction(const QString &id);
|
||||||
|
|
||||||
|
virtual QMenuBar *menuBar() const;
|
||||||
|
void setMenuBar(QMenuBar *menuBar);
|
||||||
|
private:
|
||||||
|
QMenuBar *_menuBar;
|
||||||
|
typedef QHash<QString, QMenu *> IdMenuMap;
|
||||||
|
IdMenuMap _menuMap;
|
||||||
|
typedef QHash<QString, QAction *> IdActionMap;
|
||||||
|
IdActionMap _actionMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
|
#endif // MENU_MANAGER_H
|
|
@ -28,7 +28,7 @@ namespace Core
|
||||||
{
|
{
|
||||||
|
|
||||||
CSearchPathsSettingsPage::CSearchPathsSettingsPage(QObject *parent)
|
CSearchPathsSettingsPage::CSearchPathsSettingsPage(QObject *parent)
|
||||||
: QObject(parent),
|
: IOptionsPage(parent),
|
||||||
_currentPage(0)
|
_currentPage(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,10 @@ namespace Core
|
||||||
/**
|
/**
|
||||||
@class CSearchPathsSettingsPage
|
@class CSearchPathsSettingsPage
|
||||||
*/
|
*/
|
||||||
class CSearchPathsSettingsPage : public QObject, public Core::IOptionsPage
|
class CSearchPathsSettingsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(Core::IOptionsPage)
|
|
||||||
public:
|
public:
|
||||||
CSearchPathsSettingsPage(QObject *parent = 0);
|
CSearchPathsSettingsPage(QObject *parent = 0);
|
||||||
~CSearchPathsSettingsPage() {}
|
~CSearchPathsSettingsPage() {}
|
||||||
|
|
|
@ -62,7 +62,7 @@ CSettingsDialog::CSettingsDialog(CorePlugin *corePlugin,
|
||||||
|
|
||||||
QMap<QString, QTreeWidgetItem *> categories;
|
QMap<QString, QTreeWidgetItem *> categories;
|
||||||
|
|
||||||
QList<IOptionsPage *> pages = corePlugin->getObjects<IOptionsPage>();
|
QList<IOptionsPage *> pages = _plugMan->getObjects<IOptionsPage>();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
Q_FOREACH(IOptionsPage *page, pages)
|
Q_FOREACH(IOptionsPage *page, pages)
|
||||||
|
|
|
@ -13,9 +13,7 @@ SET(OVQT_PLUG_EXAMPLE_HDR plugin1.h
|
||||||
qnel_widget.h
|
qnel_widget.h
|
||||||
simple_viewer.h
|
simple_viewer.h
|
||||||
example_settings_page.h
|
example_settings_page.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../core/iapp_page.h
|
${CMAKE_CURRENT_SOURCE_DIR}/../core/iapp_page.h)
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../core/icore_listener.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/../core/ioptions_page.h)
|
|
||||||
|
|
||||||
SET(OVQT_PLUG_EXAMPLE_UIS example_settings_page.ui)
|
SET(OVQT_PLUG_EXAMPLE_UIS example_settings_page.ui)
|
||||||
|
|
||||||
|
@ -33,7 +31,7 @@ SOURCE_GROUP("OVQT Extension System" FILES ${OVQT_EXT_SYS_SRC})
|
||||||
|
|
||||||
ADD_LIBRARY(ovqt_plugin_example MODULE ${SRC} ${OVQT_PLUG_EXAMPLE_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUG_EXAMPLE_UI_HDRS})
|
ADD_LIBRARY(ovqt_plugin_example MODULE ${SRC} ${OVQT_PLUG_EXAMPLE_MOC_SRC} ${OVQT_EXT_SYS_SRC} ${OVQT_PLUG_EXAMPLE_UI_HDRS})
|
||||||
|
|
||||||
TARGET_LINK_LIBRARIES(ovqt_plugin_example nelmisc nel3d ${QT_LIBRARIES})
|
TARGET_LINK_LIBRARIES(ovqt_plugin_example ovqt_plugin_core nelmisc nel3d ${QT_LIBRARIES})
|
||||||
|
|
||||||
NL_DEFAULT_PROPS(ovqt_plugin_example "NeL, Tools, 3D: Object Viewer Qt Plugin: Example")
|
NL_DEFAULT_PROPS(ovqt_plugin_example "NeL, Tools, 3D: Object Viewer Qt Plugin: Example")
|
||||||
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_example)
|
NL_ADD_RUNTIME_FLAGS(ovqt_plugin_example)
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Plugin
|
||||||
{
|
{
|
||||||
|
|
||||||
CExampleSettingsPage::CExampleSettingsPage(QObject *parent)
|
CExampleSettingsPage::CExampleSettingsPage(QObject *parent)
|
||||||
: QObject(parent),
|
: IOptionsPage(parent),
|
||||||
_currentPage(NULL)
|
_currentPage(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,9 @@ namespace Plugin
|
||||||
/**
|
/**
|
||||||
@class CExampleSettingsPage
|
@class CExampleSettingsPage
|
||||||
*/
|
*/
|
||||||
class CExampleSettingsPage : public QObject, public Core::IOptionsPage
|
class CExampleSettingsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(Core::IOptionsPage)
|
|
||||||
public:
|
public:
|
||||||
CExampleSettingsPage(QObject *parent = 0);
|
CExampleSettingsPage(QObject *parent = 0);
|
||||||
virtual ~CExampleSettingsPage() {}
|
virtual ~CExampleSettingsPage() {}
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
#include "example_settings_page.h"
|
#include "example_settings_page.h"
|
||||||
#include "simple_viewer.h"
|
#include "simple_viewer.h"
|
||||||
#include "../core/iapp_page.h"
|
#include "../core/iapp_page.h"
|
||||||
|
#include "../core/core_constants.h"
|
||||||
|
#include "../core/imenu_manager.h"
|
||||||
#include "../../extension_system/iplugin_spec.h"
|
#include "../../extension_system/iplugin_spec.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
|
@ -41,6 +43,21 @@ bool MyPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QStrin
|
||||||
|
|
||||||
void MyPlugin::extensionsInitialized()
|
void MyPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
|
Core::IMenuManager *menuManager = 0;
|
||||||
|
menuManager = _plugMan->getObject<Core::IMenuManager>();
|
||||||
|
if (menuManager == 0)
|
||||||
|
nlinfo("error menu manager");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QAction *exampleAction1 = new QAction("Example1", this);
|
||||||
|
QAction *exampleAction2 = new QAction("Example2", this);
|
||||||
|
QAction *aboutQtAction = menuManager->action(Core::Constants::ABOUT_QT);
|
||||||
|
QMenu *helpMenu = menuManager->menu(Core::Constants::M_HELP);
|
||||||
|
helpMenu->insertAction(aboutQtAction, exampleAction1);
|
||||||
|
helpMenu->addSeparator();
|
||||||
|
helpMenu->addAction(exampleAction2);
|
||||||
|
menuManager->menuBar()->addMenu("ExampleMenu");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
void MyPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
||||||
|
|
|
@ -39,12 +39,11 @@ public:
|
||||||
virtual ~CSimpleViewer() {}
|
virtual ~CSimpleViewer() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCoreListener : public QObject, public Core::ICoreListener
|
class CCoreListener : public Core::ICoreListener
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(Core::ICoreListener)
|
|
||||||
public:
|
public:
|
||||||
CCoreListener(QObject *parent = 0): QObject(parent) {}
|
CCoreListener(QObject *parent = 0): ICoreListener(parent) {}
|
||||||
virtual ~CCoreListener() {}
|
virtual ~CCoreListener() {}
|
||||||
|
|
||||||
virtual bool closeMainWindow() const;
|
virtual bool closeMainWindow() const;
|
||||||
|
|
Loading…
Reference in a new issue