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:
dnk-88 2011-05-27 17:06:30 +03:00
parent 790b3c8733
commit ba808bb5e8
24 changed files with 89 additions and 29 deletions

View file

@ -18,6 +18,7 @@
// Project includes
#include "context_manager.h"
#include "icontext.h"
#include "main_window.h"
// NeL includes
#include <nel/misc/debug.h>
@ -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<IContext *> 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)));

View file

@ -21,8 +21,6 @@
// Project includes
#include "core_global.h"
#include "../../extension_system/iplugin_manager.h"
// Qt includes
#include <QtCore/QObject>
@ -33,6 +31,7 @@ QT_END_NAMESPACE
namespace Core
{
class IContext;
class MainWindow;
struct ContextManagerPrivate;
class CORE_EXPORT ContextManager : public QObject
@ -40,7 +39,7 @@ 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;

View file

@ -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();

View file

@ -44,6 +44,7 @@ public:
QString trName() const;
QString category() const;
QString trCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();

View file

@ -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

View file

@ -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;

View file

@ -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"));

View file

@ -26,6 +26,7 @@
// Qt includes
#include <QtGui/QMainWindow>
#include <QtGui/QUndoGroup>
#include <QtCore/QSettings>
namespace Core
@ -85,6 +86,7 @@ private:
QPalette m_originalPalette;
QString m_lastDir;
QUndoGroup *m_undoGroup;
QSettings *m_settings;
QTimer *m_mainTimer;

View file

@ -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);

View file

@ -44,6 +44,7 @@ public:
QString trName() const;
QString category() const;
QString trCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();

View file

@ -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);

View file

@ -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();

View file

@ -86,6 +86,10 @@ public:
return m_simpleViewer;
}
virtual void open()
{
}
CSimpleViewer *m_simpleViewer;
};

View file

@ -93,6 +93,11 @@ public:
{
return QIcon();
}
virtual void open()
{
}
virtual QWidget *widget();
LandscapeEditorWindow *m_landEditorWindow;

View file

@ -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);

View file

@ -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();

View file

@ -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");

View file

@ -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);

View file

@ -89,6 +89,11 @@ void ObjectViewerPlugin::addAutoReleasedObject(QObject *obj)
_autoReleaseObjects.prepend(obj);
}
void CObjectViewerContext::open()
{
Modules::mainWin().open();
}
QWidget *CObjectViewerContext::widget()
{
return &Modules::mainWin();

View file

@ -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();
};

View file

@ -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);

View file

@ -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();

View file

@ -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);

View file

@ -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();