mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-25 02:10:53 +00:00
Changed: #1303 Each context must have its own file open dialog, which will be called when the context is active. The beginning of work on adding undo/redo.
This commit is contained in:
parent
9f204828e7
commit
fbbdb15ad2
24 changed files with 89 additions and 29 deletions
|
@ -18,6 +18,7 @@
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "context_manager.h"
|
#include "context_manager.h"
|
||||||
#include "icontext.h"
|
#include "icontext.h"
|
||||||
|
#include "main_window.h"
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/debug.h>
|
#include <nel/misc/debug.h>
|
||||||
|
@ -31,26 +32,26 @@ namespace Core
|
||||||
|
|
||||||
struct ContextManagerPrivate
|
struct ContextManagerPrivate
|
||||||
{
|
{
|
||||||
explicit ContextManagerPrivate(ExtensionSystem::IPluginManager *pluginManager, QTabWidget *tabWidget);
|
explicit ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget);
|
||||||
ExtensionSystem::IPluginManager *m_pluginManager;
|
Core::MainWindow *m_mainWindow;
|
||||||
QTabWidget *m_tabWidget;
|
QTabWidget *m_tabWidget;
|
||||||
QVector<IContext *> m_contexts;
|
QVector<IContext *> m_contexts;
|
||||||
int m_oldCurrent;
|
int m_oldCurrent;
|
||||||
};
|
};
|
||||||
|
|
||||||
ContextManagerPrivate::ContextManagerPrivate(ExtensionSystem::IPluginManager *pluginManager, QTabWidget *tabWidget)
|
ContextManagerPrivate::ContextManagerPrivate(Core::MainWindow *mainWindow, QTabWidget *tabWidget)
|
||||||
: m_pluginManager(pluginManager),
|
: m_mainWindow(mainWindow),
|
||||||
m_tabWidget(tabWidget),
|
m_tabWidget(tabWidget),
|
||||||
m_oldCurrent(-1)
|
m_oldCurrent(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextManager::ContextManager(ExtensionSystem::IPluginManager *pluginManager, QTabWidget *tabWidget)
|
ContextManager::ContextManager(Core::MainWindow *mainWindow, QTabWidget *tabWidget)
|
||||||
: d(new ContextManagerPrivate(pluginManager, 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 *)));
|
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 *)));
|
this, SLOT(aboutToRemoveObject(QObject *)));
|
||||||
|
|
||||||
QObject::connect(d->m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
|
QObject::connect(d->m_tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include "../../extension_system/iplugin_manager.h"
|
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
|
@ -33,6 +31,7 @@ QT_END_NAMESPACE
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
class IContext;
|
class IContext;
|
||||||
|
class MainWindow;
|
||||||
struct ContextManagerPrivate;
|
struct ContextManagerPrivate;
|
||||||
|
|
||||||
class CORE_EXPORT ContextManager : public QObject
|
class CORE_EXPORT ContextManager : public QObject
|
||||||
|
@ -40,7 +39,7 @@ class CORE_EXPORT ContextManager : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ContextManager(ExtensionSystem::IPluginManager *pluginManager, QTabWidget *tabWidget);
|
explicit ContextManager(Core::MainWindow *mainWindow, QTabWidget *tabWidget);
|
||||||
virtual ~ContextManager();
|
virtual ~ContextManager();
|
||||||
|
|
||||||
Core::IContext *currentContext() const;
|
Core::IContext *currentContext() const;
|
||||||
|
|
|
@ -65,6 +65,11 @@ QString GeneralSettingsPage::trCategory() const
|
||||||
return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL);
|
return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon GeneralSettingsPage::categoryIcon() const
|
||||||
|
{
|
||||||
|
return QIcon();
|
||||||
|
}
|
||||||
|
|
||||||
void GeneralSettingsPage::applyGeneralSettings()
|
void GeneralSettingsPage::applyGeneralSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::instance()->settings();
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
QString trName() const;
|
QString trName() const;
|
||||||
QString category() const;
|
QString category() const;
|
||||||
QString trCategory() const;
|
QString trCategory() const;
|
||||||
|
QIcon categoryIcon() const;
|
||||||
QWidget *createPage(QWidget *parent);
|
QWidget *createPage(QWidget *parent);
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
|
|
|
@ -57,15 +57,7 @@ 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 bool open()
|
virtual void open() = 0;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool help()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
class QIcon;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
|
@ -56,6 +57,8 @@ public:
|
||||||
/// trCategory() is the translated category
|
/// trCategory() is the translated category
|
||||||
virtual QString trCategory() const = 0;
|
virtual QString trCategory() const = 0;
|
||||||
|
|
||||||
|
virtual QIcon categoryIcon() const = 0;
|
||||||
|
|
||||||
/// createPage() is called to retrieve the widget to show in the preferences dialog
|
/// 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
|
/// The widget will be destroyed by the widget hierarchy when the dialog closes
|
||||||
virtual QWidget *createPage(QWidget *parent) = 0;
|
virtual QWidget *createPage(QWidget *parent) = 0;
|
||||||
|
|
|
@ -42,6 +42,7 @@ MainWindow::MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget *
|
||||||
m_contextManager(0),
|
m_contextManager(0),
|
||||||
m_coreImpl(0),
|
m_coreImpl(0),
|
||||||
m_lastDir("."),
|
m_lastDir("."),
|
||||||
|
m_undoGroup(0),
|
||||||
m_settings(0)
|
m_settings(0)
|
||||||
{
|
{
|
||||||
QCoreApplication::setApplicationName(QLatin1String("ObjectViewerQt"));
|
QCoreApplication::setApplicationName(QLatin1String("ObjectViewerQt"));
|
||||||
|
@ -65,10 +66,11 @@ MainWindow::MainWindow(ExtensionSystem::IPluginManager *pluginManager, QWidget *
|
||||||
m_tabWidget->setDocumentMode(true);
|
m_tabWidget->setDocumentMode(true);
|
||||||
setCentralWidget(m_tabWidget);
|
setCentralWidget(m_tabWidget);
|
||||||
|
|
||||||
m_contextManager = new ContextManager(m_pluginManager, m_tabWidget);
|
m_contextManager = new ContextManager(this, m_tabWidget);
|
||||||
|
|
||||||
setDockNestingEnabled(true);
|
setDockNestingEnabled(true);
|
||||||
m_originalPalette = QApplication::palette();
|
m_originalPalette = QApplication::palette();
|
||||||
|
m_undoGroup = new QUndoGroup(this);
|
||||||
|
|
||||||
createDialogs();
|
createDialogs();
|
||||||
createActions();
|
createActions();
|
||||||
|
@ -122,6 +124,7 @@ ExtensionSystem::IPluginManager *MainWindow::pluginManager() const
|
||||||
|
|
||||||
void MainWindow::open()
|
void MainWindow::open()
|
||||||
{
|
{
|
||||||
|
m_contextManager->currentContext()->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::showOptionsDialog(const QString &group,
|
bool MainWindow::showOptionsDialog(const QString &group,
|
||||||
|
@ -212,11 +215,14 @@ void MainWindow::createMenus()
|
||||||
{
|
{
|
||||||
m_fileMenu = menuBar()->addMenu(tr("&File"));
|
m_fileMenu = menuBar()->addMenu(tr("&File"));
|
||||||
menuManager()->registerMenu(m_fileMenu, Constants::M_FILE);
|
menuManager()->registerMenu(m_fileMenu, Constants::M_FILE);
|
||||||
// m_fileMenu->addAction(m_openAction);
|
m_fileMenu->addAction(m_openAction);
|
||||||
m_fileMenu->addSeparator();
|
m_fileMenu->addSeparator();
|
||||||
m_fileMenu->addAction(m_exitAction);
|
m_fileMenu->addAction(m_exitAction);
|
||||||
|
|
||||||
m_editMenu = menuBar()->addMenu(tr("&Edit"));
|
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);
|
menuManager()->registerMenu(m_editMenu, Constants::M_EDIT);
|
||||||
|
|
||||||
m_viewMenu = menuBar()->addMenu(tr("&View"));
|
m_viewMenu = menuBar()->addMenu(tr("&View"));
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QMainWindow>
|
#include <QtGui/QMainWindow>
|
||||||
|
#include <QtGui/QUndoGroup>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
|
@ -85,6 +86,7 @@ private:
|
||||||
QPalette m_originalPalette;
|
QPalette m_originalPalette;
|
||||||
QString m_lastDir;
|
QString m_lastDir;
|
||||||
|
|
||||||
|
QUndoGroup *m_undoGroup;
|
||||||
QSettings *m_settings;
|
QSettings *m_settings;
|
||||||
|
|
||||||
QTimer *m_mainTimer;
|
QTimer *m_mainTimer;
|
||||||
|
|
|
@ -63,6 +63,11 @@ QString CSearchPathsSettingsPage::trCategory() const
|
||||||
return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL);
|
return tr(Constants::SETTINGS_TR_CATEGORY_GENERAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon CSearchPathsSettingsPage::categoryIcon() const
|
||||||
|
{
|
||||||
|
return QIcon();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent)
|
QWidget *CSearchPathsSettingsPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
m_page = new QWidget(parent);
|
m_page = new QWidget(parent);
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
QString trName() const;
|
QString trName() const;
|
||||||
QString category() const;
|
QString category() const;
|
||||||
QString trCategory() const;
|
QString trCategory() const;
|
||||||
|
QIcon categoryIcon() const;
|
||||||
QWidget *createPage(QWidget *parent);
|
QWidget *createPage(QWidget *parent);
|
||||||
|
|
||||||
void apply();
|
void apply();
|
||||||
|
|
|
@ -53,6 +53,11 @@ QString CExampleSettingsPage::trCategory() const
|
||||||
return tr("General");
|
return tr("General");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon CExampleSettingsPage::categoryIcon() const
|
||||||
|
{
|
||||||
|
return QIcon();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *CExampleSettingsPage::createPage(QWidget *parent)
|
QWidget *CExampleSettingsPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
_currentPage = new QWidget(parent);
|
_currentPage = new QWidget(parent);
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
virtual QString trName() const;
|
virtual QString trName() const;
|
||||||
virtual QString category() const;
|
virtual QString category() const;
|
||||||
virtual QString trCategory() const;
|
virtual QString trCategory() const;
|
||||||
|
QIcon categoryIcon() const;
|
||||||
virtual QWidget *createPage(QWidget *parent);
|
virtual QWidget *createPage(QWidget *parent);
|
||||||
|
|
||||||
virtual void apply();
|
virtual void apply();
|
||||||
|
|
|
@ -86,6 +86,10 @@ public:
|
||||||
return m_simpleViewer;
|
return m_simpleViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void open()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CSimpleViewer *m_simpleViewer;
|
CSimpleViewer *m_simpleViewer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,11 @@ public:
|
||||||
{
|
{
|
||||||
return QIcon();
|
return QIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void open()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual QWidget *widget();
|
virtual QWidget *widget();
|
||||||
|
|
||||||
LandscapeEditorWindow *m_landEditorWindow;
|
LandscapeEditorWindow *m_landEditorWindow;
|
||||||
|
|
|
@ -58,6 +58,11 @@ QString GraphicsSettingsPage::trCategory() const
|
||||||
return tr("Object Viewer");
|
return tr("Object Viewer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon GraphicsSettingsPage::categoryIcon() const
|
||||||
|
{
|
||||||
|
return QIcon();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *GraphicsSettingsPage::createPage(QWidget *parent)
|
QWidget *GraphicsSettingsPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
m_page = new QWidget(parent);
|
m_page = new QWidget(parent);
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
virtual QString trName() const;
|
virtual QString trName() const;
|
||||||
virtual QString category() const;
|
virtual QString category() const;
|
||||||
virtual QString trCategory() const;
|
virtual QString trCategory() const;
|
||||||
|
QIcon categoryIcon() const;
|
||||||
virtual QWidget *createPage(QWidget *parent);
|
virtual QWidget *createPage(QWidget *parent);
|
||||||
|
|
||||||
virtual void apply();
|
virtual void apply();
|
||||||
|
|
|
@ -272,8 +272,8 @@ void CMainWindow::createMenus()
|
||||||
// add actions in file menu
|
// add actions in file menu
|
||||||
QMenu *fileMenu = menuManager->menu(Core::Constants::M_FILE);
|
QMenu *fileMenu = menuManager->menu(Core::Constants::M_FILE);
|
||||||
QAction *exitAction = menuManager->action(Core::Constants::EXIT);
|
QAction *exitAction = menuManager->action(Core::Constants::EXIT);
|
||||||
fileMenu->insertAction(exitAction, _openAction);
|
//fileMenu->insertAction(exitAction, _openAction);
|
||||||
fileMenu->insertSeparator(exitAction);
|
//fileMenu->insertSeparator(exitAction);
|
||||||
|
|
||||||
// register actions for view menu
|
// register actions for view menu
|
||||||
menuManager->registerAction(_setBackColorAction, "ObjectViewer.View.SetBackgroundColor");
|
menuManager->registerAction(_setBackColorAction, "ObjectViewer.View.SetBackgroundColor");
|
||||||
|
|
|
@ -72,10 +72,12 @@ public:
|
||||||
return _SkeletonTreeModel;
|
return _SkeletonTreeModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void open();
|
void open();
|
||||||
void resetScene();
|
void resetScene();
|
||||||
void reloadTextures();
|
void reloadTextures();
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
void updateStatusBar();
|
void updateStatusBar();
|
||||||
void updateRender();
|
void updateRender();
|
||||||
void setInterval(int value);
|
void setInterval(int value);
|
||||||
|
|
|
@ -89,6 +89,11 @@ void ObjectViewerPlugin::addAutoReleasedObject(QObject *obj)
|
||||||
_autoReleaseObjects.prepend(obj);
|
_autoReleaseObjects.prepend(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CObjectViewerContext::open()
|
||||||
|
{
|
||||||
|
Modules::mainWin().open();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *CObjectViewerContext::widget()
|
QWidget *CObjectViewerContext::widget()
|
||||||
{
|
{
|
||||||
return &Modules::mainWin();
|
return &Modules::mainWin();
|
||||||
|
|
|
@ -66,14 +66,19 @@ public:
|
||||||
{
|
{
|
||||||
return QLatin1String("ObjectViewer");
|
return QLatin1String("ObjectViewer");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual QString trName() const
|
virtual QString trName() const
|
||||||
{
|
{
|
||||||
return tr("Object Viewer");
|
return tr("Object Viewer");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual QIcon icon() const
|
virtual QIcon icon() const
|
||||||
{
|
{
|
||||||
return QIcon();
|
return QIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void open();
|
||||||
|
|
||||||
virtual QWidget *widget();
|
virtual QWidget *widget();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,11 @@ QString SoundSettingsPage::trCategory() const
|
||||||
return tr("Object Viewer");
|
return tr("Object Viewer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon SoundSettingsPage::categoryIcon() const
|
||||||
|
{
|
||||||
|
return QIcon();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *SoundSettingsPage::createPage(QWidget *parent)
|
QWidget *SoundSettingsPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
m_page = new QWidget(parent);
|
m_page = new QWidget(parent);
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
virtual QString trName() const;
|
virtual QString trName() const;
|
||||||
virtual QString category() const;
|
virtual QString category() const;
|
||||||
virtual QString trCategory() const;
|
virtual QString trCategory() const;
|
||||||
|
QIcon categoryIcon() const;
|
||||||
virtual QWidget *createPage(QWidget *parent);
|
virtual QWidget *createPage(QWidget *parent);
|
||||||
|
|
||||||
virtual void apply();
|
virtual void apply();
|
||||||
|
|
|
@ -59,6 +59,11 @@ QString VegetableSettingsPage::trCategory() const
|
||||||
return tr("Object Viewer");
|
return tr("Object Viewer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QIcon VegetableSettingsPage::categoryIcon() const
|
||||||
|
{
|
||||||
|
return QIcon();
|
||||||
|
}
|
||||||
|
|
||||||
QWidget *VegetableSettingsPage::createPage(QWidget *parent)
|
QWidget *VegetableSettingsPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
m_page = new QWidget(parent);
|
m_page = new QWidget(parent);
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
virtual QString trName() const;
|
virtual QString trName() const;
|
||||||
virtual QString category() const;
|
virtual QString category() const;
|
||||||
virtual QString trCategory() const;
|
virtual QString trCategory() const;
|
||||||
|
QIcon categoryIcon() const;
|
||||||
virtual QWidget *createPage(QWidget *parent);
|
virtual QWidget *createPage(QWidget *parent);
|
||||||
|
|
||||||
virtual void apply();
|
virtual void apply();
|
||||||
|
|
Loading…
Reference in a new issue