Commit 6321e4eb authored by hjk's avatar hjk
Browse files

debugger: closer dependency plugin<->manager, less signal/slot connections

parent 944b6dad
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "debuggermanager.h" #include "debuggermanager.h"
#include "debuggerplugin.h"
#include "debuggeractions.h" #include "debuggeractions.h"
#include "debuggeragents.h" #include "debuggeragents.h"
#include "debuggerrunner.h" #include "debuggerrunner.h"
...@@ -305,6 +306,7 @@ struct DebuggerManagerPrivate ...@@ -305,6 +306,7 @@ struct DebuggerManagerPrivate
DebuggerState m_state; DebuggerState m_state;
CPlusPlus::Snapshot m_codeModelSnapshot; CPlusPlus::Snapshot m_codeModelSnapshot;
DebuggerPlugin *m_plugin;
}; };
DebuggerManager *DebuggerManagerPrivate::instance = 0; DebuggerManager *DebuggerManagerPrivate::instance = 0;
...@@ -322,10 +324,11 @@ DebuggerManagerPrivate::DebuggerManagerPrivate(DebuggerManager *manager) : ...@@ -322,10 +324,11 @@ DebuggerManagerPrivate::DebuggerManagerPrivate(DebuggerManager *manager) :
m_stopIcon.addFile(":/debugger/images/debugger_stop.png"); m_stopIcon.addFile(":/debugger/images/debugger_stop.png");
} }
DebuggerManager::DebuggerManager() DebuggerManager::DebuggerManager(DebuggerPlugin *plugin)
: d(new DebuggerManagerPrivate(this)) : d(new DebuggerManagerPrivate(this))
{ {
DebuggerManagerPrivate::instance = this; DebuggerManagerPrivate::instance = this;
d->m_plugin = plugin;
init(); init();
} }
...@@ -564,17 +567,17 @@ void DebuggerManager::init() ...@@ -564,17 +567,17 @@ void DebuggerManager::init()
this, SLOT(reloadModules()), Qt::QueuedConnection); this, SLOT(reloadModules()), Qt::QueuedConnection);
d->m_registerDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_registerWindow, d->m_registerDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_registerWindow,
Qt::TopDockWidgetArea, false); Qt::TopDockWidgetArea, false);
connect(d->m_registerDock->toggleViewAction(), SIGNAL(toggled(bool)), connect(d->m_registerDock->toggleViewAction(), SIGNAL(toggled(bool)),
this, SLOT(reloadRegisters()), Qt::QueuedConnection); this, SLOT(reloadRegisters()), Qt::QueuedConnection);
d->m_outputDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_outputWindow, d->m_outputDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_outputWindow,
Qt::TopDockWidgetArea, false); Qt::TopDockWidgetArea, false);
d->m_snapshotDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_snapshotWindow); d->m_snapshotDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_snapshotWindow);
d->m_stackDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_stackWindow); d->m_stackDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_stackWindow);
d->m_sourceFilesDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_sourceFilesWindow, d->m_sourceFilesDock = uiSwitcher->createDockWidget(LANG_CPP,
Qt::TopDockWidgetArea, false); d->m_sourceFilesWindow, Qt::TopDockWidgetArea, false);
connect(d->m_sourceFilesDock->toggleViewAction(), SIGNAL(toggled(bool)), connect(d->m_sourceFilesDock->toggleViewAction(), SIGNAL(toggled(bool)),
this, SLOT(reloadSourceFiles()), Qt::QueuedConnection); this, SLOT(reloadSourceFiles()), Qt::QueuedConnection);
...@@ -588,7 +591,8 @@ void DebuggerManager::init() ...@@ -588,7 +591,8 @@ void DebuggerManager::init()
localsAndWatchers->setStretchFactor(0, 3); localsAndWatchers->setStretchFactor(0, 3);
localsAndWatchers->setStretchFactor(1, 1); localsAndWatchers->setStretchFactor(1, 1);
localsAndWatchers->setStretchFactor(2, 1); localsAndWatchers->setStretchFactor(2, 1);
d->m_watchDock = DebuggerUISwitcher::instance()->createDockWidget(LANG_CPP, localsAndWatchers); d->m_watchDock = DebuggerUISwitcher::instance()->createDockWidget(LANG_CPP,
localsAndWatchers);
d->m_dockWidgets << d->m_breakDock << d->m_modulesDock << d->m_registerDock d->m_dockWidgets << d->m_breakDock << d->m_modulesDock << d->m_registerDock
<< d->m_outputDock << d->m_stackDock << d->m_sourceFilesDock << d->m_outputDock << d->m_stackDock << d->m_sourceFilesDock
<< d->m_threadsDock << d->m_watchDock; << d->m_threadsDock << d->m_watchDock;
...@@ -691,7 +695,8 @@ QWidget *DebuggerManager::threadsWindow() const ...@@ -691,7 +695,8 @@ QWidget *DebuggerManager::threadsWindow() const
void DebuggerManager::createNewDock(QWidget *widget) void DebuggerManager::createNewDock(QWidget *widget)
{ {
QDockWidget *dockWidget = DebuggerUISwitcher::instance()->createDockWidget(LANG_CPP, widget); QDockWidget *dockWidget =
DebuggerUISwitcher::instance()->createDockWidget(LANG_CPP, widget);
dockWidget->setWindowTitle(widget->windowTitle()); dockWidget->setWindowTitle(widget->windowTitle());
dockWidget->setObjectName(widget->windowTitle()); dockWidget->setObjectName(widget->windowTitle());
dockWidget->setFeatures(QDockWidget::DockWidgetClosable); dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
...@@ -860,7 +865,7 @@ void DebuggerManager::toggleBreakpoint() ...@@ -860,7 +865,7 @@ void DebuggerManager::toggleBreakpoint()
{ {
QString fileName; QString fileName;
int lineNumber = -1; int lineNumber = -1;
queryCurrentTextEditor(&fileName, &lineNumber, 0); d->m_plugin->currentTextEditor(&fileName, &lineNumber);
if (lineNumber == -1) if (lineNumber == -1)
return; return;
toggleBreakpoint(fileName, lineNumber); toggleBreakpoint(fileName, lineNumber);
...@@ -1047,9 +1052,10 @@ void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp) ...@@ -1047,9 +1052,10 @@ void DebuggerManager::startNewDebugger(const DebuggerStartParametersPtr &sp)
d->m_startParameters = sp; d->m_startParameters = sp;
d->m_inferiorPid = d->m_startParameters->attachPID > 0 d->m_inferiorPid = d->m_startParameters->attachPID > 0
? d->m_startParameters->attachPID : 0; ? d->m_startParameters->attachPID : 0;
const QString toolChainName = ProjectExplorer::ToolChain::toolChainName(static_cast<ProjectExplorer::ToolChain::ToolChainType>(d->m_startParameters->toolChainType)); const QString toolChainName = ProjectExplorer::ToolChain::toolChainName(
ProjectExplorer::ToolChain::ToolChainType(d->m_startParameters->toolChainType));
emit debugModeRequested(); d->m_plugin->activateDebugMode();
showDebuggerOutput(LogStatus, showDebuggerOutput(LogStatus,
tr("Starting debugger for tool chain '%1'...").arg(toolChainName)); tr("Starting debugger for tool chain '%1'...").arg(toolChainName));
showDebuggerOutput(LogDebug, DebuggerSettings::instance()->dump()); showDebuggerOutput(LogDebug, DebuggerSettings::instance()->dump());
...@@ -1347,12 +1353,6 @@ void DebuggerManager::setBusyCursor(bool busy) ...@@ -1347,12 +1353,6 @@ void DebuggerManager::setBusyCursor(bool busy)
d->m_watchersWindow->setCursor(cursor); d->m_watchersWindow->setCursor(cursor);
} }
void DebuggerManager::queryCurrentTextEditor(QString *fileName, int *lineNumber,
QObject **object)
{
emit currentTextEditorRequested(fileName, lineNumber, object);
}
void DebuggerManager::continueExec() void DebuggerManager::continueExec()
{ {
if (d->m_engine) if (d->m_engine)
...@@ -1382,7 +1382,7 @@ void DebuggerManager::runToLineExec() ...@@ -1382,7 +1382,7 @@ void DebuggerManager::runToLineExec()
{ {
QString fileName; QString fileName;
int lineNumber = -1; int lineNumber = -1;
emit currentTextEditorRequested(&fileName, &lineNumber, 0); d->m_plugin->currentTextEditor(&fileName, &lineNumber);
if (d->m_engine && !fileName.isEmpty()) { if (d->m_engine && !fileName.isEmpty()) {
STATE_DEBUG(fileName << lineNumber); STATE_DEBUG(fileName << lineNumber);
d->m_engine->runToLineExec(fileName, lineNumber); d->m_engine->runToLineExec(fileName, lineNumber);
...@@ -1393,8 +1393,7 @@ void DebuggerManager::runToFunctionExec() ...@@ -1393,8 +1393,7 @@ void DebuggerManager::runToFunctionExec()
{ {
QString fileName; QString fileName;
int lineNumber = -1; int lineNumber = -1;
QObject *object = 0; QObject *object = d->m_plugin->currentTextEditor(&fileName, &lineNumber);
emit currentTextEditorRequested(&fileName, &lineNumber, &object);
QPlainTextEdit *ed = qobject_cast<QPlainTextEdit*>(object); QPlainTextEdit *ed = qobject_cast<QPlainTextEdit*>(object);
if (!ed) if (!ed)
return; return;
...@@ -1426,7 +1425,7 @@ void DebuggerManager::jumpToLineExec() ...@@ -1426,7 +1425,7 @@ void DebuggerManager::jumpToLineExec()
{ {
QString fileName; QString fileName;
int lineNumber = -1; int lineNumber = -1;
emit currentTextEditorRequested(&fileName, &lineNumber, 0); d->m_plugin->currentTextEditor(&fileName, &lineNumber);
if (d->m_engine && !fileName.isEmpty()) { if (d->m_engine && !fileName.isEmpty()) {
STATE_DEBUG(fileName << lineNumber); STATE_DEBUG(fileName << lineNumber);
d->m_engine->jumpToLineExec(fileName, lineNumber); d->m_engine->jumpToLineExec(fileName, lineNumber);
...@@ -1438,18 +1437,18 @@ void DebuggerManager::resetLocation() ...@@ -1438,18 +1437,18 @@ void DebuggerManager::resetLocation()
d->m_disassemblerViewAgent.resetLocation(); d->m_disassemblerViewAgent.resetLocation();
d->m_stackHandler->setCurrentIndex(-1); d->m_stackHandler->setCurrentIndex(-1);
// Connected to the plugin. // Connected to the plugin.
emit resetLocationRequested(); d->m_plugin->resetLocation();
} }
void DebuggerManager::gotoLocation(const Debugger::Internal::StackFrame &frame, bool setMarker) void DebuggerManager::gotoLocation(const StackFrame &frame, bool setMarker)
{ {
if (theDebuggerBoolSetting(OperateByInstruction) || !frame.isUsable()) { if (theDebuggerBoolSetting(OperateByInstruction) || !frame.isUsable()) {
if (setMarker) if (setMarker)
emit resetLocationRequested(); d->m_plugin->resetLocation();
d->m_disassemblerViewAgent.setFrame(frame); d->m_disassemblerViewAgent.setFrame(frame);
} else { } else {
// Connected to the plugin. // Connected to the plugin.
emit gotoLocationRequested(frame.file, frame.line, setMarker); d->m_plugin->gotoLocation(frame.file, frame.line, setMarker);
} }
} }
...@@ -1633,15 +1632,12 @@ bool DebuggerManager::isReverseDebugging() const ...@@ -1633,15 +1632,12 @@ bool DebuggerManager::isReverseDebugging() const
QVariant DebuggerManager::sessionValue(const QString &name) QVariant DebuggerManager::sessionValue(const QString &name)
{ {
// this is answered by the plugin return d->m_plugin->sessionValue(name);
QVariant value;
emit sessionValueRequested(name, &value);
return value;
} }
void DebuggerManager::setSessionValue(const QString &name, const QVariant &value) void DebuggerManager::setSessionValue(const QString &name, const QVariant &value)
{ {
emit setSessionValueRequested(name, value); d->m_plugin->setSessionValue(name, value);
} }
QMessageBox *DebuggerManager::showMessageBox(int icon, const QString &title, QMessageBox *DebuggerManager::showMessageBox(int icon, const QString &title,
...@@ -1803,7 +1799,7 @@ void DebuggerManager::setState(DebuggerState state, bool forced) ...@@ -1803,7 +1799,7 @@ void DebuggerManager::setState(DebuggerState state, bool forced)
theDebuggerAction(ExpandStack)->setEnabled(actionsEnabled); theDebuggerAction(ExpandStack)->setEnabled(actionsEnabled);
theDebuggerAction(ExecuteCommand)->setEnabled(d->m_state != DebuggerNotReady); theDebuggerAction(ExecuteCommand)->setEnabled(d->m_state != DebuggerNotReady);
emit stateChanged(d->m_state); d->m_plugin->handleStateChanged(d->m_state);
const bool notbusy = state == InferiorStopped const bool notbusy = state == InferiorStopped
|| state == DebuggerNotReady || state == DebuggerNotReady
|| state == InferiorUnrunnable; || state == InferiorUnrunnable;
......
...@@ -87,7 +87,6 @@ class ScriptEngine; ...@@ -87,7 +87,6 @@ class ScriptEngine;
class CdbDebugEngine; class CdbDebugEngine;
class CdbDebugEnginePrivate; class CdbDebugEnginePrivate;
struct DebuggerManagerActions; struct DebuggerManagerActions;
class DebuggerPlugin;
class CdbDebugEventCallback; class CdbDebugEventCallback;
class CdbDumperHelper; class CdbDumperHelper;
class CdbDumperInitThread; class CdbDumperInitThread;
...@@ -158,7 +157,7 @@ class DEBUGGER_EXPORT DebuggerManager : public QObject ...@@ -158,7 +157,7 @@ class DEBUGGER_EXPORT DebuggerManager : public QObject
Q_OBJECT Q_OBJECT
public: public:
DebuggerManager(); explicit DebuggerManager(Internal::DebuggerPlugin *plugin);
~DebuggerManager(); ~DebuggerManager();
friend class Internal::IDebuggerEngine; friend class Internal::IDebuggerEngine;
...@@ -207,7 +206,6 @@ public slots: ...@@ -207,7 +206,6 @@ public slots:
void setSimpleDockWidgetArrangement(const QString &activeLanguage); void setSimpleDockWidgetArrangement(const QString &activeLanguage);
void setBusyCursor(bool on); void setBusyCursor(bool on);
void queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **ed);
void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setLocationMarker); void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setLocationMarker);
void fileOpen(const QString &file); void fileOpen(const QString &file);
...@@ -330,16 +328,7 @@ signals: ...@@ -330,16 +328,7 @@ signals:
void debuggingFinished(); void debuggingFinished();
void inferiorPidChanged(qint64 pid); void inferiorPidChanged(qint64 pid);
void stateChanged(int newstatus); void stateChanged(int newstatus);
void debugModeRequested();
void previousModeRequested();
void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever' void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
void gotoLocationRequested(const QString &file, int line, bool setLocationMarker);
void resetLocationRequested();
void currentTextEditorRequested(QString *fileName, int *lineNumber, QObject **ob);
void sessionValueRequested(const QString &name, QVariant *value);
void setSessionValueRequested(const QString &name, const QVariant &value);
void configValueRequested(const QString &name, QVariant *value);
void setConfigValueRequested(const QString &name, const QVariant &value);
void applicationOutputAvailable(const QString &output); void applicationOutputAvailable(const QString &output);
void emitShowOutput(int channel, const QString &output); void emitShowOutput(int channel, const QString &output);
void emitShowInput(int channel, const QString &input); void emitShowInput(int channel, const QString &input);
......
...@@ -86,6 +86,7 @@ ...@@ -86,6 +86,7 @@
#include <QtCore/QtPlugin> #include <QtCore/QtPlugin>
#include <QtCore/QCoreApplication> #include <QtCore/QCoreApplication>
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtCore/QVariant>
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QDockWidget> #include <QtGui/QDockWidget>
...@@ -674,11 +675,6 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -674,11 +675,6 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
ExtensionSystem::PluginManager::instance()->addObject(m_uiSwitcher); ExtensionSystem::PluginManager::instance()->addObject(m_uiSwitcher);
m_uiSwitcher->addLanguage(LANG_CPP); m_uiSwitcher->addLanguage(LANG_CPP);
m_manager = new DebuggerManager;
ExtensionSystem::PluginManager::instance()->addObject(m_manager);
const QList<Core::IOptionsPage *> engineOptionPages =
m_manager->initializeEngines(m_cmdLineEnabledEngines);
ICore *core = ICore::instance(); ICore *core = ICore::instance();
QTC_ASSERT(core, return false); QTC_ASSERT(core, return false);
...@@ -705,8 +701,13 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -705,8 +701,13 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
m_gdbRunningContext = uidm->uniqueIdentifier(Constants::GDBRUNNING); m_gdbRunningContext = uidm->uniqueIdentifier(Constants::GDBRUNNING);
DebuggerManager *manager = new DebuggerManager(this);
ExtensionSystem::PluginManager::instance()->addObject(manager);
const QList<Core::IOptionsPage *> engineOptionPages =
manager->initializeEngines(m_cmdLineEnabledEngines);
// register factory of DebuggerRunControl // register factory of DebuggerRunControl
m_debuggerRunControlFactory = new DebuggerRunControlFactory(m_manager); m_debuggerRunControlFactory = new DebuggerRunControlFactory(manager);
addAutoReleasedObject(m_debuggerRunControlFactory); addAutoReleasedObject(m_debuggerRunControlFactory);
QList<int> context; QList<int> context;
...@@ -741,13 +742,13 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -741,13 +742,13 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
m_detachAction = new QAction(this); m_detachAction = new QAction(this);
m_detachAction->setText(tr("Detach Debugger")); m_detachAction->setText(tr("Detach Debugger"));
connect(m_detachAction, SIGNAL(triggered()), connect(m_detachAction, SIGNAL(triggered()),
m_manager, SLOT(detachDebugger())); manager, SLOT(detachDebugger()));
// Core::ActionContainer *mdebug = // Core::ActionContainer *mdebug =
// am->actionContainer(ProjectExplorer::Constants::M_DEBUG); // am->actionContainer(ProjectExplorer::Constants::M_DEBUG);
Core::Command *cmd = 0; Core::Command *cmd = 0;
const DebuggerManagerActions actions = m_manager->debuggerManagerActions(); const DebuggerManagerActions actions = manager->debuggerManagerActions();
Core::ActionContainer *mstart = Core::ActionContainer *mstart =
...@@ -902,34 +903,33 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -902,34 +903,33 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
addAutoReleasedObject(new DebuggerListener); addAutoReleasedObject(new DebuggerListener);
m_locationMark = 0; m_locationMark = 0;
m_manager->setSimpleDockWidgetArrangement(LANG_CPP); manager->setSimpleDockWidgetArrangement(LANG_CPP);
readSettings(); readSettings();
m_uiSwitcher->setToolbar(LANG_CPP, createToolbar());
connect(m_uiSwitcher, SIGNAL(dockArranged(QString)), m_manager,
SLOT(setSimpleDockWidgetArrangement(QString)));
connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), connect(ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)),
this, SLOT(onModeChanged(Core::IMode*))); this, SLOT(onModeChanged(Core::IMode*)));
m_debugMode->widget()->setFocusProxy(EditorManager::instance()); m_debugMode->widget()->setFocusProxy(EditorManager::instance());
addObject(m_debugMode); addObject(m_debugMode);
m_manager = manager;
// //
// Connections // Connections
// //
// TextEditor // TextEditor
connect(TextEditor::TextEditorPlugin::instance(), connect(TextEditorPlugin::instance(),
SIGNAL(fontSettingsChanged(TextEditor::FontSettings)), SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
m_manager, SLOT(fontSettingsChanged(TextEditor::FontSettings))); manager, SLOT(fontSettingsChanged(TextEditor::FontSettings)));
// ProjectExplorer // ProjectExplorer
connect(sessionManager(), SIGNAL(sessionLoaded()), connect(sessionManager(), SIGNAL(sessionLoaded()),
m_manager, SLOT(sessionLoaded())); manager, SLOT(sessionLoaded()));
connect(sessionManager(), SIGNAL(aboutToSaveSession()), connect(sessionManager(), SIGNAL(aboutToSaveSession()),
m_manager, SLOT(aboutToSaveSession())); manager, SLOT(aboutToSaveSession()));
connect(sessionManager(), SIGNAL(aboutToUnloadSession()), connect(sessionManager(), SIGNAL(aboutToUnloadSession()),
m_manager, SLOT(aboutToUnloadSession())); manager, SLOT(aboutToUnloadSession()));
// EditorManager // EditorManager
QObject *editorManager = core->editorManager(); QObject *editorManager = core->editorManager();
...@@ -939,60 +939,46 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -939,60 +939,46 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
this, SLOT(editorOpened(Core::IEditor*))); this, SLOT(editorOpened(Core::IEditor*)));
// Application interaction // Application interaction
connect(m_manager, SIGNAL(currentTextEditorRequested(QString*,int*,QObject**)),
this, SLOT(queryCurrentTextEditor(QString*,int*,QObject**)));
connect(m_manager, SIGNAL(setSessionValueRequested(QString,QVariant)),
this, SLOT(setSessionValue(QString,QVariant)));
connect(m_manager, SIGNAL(sessionValueRequested(QString,QVariant*)),
this, SLOT(querySessionValue(QString,QVariant*)));
connect(m_manager, SIGNAL(resetLocationRequested()),
this, SLOT(resetLocation()));
connect(m_manager, SIGNAL(gotoLocationRequested(QString,int,bool)),
this, SLOT(gotoLocation(QString,int,bool)));
connect(m_manager, SIGNAL(stateChanged(int)),
this, SLOT(handleStateChanged(int)));
connect(m_manager, SIGNAL(previousModeRequested()),
this, SLOT(activatePreviousMode()));
connect(m_manager, SIGNAL(debugModeRequested()),
this, SLOT(activateDebugMode()));
connect(theDebuggerAction(SettingsDialog), SIGNAL(triggered()), connect(theDebuggerAction(SettingsDialog), SIGNAL(triggered()),
this, SLOT(showSettingsDialog())); this, SLOT(showSettingsDialog()));
handleStateChanged(DebuggerNotReady); handleStateChanged(DebuggerNotReady);
m_uiSwitcher->setToolbar(LANG_CPP, createToolbar());
connect(m_uiSwitcher, SIGNAL(dockArranged(QString)), manager,
SLOT(setSimpleDockWidgetArrangement(QString)));
return true; return true;
} }
QWidget *DebuggerPlugin::createToolbar() const QWidget *DebuggerPlugin::createToolbar() const
{ {
Core::ActionManager *am = ICore::instance()->actionManager(); Core::ActionManager *am = ICore::instance()->actionManager();
QWidget *toolbarContainer = new QWidget; QWidget *toolbarContainer = new QWidget;
QHBoxLayout *debugToolBarLayout = new QHBoxLayout(toolbarContainer);
QHBoxLayout *hbox = new QHBoxLayout(toolbarContainer);
debugToolBarLayout->setMargin(0); hbox->setMargin(0);
debugToolBarLayout->setSpacing(0); hbox->setSpacing(0);
debugToolBarLayout->addWidget(toolButton(am->command(ProjectExplorer::Constants::DEBUG)->action())); hbox->addWidget(toolButton(am->command(ProjectExplorer::Constants::DEBUG)->action()));
debugToolBarLayout->addWidget(toolButton(am->command(Constants::INTERRUPT)->action())); hbox->addWidget(toolButton(am->command(Constants::INTERRUPT)->action()));
debugToolBarLayout->addWidget(toolButton(am->command(Constants::NEXT)->action())); hbox->addWidget(toolButton(am->command(Constants::NEXT)->action()));
debugToolBarLayout->addWidget(toolButton(am->command(Constants::STEP)->action())); hbox->addWidget(toolButton(am->command(Constants::STEP)->action()));
debugToolBarLayout->addWidget(toolButton(am->command(Constants::STEPOUT)->action())); hbox->addWidget(toolButton(am->command(Constants::STEPOUT)->action()));
debugToolBarLayout->addWidget(toolButton(am->command(Constants::OPERATE_BY_INSTRUCTION)->action())); hbox->addWidget(toolButton(am->command(Constants::OPERATE_BY_INSTRUCTION)->action()));
#ifdef USE_REVERSE_DEBUGGING #ifdef USE_REVERSE_DEBUGGING
debugToolBarLayout->addWidget(new Utils::StyledSeparator); hbox->addWidget(new Utils::StyledSeparator);
debugToolBarLayout->addWidget(toolButton(am->command(Constants::REVERSE)->action())); hbox->addWidget(toolButton(am->command(Constants::REVERSE)->action()));
#endif #endif
debugToolBarLayout->addWidget(new Utils::StyledSeparator); hbox->addWidget(new Utils::StyledSeparator);
debugToolBarLayout->addWidget(new QLabel(tr("Threads:"))); hbox->addWidget(new QLabel(tr("Threads:")));
QComboBox *threadBox = new QComboBox; QComboBox *threadBox = new QComboBox;
threadBox->setModel(m_manager->threadsModel()); threadBox->setModel(m_manager->threadsModel());
connect(threadBox, SIGNAL(activated(int)), connect(threadBox, SIGNAL(activated(int)),
m_manager->threadsWindow(), SIGNAL(threadSelected(int))); m_manager->threadsWindow(), SIGNAL(threadSelected(int)));
debugToolBarLayout->addWidget(threadBox);
debugToolBarLayout->addWidget(m_manager->statusLabel(), 10); hbox->addWidget(threadBox);
hbox->addWidget(m_manager->statusLabel(), 10);
return toolbarContainer; return toolbarContainer;
} }
...@@ -1047,21 +1033,20 @@ void DebuggerPlugin::activateDebugMode() ...@@ -1047,21 +1033,20 @@ void DebuggerPlugin::activateDebugMode()
modeManager->activateMode(QLatin1String(MODE_DEBUG)); modeManager->activateMode(QLatin1String(MODE_DEBUG));
} }
void DebuggerPlugin::queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **object) QWidget *DebuggerPlugin::currentTextEditor(QString *fileName, int *lineNumber)
{ {
EditorManager *editorManager = EditorManager::instance(); EditorManager *editorManager = EditorManager::instance();
if (!editorManager) if (!editorManager)
return; return 0;
Core::IEditor *editor = editorManager->currentEditor(); Core::IEditor *editor = editorManager->currentEditor();
ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor); ITextEditor *textEditor = qobject_cast<ITextEditor*>(editor);
if (!textEditor) if (!textEditor)
return; return 0;
if (fileName) if (fileName)
*fileName = textEditor->file()->fileName(); *fileName = textEditor->file()->fileName();
if (lineNumber)