Commit 3ac9bee1 authored by hjk's avatar hjk

core: make mode creation more uniform

parent 618fde4c
......@@ -86,12 +86,10 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
parseArguments(arguments);
const bool success = m_mainWindow->init(errorMessage);
if (success) {
EditorManager *editorManager = m_mainWindow->editorManager();
m_editMode = new EditMode(editorManager);
m_editMode = new EditMode;
addObject(m_editMode);
m_mainWindow->modeManager()->activateMode(m_editMode->id());
m_designMode = new DesignMode(editorManager);
m_designMode = new DesignMode;
addObject(m_designMode);
}
return success;
......
......@@ -86,36 +86,37 @@ bool DesignModeCoreListener::coreAboutToClose()
} // namespace Internal
struct DesignEditorInfo {
struct DesignEditorInfo
{
int widgetIndex;
QStringList mimeTypes;
Context context;
QWidget *widget;
};
struct DesignModePrivate {
explicit DesignModePrivate(DesignMode *q, EditorManager *editorManager);
class DesignModePrivate
{
public:
explicit DesignModePrivate(DesignMode *q);
public:
Internal::DesignModeCoreListener *m_coreListener;
QWeakPointer<Core::IEditor> m_currentEditor;
bool m_isActive;
QList<DesignEditorInfo*> m_editors;
EditorManager *m_editorManager;
QStackedWidget *m_stackWidget;
Context m_activeContext;
};
DesignModePrivate::DesignModePrivate(DesignMode *q, EditorManager *editorManager) :
m_coreListener(new Internal::DesignModeCoreListener(q)),
DesignModePrivate::DesignModePrivate(DesignMode *q)
: m_coreListener(new Internal::DesignModeCoreListener(q)),
m_isActive(false),
m_editorManager(editorManager),
m_stackWidget(new QStackedWidget)
{
}
DesignMode::DesignMode(EditorManager *editorManager) :
IMode(), d(new DesignModePrivate(this, editorManager))
DesignMode::DesignMode()
: d(new DesignModePrivate(this))
{
setObjectName(QLatin1String("DesignMode"));
setEnabled(false);
......@@ -129,7 +130,7 @@ DesignMode::DesignMode(EditorManager *editorManager) :
ExtensionSystem::PluginManager::instance()->addObject(d->m_coreListener);
connect(editorManager, SIGNAL(currentEditorChanged(Core::IEditor*)),
connect(EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(currentEditorChanged(Core::IEditor*)));
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*,Core::IMode*)),
......
......@@ -36,7 +36,6 @@
#include <coreplugin/imode.h>
namespace Core {
class EditorManager;
class IEditor;
namespace Internal {
......@@ -50,14 +49,14 @@ class DesignModeCoreListener;
* to the main editor widget itself.
*/
struct DesignModePrivate;
class DesignModePrivate;
class CORE_EXPORT DesignMode : public Core::IMode
{
Q_OBJECT
public:
explicit DesignMode(EditorManager *editorManager);
explicit DesignMode();
virtual ~DesignMode();
void registerDesignWidget(QWidget *widget,
......
......@@ -51,11 +51,11 @@
using namespace Core;
using namespace Core::Internal;
EditMode::EditMode(EditorManager *editorManager) :
m_editorManager(editorManager),
EditMode::EditMode() :
m_splitter(new MiniSplitter),
m_rightSplitWidgetLayout(new QVBoxLayout)
{
m_editorManager = EditorManager::instance();
setObjectName(QLatin1String("EditMode"));
setDisplayName(tr("Edit"));
setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Edit.png")));
......
......@@ -37,7 +37,6 @@
QT_BEGIN_NAMESPACE
class QSplitter;
class QWidget;
class QVBoxLayout;
QT_END_NAMESPACE
......@@ -52,7 +51,7 @@ class EditMode : public Core::IMode
Q_OBJECT
public:
EditMode(EditorManager *editorManager);
EditMode();
~EditMode();
private slots:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment