Changed: #1303 Added undo/redo framework in core plugin.
This commit is contained in:
parent
fbbdb15ad2
commit
d7ce82b4bf
16 changed files with 101 additions and 7 deletions
|
@ -102,6 +102,7 @@ void ContextManager::aboutToRemoveObject(QObject *obj)
|
||||||
void ContextManager::addContextObject(IContext *context)
|
void ContextManager::addContextObject(IContext *context)
|
||||||
{
|
{
|
||||||
d->m_contexts.push_back(context);
|
d->m_contexts.push_back(context);
|
||||||
|
d->m_mainWindow->addContextObject(context);
|
||||||
|
|
||||||
QWidget *tabWidget = new QWidget(d->m_tabWidget);
|
QWidget *tabWidget = new QWidget(d->m_tabWidget);
|
||||||
d->m_tabWidget->addTab(tabWidget, context->icon(), context->trName());
|
d->m_tabWidget->addTab(tabWidget, context->icon(), context->trName());
|
||||||
|
@ -113,6 +114,8 @@ void ContextManager::addContextObject(IContext *context)
|
||||||
|
|
||||||
void ContextManager::removeContextObject(IContext *context)
|
void ContextManager::removeContextObject(IContext *context)
|
||||||
{
|
{
|
||||||
|
d->m_mainWindow->removeContextObject(context);
|
||||||
|
|
||||||
const int index = indexOf(context->id());
|
const int index = indexOf(context->id());
|
||||||
QWidget *widget = d->m_tabWidget->widget(index);
|
QWidget *widget = d->m_tabWidget->widget(index);
|
||||||
d->m_tabWidget->removeTab(index);
|
d->m_tabWidget->removeTab(index);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
class QUndoStack;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
|
@ -57,6 +58,8 @@ public:
|
||||||
/// The widget will be destroyed by the widget hierarchy when the main window closes
|
/// The widget will be destroyed by the widget hierarchy when the main window closes
|
||||||
virtual QWidget *widget() = 0;
|
virtual QWidget *widget() = 0;
|
||||||
|
|
||||||
|
virtual QUndoStack *undoStack() = 0;
|
||||||
|
|
||||||
virtual void open() = 0;
|
virtual void open() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,9 @@ bool MainWindow::initialize(QString *errorString)
|
||||||
void MainWindow::extensionsInitialized()
|
void MainWindow::extensionsInitialized()
|
||||||
{
|
{
|
||||||
readSettings();
|
readSettings();
|
||||||
|
connect(m_contextManager, SIGNAL(currentContextChanged(Core::IContext*)),
|
||||||
|
this, SLOT(updateContext(Core::IContext*)));
|
||||||
|
updateContext(m_contextManager->currentContext());
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +125,16 @@ ExtensionSystem::IPluginManager *MainWindow::pluginManager() const
|
||||||
return m_pluginManager;
|
return m_pluginManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::addContextObject(IContext *context)
|
||||||
|
{
|
||||||
|
m_undoGroup->addStack(context->undoStack());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::removeContextObject(IContext *context)
|
||||||
|
{
|
||||||
|
m_undoGroup->removeStack(context->undoStack());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::open()
|
void MainWindow::open()
|
||||||
{
|
{
|
||||||
m_contextManager->currentContext()->open();
|
m_contextManager->currentContext()->open();
|
||||||
|
@ -148,6 +161,11 @@ void MainWindow::about()
|
||||||
"<p> Ryzom Core team <p>Compiled on %1 %2").arg(__DATE__).arg(__TIME__));
|
"<p> Ryzom Core team <p>Compiled on %1 %2").arg(__DATE__).arg(__TIME__));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateContext(Core::IContext *context)
|
||||||
|
{
|
||||||
|
m_undoGroup->setActiveStack(context->undoStack());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *event)
|
void MainWindow::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
QList<ICoreListener *> listeners = m_pluginManager->getObjects<ICoreListener>();
|
QList<ICoreListener *> listeners = m_pluginManager->getObjects<ICoreListener>();
|
||||||
|
|
|
@ -56,6 +56,9 @@ public:
|
||||||
|
|
||||||
ExtensionSystem::IPluginManager *pluginManager() const;
|
ExtensionSystem::IPluginManager *pluginManager() const;
|
||||||
|
|
||||||
|
void addContextObject(IContext *context);
|
||||||
|
void removeContextObject(IContext *context);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
bool showOptionsDialog(const QString &group = QString(),
|
bool showOptionsDialog(const QString &group = QString(),
|
||||||
const QString &page = QString(),
|
const QString &page = QString(),
|
||||||
|
@ -64,6 +67,7 @@ public Q_SLOTS:
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void open();
|
void open();
|
||||||
void about();
|
void about();
|
||||||
|
void updateContext(Core::IContext *context);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent(QCloseEvent *event);
|
virtual void closeEvent(QCloseEvent *event);
|
||||||
|
|
|
@ -86,6 +86,11 @@ public:
|
||||||
return m_simpleViewer;
|
return m_simpleViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual QUndoStack *undoStack()
|
||||||
|
{
|
||||||
|
return m_simpleViewer->m_undoStack;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void open()
|
virtual void open()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,8 @@ CSimpleViewer::CSimpleViewer(QWidget *parent)
|
||||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
NLQT::QNLWidget *_nelWidget = new NLQT::QNLWidget(this);
|
NLQT::QNLWidget *_nelWidget = new NLQT::QNLWidget(this);
|
||||||
gridLayout->addWidget(_nelWidget, 0, 0, 1, 1);
|
gridLayout->addWidget(_nelWidget, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
m_undoStack = new QUndoStack(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCoreListener::closeMainWindow() const
|
bool CCoreListener::closeMainWindow() const
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
#include <QtGui/QUndoStack>
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
namespace Plugin
|
namespace Plugin
|
||||||
|
@ -37,6 +37,8 @@ class CSimpleViewer : public QWidget
|
||||||
public:
|
public:
|
||||||
CSimpleViewer(QWidget *parent = 0);
|
CSimpleViewer(QWidget *parent = 0);
|
||||||
virtual ~CSimpleViewer() {}
|
virtual ~CSimpleViewer() {}
|
||||||
|
|
||||||
|
QUndoStack *m_undoStack;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCoreListener : public Core::ICoreListener
|
class CCoreListener : public Core::ICoreListener
|
||||||
|
|
|
@ -108,6 +108,16 @@ LandscapeEditorContext::LandscapeEditorContext(QObject *parent)
|
||||||
m_landEditorWindow = new LandscapeEditorWindow();
|
m_landEditorWindow = new LandscapeEditorWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUndoStack *LandscapeEditorContext::undoStack()
|
||||||
|
{
|
||||||
|
return m_landEditorWindow->undoStack();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorContext::open()
|
||||||
|
{
|
||||||
|
m_landEditorWindow->open();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *LandscapeEditorContext::widget()
|
QWidget *LandscapeEditorContext::widget()
|
||||||
{
|
{
|
||||||
return m_landEditorWindow;
|
return m_landEditorWindow;
|
||||||
|
|
|
@ -94,9 +94,9 @@ public:
|
||||||
return QIcon();
|
return QIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void open()
|
virtual void open();
|
||||||
{
|
|
||||||
}
|
virtual QUndoStack *undoStack();
|
||||||
|
|
||||||
virtual QWidget *widget();
|
virtual QWidget *widget();
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,19 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
|
#include <QtGui/QFileDialog>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
QString _lastDir;
|
||||||
|
|
||||||
LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
LandscapeEditorWindow::LandscapeEditorWindow(QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
m_ui.setupUi(this);
|
||||||
|
|
||||||
|
m_undoStack = new QUndoStack(this);
|
||||||
|
|
||||||
createMenus();
|
createMenus();
|
||||||
readSettings();
|
readSettings();
|
||||||
}
|
}
|
||||||
|
@ -45,6 +50,26 @@ LandscapeEditorWindow::~LandscapeEditorWindow()
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUndoStack *LandscapeEditorWindow::undoStack() const
|
||||||
|
{
|
||||||
|
return m_undoStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LandscapeEditorWindow::open()
|
||||||
|
{
|
||||||
|
QStringList fileNames = QFileDialog::getOpenFileNames(this,
|
||||||
|
tr("Open NeL Ligo land file"), _lastDir,
|
||||||
|
tr("All NeL Ligo land files (*.land)"));
|
||||||
|
|
||||||
|
setCursor(Qt::WaitCursor);
|
||||||
|
if (!fileNames.isEmpty())
|
||||||
|
{
|
||||||
|
QStringList list = fileNames;
|
||||||
|
_lastDir = QFileInfo(list.front()).absolutePath();
|
||||||
|
}
|
||||||
|
setCursor(Qt::ArrowCursor);
|
||||||
|
}
|
||||||
|
|
||||||
void LandscapeEditorWindow::createMenus()
|
void LandscapeEditorWindow::createMenus()
|
||||||
{
|
{
|
||||||
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
Core::IMenuManager *menuManager = Core::ICore::instance()->menuManager();
|
||||||
|
|
|
@ -18,9 +18,11 @@
|
||||||
#ifndef LANDSCAPE_EDITOR_WINDOW_H
|
#ifndef LANDSCAPE_EDITOR_WINDOW_H
|
||||||
#define LANDSCAPE_EDITOR_WINDOW_H
|
#define LANDSCAPE_EDITOR_WINDOW_H
|
||||||
|
|
||||||
|
// Project includes
|
||||||
#include "ui_landscape_editor_window.h"
|
#include "ui_landscape_editor_window.h"
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
|
#include <QtGui/QUndoStack>
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
@ -33,14 +35,19 @@ public:
|
||||||
LandscapeEditorWindow(QWidget *parent = 0);
|
LandscapeEditorWindow(QWidget *parent = 0);
|
||||||
~LandscapeEditorWindow();
|
~LandscapeEditorWindow();
|
||||||
|
|
||||||
|
QUndoStack *undoStack() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
void open();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
private:
|
private:
|
||||||
void createMenus();
|
void createMenus();
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
|
|
||||||
|
QUndoStack *m_undoStack;
|
||||||
Ui::LandscapeEditorWindow m_ui;
|
Ui::LandscapeEditorWindow m_ui;
|
||||||
}; /* class LandscapeEditorWindow */
|
}; /* class LandscapeEditorWindow */
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ CMainWindow::CMainWindow(QWidget *parent)
|
||||||
_isSoundInitialized = true;
|
_isSoundInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_undoStack = new QUndoStack(this);
|
||||||
_SkeletonTreeModel = new CSkeletonTreeModel(this);
|
_SkeletonTreeModel = new CSkeletonTreeModel(this);
|
||||||
|
|
||||||
createDialogs();
|
createDialogs();
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QMainWindow>
|
#include <QtGui/QMainWindow>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
|
#include <QtGui/QUndoStack>
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/config_file.h>
|
#include <nel/misc/config_file.h>
|
||||||
|
@ -72,6 +73,11 @@ public:
|
||||||
return _SkeletonTreeModel;
|
return _SkeletonTreeModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUndoStack *getUndoStack() const
|
||||||
|
{
|
||||||
|
return _undoStack;
|
||||||
|
}
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void open();
|
void open();
|
||||||
void resetScene();
|
void resetScene();
|
||||||
|
@ -132,6 +138,7 @@ private:
|
||||||
QAction *_resetSceneAction;
|
QAction *_resetSceneAction;
|
||||||
QAction *_saveScreenshotAction;
|
QAction *_saveScreenshotAction;
|
||||||
QLabel *_statusInfo;
|
QLabel *_statusInfo;
|
||||||
|
QUndoStack *_undoStack;
|
||||||
|
|
||||||
float _fps;
|
float _fps;
|
||||||
uint _numTri;
|
uint _numTri;
|
||||||
|
|
|
@ -37,7 +37,7 @@ void Modules::init()
|
||||||
|
|
||||||
void Modules::release()
|
void Modules::release()
|
||||||
{
|
{
|
||||||
delete _mainWindow;
|
// delete _mainWindow;
|
||||||
_mainWindow = NULL;
|
_mainWindow = NULL;
|
||||||
delete _particleEditor;
|
delete _particleEditor;
|
||||||
_particleEditor = NULL;
|
_particleEditor = NULL;
|
||||||
|
|
|
@ -22,7 +22,7 @@ ObjectViewerPlugin::~ObjectViewerPlugin()
|
||||||
}
|
}
|
||||||
qDeleteAll(_autoReleaseObjects);
|
qDeleteAll(_autoReleaseObjects);
|
||||||
_autoReleaseObjects.clear();
|
_autoReleaseObjects.clear();
|
||||||
//Modules::release();
|
Modules::release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectViewerPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
bool ObjectViewerPlugin::initialize(ExtensionSystem::IPluginManager *pluginManager, QString *errorString)
|
||||||
|
@ -43,7 +43,7 @@ void ObjectViewerPlugin::extensionsInitialized()
|
||||||
|
|
||||||
void ObjectViewerPlugin::shutdown()
|
void ObjectViewerPlugin::shutdown()
|
||||||
{
|
{
|
||||||
Modules::release();
|
// Modules::release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectViewerPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
void ObjectViewerPlugin::setNelContext(NLMISC::INelContext *nelContext)
|
||||||
|
@ -94,6 +94,11 @@ void CObjectViewerContext::open()
|
||||||
Modules::mainWin().open();
|
Modules::mainWin().open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUndoStack *CObjectViewerContext::undoStack()
|
||||||
|
{
|
||||||
|
return Modules::mainWin().getUndoStack();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *CObjectViewerContext::widget()
|
QWidget *CObjectViewerContext::widget()
|
||||||
{
|
{
|
||||||
return &Modules::mainWin();
|
return &Modules::mainWin();
|
||||||
|
|
|
@ -77,6 +77,8 @@ public:
|
||||||
return QIcon();
|
return QIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual QUndoStack *undoStack();
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
|
|
||||||
virtual QWidget *widget();
|
virtual QWidget *widget();
|
||||||
|
|
Loading…
Reference in a new issue