Commit 0c7c6e8c authored by hjk's avatar hjk

debugger: make DebuggerMode derive directly from IMode instead of BaseMode

parent fd1b9087
......@@ -68,7 +68,7 @@
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/basemode.h>
#include <coreplugin/imode.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/dialogs/ioptionspage.h>
#include <coreplugin/editormanager/editormanager.h>
......@@ -505,10 +505,10 @@ static DebuggerEngine *dummyEngine()
//
///////////////////////////////////////////////////////////////////////
class DebugMode : public Core::BaseMode
class DebugMode : public IMode
{
public:
DebugMode(QObject *parent = 0) : BaseMode(parent)
DebugMode(QObject *parent = 0) : IMode(parent)
{
setDisplayName(QCoreApplication::translate("Debugger::Internal::DebugMode", "Debug"));
setType(CC::MODE_EDIT_TYPE);
......@@ -522,6 +522,35 @@ public:
// Make sure the editor manager does not get deleted.
EditorManager::instance()->setParent(0);
}
// IMode
QString displayName() const { return m_displayName; }
QIcon icon() const { return m_icon; }
int priority() const { return m_priority; }
QWidget *widget() { return m_widget; }
QString id() const { return m_id; }
QString type() const { return m_type; }
Context context() const { return m_context; }
QString contextHelpId() const { return m_helpId; }
void setDisplayName(const QString &name) { m_displayName = name; }
void setIcon(const QIcon &icon) { m_icon = icon; }
void setPriority(int priority) { m_priority = priority; }
void setWidget(QWidget *widget) { m_widget = widget; }
void setId(const QString &id) { m_id = id; }
void setType(const QString &type) { m_type = type; }
void setContextHelpId(const QString &helpId) { m_helpId = helpId; }
void setContext(const Context &context) { m_context = context; }
private:
QString m_displayName;
QIcon m_icon;
int m_priority;
QWidget *m_widget;
QString m_id;
QString m_type;
QString m_helpId;
Context m_context;
};
......@@ -2914,7 +2943,8 @@ void DebuggerPluginPrivate::extensionsInitialized()
SLOT(executeDebuggerCommand()));
// Cpp/Qml ui setup
m_uiSwitcher = new DebuggerUISwitcher(m_debugMode, this);
m_uiSwitcher = new DebuggerUISwitcher(this);
m_debugMode->setWidget(m_uiSwitcher->createContents(m_debugMode));
ExtensionSystem::PluginManager::instance()->addObject(m_uiSwitcher);
m_uiSwitcher->addLanguage(CppLanguage, cppDebuggercontext);
m_uiSwitcher->addLanguage(QmlLanguage, qmlDebuggerContext);
......
......@@ -38,7 +38,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/basemode.h>
#include <coreplugin/imode.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/findplaceholder.h>
......@@ -160,25 +160,9 @@ DebuggerUISwitcherPrivate::DebuggerUISwitcherPrivate(DebuggerUISwitcher *q)
{
}
DebuggerUISwitcher::DebuggerUISwitcher(BaseMode *mode, QObject* parent)
DebuggerUISwitcher::DebuggerUISwitcher(QObject *parent)
: QObject(parent), d(new DebuggerUISwitcherPrivate(this))
{
mode->setWidget(createContents(mode));
ICore *core = ICore::instance();
ActionManager *am = core->actionManager();
ProjectExplorer::ProjectExplorerPlugin *pe =
ProjectExplorer::ProjectExplorerPlugin::instance();
connect(pe->session(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
SLOT(updateUiForProject(ProjectExplorer::Project*)));
connect(d->m_resizeEventFilter, SIGNAL(widgetResized()),
SLOT(updateDockWidgetSettings()));
d->m_debugMenu = am->actionContainer(ProjectExplorer::Constants::M_DEBUG);
d->m_viewsMenu = am->actionContainer(Core::Id(Core::Constants::M_WINDOW_VIEWS));
QTC_ASSERT(d->m_viewsMenu, return)
}
{}
DebuggerUISwitcher::~DebuggerUISwitcher()
{
......@@ -427,7 +411,7 @@ Utils::FancyMainWindow *DebuggerUISwitcher::mainWindow() const
return d->m_mainWindow;
}
QWidget *DebuggerUISwitcher::createMainWindow(BaseMode *mode)
QWidget *DebuggerUISwitcher::createMainWindow(IMode *mode)
{
d->m_mainWindow = new Internal::DebuggerMainWindow(this);
d->m_mainWindow->setDocumentMode(true);
......@@ -566,8 +550,22 @@ QDockWidget *DebuggerUISwitcher::createDockWidget(const DebuggerLanguage &langua
return dockWidget;
}
QWidget *DebuggerUISwitcher::createContents(BaseMode *mode)
QWidget *DebuggerUISwitcher::createContents(IMode *mode)
{
ICore *core = ICore::instance();
ActionManager *am = core->actionManager();
ProjectExplorer::ProjectExplorerPlugin *pe =
ProjectExplorer::ProjectExplorerPlugin::instance();
connect(pe->session(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
SLOT(updateUiForProject(ProjectExplorer::Project*)));
connect(d->m_resizeEventFilter, SIGNAL(widgetResized()),
SLOT(updateDockWidgetSettings()));
d->m_debugMenu = am->actionContainer(ProjectExplorer::Constants::M_DEBUG);
d->m_viewsMenu = am->actionContainer(Core::Id(Core::Constants::M_WINDOW_VIEWS));
QTC_ASSERT(d->m_viewsMenu, return 0)
// right-side window with editor, output etc.
MiniSplitter *mainWindowSplitter = new MiniSplitter;
mainWindowSplitter->addWidget(createMainWindow(mode));
......
......@@ -44,7 +44,6 @@ namespace Core {
class Command;
class Context;
class IMode;
class BaseMode;
}
namespace Utils {
......@@ -69,8 +68,8 @@ class DEBUGGER_EXPORT DebuggerUISwitcher : public QObject
Q_OBJECT
public:
explicit DebuggerUISwitcher(Core::BaseMode *mode, QObject *parent = 0);
virtual ~DebuggerUISwitcher();
explicit DebuggerUISwitcher(QObject *parent = 0);
~DebuggerUISwitcher();
// debuggable languages are registered with this function.
void addLanguage(const DebuggerLanguage &language, const Core::Context &context);
......@@ -109,6 +108,8 @@ public:
Qt::DockWidgetArea area = Qt::TopDockWidgetArea);
Utils::FancyMainWindow *mainWindow() const;
QWidget *createContents(Core::IMode *mode);
QWidget *createMainWindow(Core::IMode *mode);
signals:
// emit when user changes active languages from the menu.
......@@ -146,9 +147,6 @@ private:
bool isQmlCppActive() const;
bool isQmlActive() const;
QWidget *createContents(Core::BaseMode *mode);
QWidget *createMainWindow(Core::BaseMode *mode);
DebuggerUISwitcherPrivate *d;
};
......
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