diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp index 23d544593..23dbe02f4 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.cpp @@ -18,6 +18,7 @@ // Project includes #include "context_manager.h" #include "icontext.h" +#include "main_window.h" // NeL includes #include @@ -31,26 +32,26 @@ namespace Core struct ContextManagerPrivate { - explicit ContextManagerPrivate(ExtensionSystem::IPluginManager *pluginManager, QTabWidget *tabWidget); - ExtensionSystem::IPluginManager *m_pluginManager; + explicit ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget); + Core::MainWindow *m_mainWindow; QTabWidget *m_tabWidget; QVector m_contexts; int m_oldCurrent; }; -ContextManagerPrivate::ContextManagerPrivate(ExtensionSystem::IPluginManager *pluginManager, QTabWidget *tabWidget) - : m_pluginManager(pluginManager), +ContextManagerPrivate::ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget) + : m_mainWindow(mainWindow), m_tabWidget(tabWidget), m_oldCurrent(-1) { } -ContextManager::ContextManager(ExtensionSystem::IPluginManager *pluginManager, QTabWidget *tabWidget) - : d(new ContextManagerPrivate(pluginManager, tabWidget)) +ContextManager::ContextManager(Core::MainWindow *mainWindow, QTabWidget *tabWidget) + : d(new ContextManagerPrivate(mainWindow, tabWidget)) { - QObject::connect(d->m_pluginManager, SIGNAL(objectAdded(QObject *)), + QObject::connect(d->m_mainWindow->pluginManager(), SIGNAL(objectAdded(QObject *)), this, SLOT(objectAdded(QObject *))); - QObject::connect(d->m_pluginManager, SIGNAL(aboutToRemoveObject(QObject *)), + QObject::connect(d->m_mainWindow->pluginManager(), SIGNAL(aboutToRemoveObject(QObject *)), this, SLOT(aboutToRemoveObject(QObject *))); QObject::connect(d->m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int))); @@ -61,7 +62,7 @@ ContextManager::~ContextManager() delete d; } -Core::IContext* ContextManager::currentContext() const +Core::IContext *ContextManager::currentContext() const { int currentIndex = d->m_tabWidget->currentIndex(); if (currentIndex < 0) @@ -69,7 +70,7 @@ Core::IContext* ContextManager::currentContext() const return d->m_contexts.at(currentIndex); } -Core::IContext* ContextManager::context(const QString &id) const +Core::IContext *ContextManager::context(const QString &id) const { const int index = indexOf(id); if (index >= 0) diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h index 5264617a3..7a3658fff 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/context_manager.h @@ -21,8 +21,6 @@ // Project includes #include "core_global.h" -#include "../../extension_system/iplugin_manager.h" - // Qt includes #include @@ -33,6 +31,7 @@ QT_END_NAMESPACE namespace Core { class IContext; +class MainWindow; struct ContextManagerPrivate; class CORE_EXPORT ContextManager : public QObject @@ -40,11 +39,11 @@ class CORE_EXPORT ContextManager : public QObject Q_OBJECT public: - explicit ContextManager(ExtensionSystem::IPluginManager *pluginManager, QTabWidget *tabWidget); + explicit ContextManager(Core::MainWindow *mainWindow, QTabWidget *tabWidget); virtual ~ContextManager(); - Core::IContext* currentContext() const; - Core::IContext* context(const QString &id) const; + Core::IContext *currentContext() const; + Core::IContext *context(const QString &id) const; Q_SIGNALS: // the default argument '=0' is important for connects without the oldContext argument. diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp index 47bf4026a..51da80f67 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.cpp @@ -65,6 +65,11 @@ QString GeneralSettingsPage::trCategory() const return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL); } +QIcon GeneralSettingsPage::categoryIcon() const +{ + return QIcon(); +} + void GeneralSettingsPage::applyGeneralSettings() { QSettings *settings = Core::ICore::instance()->settings(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h index 2f73f8715..2fbcb842a 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/general_settings_page.h @@ -44,6 +44,7 @@ public: QString trName() const; QString category() const; QString trCategory() const; + QIcon categoryIcon() const; QWidget *createPage(QWidget *parent); void apply(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h index c012b5a0c..c6784dafe 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/icontext.h @@ -57,15 +57,7 @@ public: /// The widget will be destroyed by the widget hierarchy when the main window closes virtual QWidget *widget() = 0; - virtual bool open() - { - return false; - } - - virtual bool help() - { - return false; - } + virtual void open() = 0; }; } // namespace Core diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h index 74692833a..4d9ed6fda 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/ioptions_page.h @@ -27,6 +27,7 @@ QT_BEGIN_NAMESPACE class QWidget; +class QIcon; QT_END_NAMESPACE namespace Core @@ -56,6 +57,8 @@ public: /// trCategory() is the translated category virtual QString trCategory() const = 0; + virtual QIcon categoryIcon() const = 0; + /// createPage() is called to retrieve the widget to show in the preferences dialog /// The widget will be destroyed by the widget hierarchy when the dialog closes virtual QWidget *createPage(QWidget *parent) = 0; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp index a4bc542b2..1c8850508 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.cpp @@ -42,6 +42,7 @@ MainWindow::MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget * m_contextManager(0), m_coreImpl(0), m_lastDir("."), + m_undoGroup(0), m_settings(0) { QCoreApplication::setApplicationName(QLatin1String("ObjectViewerQt")); @@ -65,10 +66,11 @@ MainWindow::MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget * m_tabWidget->setDocumentMode(true); setCentralWidget(m_tabWidget); - m_contextManager = new ContextManager(m_pluginManager, m_tabWidget); + m_contextManager = new ContextManager(this, m_tabWidget); setDockNestingEnabled(true); m_originalPalette = QApplication::palette(); + m_undoGroup = new QUndoGroup(this); createDialogs(); createActions(); @@ -122,6 +124,7 @@ ExtensionSystem::IPluginManager *MainWindow::pluginManager() const void MainWindow::open() { + m_contextManager->currentContext()->open(); } bool MainWindow::showOptionsDialog(const QString &group, @@ -212,11 +215,14 @@ void MainWindow::createMenus() { m_fileMenu = menuBar()->addMenu(tr("&File")); menuManager()->registerMenu(m_fileMenu, Constants::M_FILE); -// m_fileMenu->addAction(m_openAction); + m_fileMenu->addAction(m_openAction); m_fileMenu->addSeparator(); m_fileMenu->addAction(m_exitAction); m_editMenu = menuBar()->addMenu(tr("&Edit")); + m_editMenu->addAction(m_undoGroup->createUndoAction(this)); + m_editMenu->addAction(m_undoGroup->createRedoAction(this)); + m_editMenu->addSeparator(); menuManager()->registerMenu(m_editMenu, Constants::M_EDIT); m_viewMenu = menuBar()->addMenu(tr("&View")); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h index 8c4a4aafe..cd34098a7 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/main_window.h @@ -26,6 +26,7 @@ // Qt includes #include +#include #include namespace Core @@ -85,6 +86,7 @@ private: QPalette m_originalPalette; QString m_lastDir; + QUndoGroup *m_undoGroup; QSettings *m_settings; QTimer *m_mainTimer; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp index 94ebec8d1..336f5ad48 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.cpp @@ -63,6 +63,11 @@ QString CSearchPathsSettingsPage::trCategory() const return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL); } +QIcon CSearchPathsSettingsPage::categoryIcon() const +{ + return QIcon(); +} + QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent) { m_page = new QWidget(parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h index 90eab513a..6ceaf88bf 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/core/search_paths_settings_page.h @@ -44,6 +44,7 @@ public: QString trName() const; QString category() const; QString trCategory() const; + QIcon categoryIcon() const; QWidget *createPage(QWidget *parent); void apply(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.cpp index 0cb885163..50e7c9db5 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.cpp @@ -53,6 +53,11 @@ QString CExampleSettingsPage::trCategory() const return tr("General"); } +QIcon CExampleSettingsPage::categoryIcon() const +{ + return QIcon(); +} + QWidget *CExampleSettingsPage::createPage(QWidget *parent) { _currentPage = new QWidget(parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.h index 64dd940f8..3475f843f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/example/example_settings_page.h @@ -43,6 +43,7 @@ public: virtual QString trName() const; virtual QString category() const; virtual QString trCategory() const; + QIcon categoryIcon() const; virtual QWidget *createPage(QWidget *parent); virtual void apply(); 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 d3be3bc38..f9d5c2d9d 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 @@ -86,6 +86,10 @@ public: return m_simpleViewer; } + virtual void open() + { + } + CSimpleViewer *m_simpleViewer; }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h index bd5040843..20db2eb15 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/landscape_editor/landscape_editor_plugin.h @@ -93,6 +93,11 @@ public: { return QIcon(); } + + virtual void open() + { + } + virtual QWidget *widget(); LandscapeEditorWindow *m_landEditorWindow; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp index eabb67f3d..6c2736895 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.cpp @@ -58,6 +58,11 @@ QString GraphicsSettingsPage::trCategory() const return tr("Object Viewer"); } +QIcon GraphicsSettingsPage::categoryIcon() const +{ + return QIcon(); +} + QWidget *GraphicsSettingsPage::createPage(QWidget *parent) { m_page = new QWidget(parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.h index e1402939f..74df1b140 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/graphics_settings_page.h @@ -42,6 +42,7 @@ public: virtual QString trName() const; virtual QString category() const; virtual QString trCategory() const; + QIcon categoryIcon() const; virtual QWidget *createPage(QWidget *parent); virtual void apply(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp index 6e183d913..d9b732521 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.cpp @@ -272,8 +272,8 @@ void CMainWindow::createMenus() // add actions in file menu QMenu *fileMenu = menuManager->menu(Core::Constants::M_FILE); QAction *exitAction = menuManager->action(Core::Constants::EXIT); - fileMenu->insertAction(exitAction, _openAction); - fileMenu->insertSeparator(exitAction); + //fileMenu->insertAction(exitAction, _openAction); + //fileMenu->insertSeparator(exitAction); // register actions for view menu menuManager->registerAction(_setBackColorAction, "ObjectViewer.View.SetBackgroundColor"); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h index 52b3dc8d5..6da360901 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/main_window.h @@ -72,10 +72,12 @@ public: return _SkeletonTreeModel; } -private Q_SLOTS: +public Q_SLOTS: void open(); void resetScene(); void reloadTextures(); + +private Q_SLOTS: void updateStatusBar(); void updateRender(); void setInterval(int value); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp index b48eb82cc..193ad8fac 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.cpp @@ -89,6 +89,11 @@ void ObjectViewerPlugin::addAutoReleasedObject(QObject *obj) _autoReleaseObjects.prepend(obj); } +void CObjectViewerContext::open() +{ + Modules::mainWin().open(); +} + QWidget *CObjectViewerContext::widget() { return &Modules::mainWin(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.h index dae298fce..e7f9b8197 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/object_viewer_plugin.h @@ -66,14 +66,19 @@ public: { return QLatin1String("ObjectViewer"); } + virtual QString trName() const { return tr("Object Viewer"); } + virtual QIcon icon() const { return QIcon(); } + + virtual void open(); + virtual QWidget *widget(); }; diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.cpp index 4c677f4bf..1bceeb80b 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.cpp @@ -56,6 +56,11 @@ QString SoundSettingsPage::trCategory() const return tr("Object Viewer"); } +QIcon SoundSettingsPage::categoryIcon() const +{ + return QIcon(); +} + QWidget *SoundSettingsPage::createPage(QWidget *parent) { m_page = new QWidget(parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.h index c27a82e1f..0e5361f54 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_settings_page.h @@ -44,6 +44,7 @@ public: virtual QString trName() const; virtual QString category() const; virtual QString trCategory() const; + QIcon categoryIcon() const; virtual QWidget *createPage(QWidget *parent); virtual void apply(); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.cpp index f794e0b73..aa15b312f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.cpp @@ -59,6 +59,11 @@ QString VegetableSettingsPage::trCategory() const return tr("Object Viewer"); } +QIcon VegetableSettingsPage::categoryIcon() const +{ + return QIcon(); +} + QWidget *VegetableSettingsPage::createPage(QWidget *parent) { m_page = new QWidget(parent); diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.h index bf49e2d2c..b66d070ba 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.h +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/vegetable_settings_page.h @@ -43,6 +43,7 @@ public: virtual QString trName() const; virtual QString category() const; virtual QString trCategory() const; + QIcon categoryIcon() const; virtual QWidget *createPage(QWidget *parent); virtual void apply();