Commit 6683b408 authored by dt's avatar dt

ProjectExplorer + Debugger: Move Debug Action to the Debugger plugin

Since all the debuggers are implemented in the debuggerplugin, that's a
natural place to put the action.
parent 211e0d84
...@@ -84,6 +84,15 @@ namespace Internal { ...@@ -84,6 +84,15 @@ namespace Internal {
const char * const OPENED_BY_DEBUGGER = "OpenedByDebugger"; const char * const OPENED_BY_DEBUGGER = "OpenedByDebugger";
const char * const OPENED_WITH_DISASSEMBLY = "DisassemblerView"; const char * const OPENED_WITH_DISASSEMBLY = "DisassemblerView";
const char * const DEBUGMODE = "Debugger.DebugMode";
const char * const DEBUG = "Debugger.Debug";
const int P_ACTION_DEBUG = 90; //priority for the modemanager
#ifdef Q_OS_MAC
const char * const DEBUG_KEY = "Ctrl+Y";
#else
const char * const DEBUG_KEY = "F5";
#endif
} // namespace Constants } // namespace Constants
......
...@@ -958,6 +958,7 @@ public slots: ...@@ -958,6 +958,7 @@ public slots:
void onModeChanged(Core::IMode *mode); void onModeChanged(Core::IMode *mode);
void showSettingsDialog(); void showSettingsDialog();
void debugProject();
void startExternalApplication(); void startExternalApplication();
void startRemoteApplication(); void startRemoteApplication();
void attachExternalApplication(); void attachExternalApplication();
...@@ -1032,6 +1033,7 @@ public slots: ...@@ -1032,6 +1033,7 @@ public slots:
void coreShutdown(); void coreShutdown();
public slots: public slots:
void updateDebugActions();
void handleExecDetach() { currentEngine()->detachDebugger(); } void handleExecDetach() { currentEngine()->detachDebugger(); }
void handleExecContinue() { currentEngine()->continueInferior(); } void handleExecContinue() { currentEngine()->continueInferior(); }
void handleExecInterrupt() { currentEngine()->requestInterruptInferior(); } void handleExecInterrupt() { currentEngine()->requestInterruptInferior(); }
...@@ -1225,6 +1227,7 @@ public: ...@@ -1225,6 +1227,7 @@ public:
Context m_anyContext; Context m_anyContext;
AttachRemoteParameters m_attachRemoteParameters; AttachRemoteParameters m_attachRemoteParameters;
QAction *m_debugAction;
QAction *m_startExternalAction; QAction *m_startExternalAction;
QAction *m_startRemoteAction; QAction *m_startRemoteAction;
QAction *m_attachExternalAction; QAction *m_attachExternalAction;
...@@ -1611,6 +1614,14 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, ...@@ -1611,6 +1614,14 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
m_reverseToolButton = 0; m_reverseToolButton = 0;
// debug action
act = m_debugAction = new QAction(this);
QIcon debuggerIcon(":/projectexplorer/images/debugger_start_small.png");
debuggerIcon.addFile(":/projectexplorer/images/debugger_start.png");
act->setIcon(debuggerIcon);
act->setText(tr("Start Debugging"));
connect(act, SIGNAL(triggered()), this, SLOT(debugProject()));
// Handling of external applications. // Handling of external applications.
act = m_startExternalAction = new QAction(this); act = m_startExternalAction = new QAction(this);
act->setText(tr("Start and Debug External Application...")); act->setText(tr("Start and Debug External Application..."));
...@@ -1644,8 +1655,16 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, ...@@ -1644,8 +1655,16 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
Core::ActionContainer *mstart = Core::ActionContainer *mstart =
am->actionContainer(PE::M_DEBUG_STARTDEBUGGING); am->actionContainer(PE::M_DEBUG_STARTDEBUGGING);
cmd = am->registerAction(m_debugAction, Constants::DEBUG, globalcontext);
cmd->setAttribute(Core::Command::CA_UpdateText);
cmd->setAttribute(Core::Command::CA_UpdateIcon);
cmd->setDefaultText(tr("Start Debugging"));
cmd->setDefaultKeySequence(QKeySequence(Constants::DEBUG_KEY));
mstart->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
Core::ICore::instance()->modeManager()->addAction(cmd, Constants::P_ACTION_DEBUG);
cmd = am->registerAction(m_actions.continueAction, cmd = am->registerAction(m_actions.continueAction,
PE::DEBUG, m_continuableContext); Constants::DEBUG, m_continuableContext);
mstart->addAction(cmd, CC::G_DEFAULT_ONE); mstart->addAction(cmd, CC::G_DEFAULT_ONE);
cmd = am->registerAction(m_startExternalAction, cmd = am->registerAction(m_startExternalAction,
...@@ -1685,11 +1704,11 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, ...@@ -1685,11 +1704,11 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
m_uiSwitcher->addMenuAction(cmd, AnyLanguage, CC::G_DEFAULT_ONE); m_uiSwitcher->addMenuAction(cmd, AnyLanguage, CC::G_DEFAULT_ONE);
cmd = am->registerAction(m_actions.interruptAction, cmd = am->registerAction(m_actions.interruptAction,
PE::DEBUG, m_interruptibleContext); Constants::DEBUG, m_interruptibleContext);
cmd->setDefaultText(tr("Interrupt Debugger")); cmd->setDefaultText(tr("Interrupt Debugger"));
cmd = am->registerAction(m_actions.undisturbableAction, cmd = am->registerAction(m_actions.undisturbableAction,
PE::DEBUG, m_undisturbableContext); Constants::DEBUG, m_undisturbableContext);
cmd->setDefaultText(tr("Debugger is Busy")); cmd->setDefaultText(tr("Debugger is Busy"));
cmd = am->registerAction(m_actions.resetAction, cmd = am->registerAction(m_actions.resetAction,
...@@ -1856,6 +1875,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, ...@@ -1856,6 +1875,8 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
SLOT(aboutToSaveSession())); SLOT(aboutToSaveSession()));
connect(sessionManager(), SIGNAL(aboutToUnloadSession()), connect(sessionManager(), SIGNAL(aboutToUnloadSession()),
SLOT(aboutToUnloadSession())); SLOT(aboutToUnloadSession()));
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(updateRunActions()),
this, SLOT(updateDebugActions()));
// EditorManager // EditorManager
QObject *editorManager = core->editorManager(); QObject *editorManager = core->editorManager();
...@@ -1874,7 +1895,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, ...@@ -1874,7 +1895,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments,
QHBoxLayout *hbox = new QHBoxLayout(toolbarContainer); QHBoxLayout *hbox = new QHBoxLayout(toolbarContainer);
hbox->setMargin(0); hbox->setMargin(0);
hbox->setSpacing(0); hbox->setSpacing(0);
hbox->addWidget(toolButton(am->command(PE::DEBUG)->action())); hbox->addWidget(toolButton(am->command(Constants::DEBUG)->action()));
hbox->addWidget(toolButton(am->command(STOP)->action())); hbox->addWidget(toolButton(am->command(STOP)->action()));
hbox->addWidget(toolButton(am->command(NEXT)->action())); hbox->addWidget(toolButton(am->command(NEXT)->action()));
hbox->addWidget(toolButton(am->command(STEP)->action())); hbox->addWidget(toolButton(am->command(STEP)->action()));
...@@ -1972,6 +1993,15 @@ void DebuggerPluginPrivate::languagesChanged(const DebuggerLanguages &languages) ...@@ -1972,6 +1993,15 @@ void DebuggerPluginPrivate::languagesChanged(const DebuggerLanguages &languages)
m_detachAction->setVisible(debuggerIsCPP); m_detachAction->setVisible(debuggerIsCPP);
} }
void DebuggerPluginPrivate::debugProject()
{
Project *pro = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject();
if (!pro)
return;
ProjectExplorer::ProjectExplorerPlugin::instance()->runProject(pro, Constants::DEBUGMODE);
}
void DebuggerPluginPrivate::startExternalApplication() void DebuggerPluginPrivate::startExternalApplication()
{ {
DebuggerStartParameters sp; DebuggerStartParameters sp;
...@@ -2373,7 +2403,7 @@ void DebuggerPluginPrivate::displayDebugger(DebuggerEngine *engine, bool updateE ...@@ -2373,7 +2403,7 @@ void DebuggerPluginPrivate::displayDebugger(DebuggerEngine *engine, bool updateE
void DebuggerPluginPrivate::startDebugger(RunControl *rc) void DebuggerPluginPrivate::startDebugger(RunControl *rc)
{ {
QTC_ASSERT(rc, return); QTC_ASSERT(rc, return);
ProjectExplorerPlugin::instance()->startRunControl(rc, PE::DEBUGMODE); ProjectExplorerPlugin::instance()->startRunControl(rc, Constants::DEBUGMODE);
} }
...@@ -2631,7 +2661,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -2631,7 +2661,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_actions.continueAction->setEnabled(false); m_actions.continueAction->setEnabled(false);
m_actions.exitAction->setEnabled(false); m_actions.exitAction->setEnabled(false);
am->command(Constants::STOP)->setKeySequence(QKeySequence()); am->command(Constants::STOP)->setKeySequence(QKeySequence());
am->command(PE::DEBUG)->setKeySequence(QKeySequence(PE::DEBUG_KEY)); am->command(Constants::DEBUG)->setKeySequence(QKeySequence(DEBUG_KEY));
core->updateAdditionalContexts(m_anyContext, Context()); core->updateAdditionalContexts(m_anyContext, Context());
} else if (m_state == InferiorStopOk) { } else if (m_state == InferiorStopOk) {
// F5 continues, Shift-F5 kills. It is "continuable". // F5 continues, Shift-F5 kills. It is "continuable".
...@@ -2639,7 +2669,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -2639,7 +2669,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_actions.continueAction->setEnabled(true); m_actions.continueAction->setEnabled(true);
m_actions.exitAction->setEnabled(true); m_actions.exitAction->setEnabled(true);
am->command(Constants::STOP)->setKeySequence(QKeySequence(STOP_KEY)); am->command(Constants::STOP)->setKeySequence(QKeySequence(STOP_KEY));
am->command(PE::DEBUG)->setKeySequence(QKeySequence(PE::DEBUG_KEY)); am->command(Constants::DEBUG)->setKeySequence(QKeySequence(DEBUG_KEY));
core->updateAdditionalContexts(m_anyContext, m_continuableContext); core->updateAdditionalContexts(m_anyContext, m_continuableContext);
} else if (m_state == InferiorRunOk) { } else if (m_state == InferiorRunOk) {
// Shift-F5 interrupts. It is also "interruptible". // Shift-F5 interrupts. It is also "interruptible".
...@@ -2647,7 +2677,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -2647,7 +2677,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_actions.continueAction->setEnabled(false); m_actions.continueAction->setEnabled(false);
m_actions.exitAction->setEnabled(false); m_actions.exitAction->setEnabled(false);
am->command(Constants::STOP)->setKeySequence(QKeySequence()); am->command(Constants::STOP)->setKeySequence(QKeySequence());
am->command(PE::DEBUG)->setKeySequence(QKeySequence(STOP_KEY)); am->command(Constants::DEBUG)->setKeySequence(QKeySequence(STOP_KEY));
core->updateAdditionalContexts(m_anyContext, m_interruptibleContext); core->updateAdditionalContexts(m_anyContext, m_interruptibleContext);
} else if (m_state == DebuggerFinished) { } else if (m_state == DebuggerFinished) {
// We don't want to do anything anymore. // We don't want to do anything anymore.
...@@ -2655,7 +2685,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -2655,7 +2685,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_actions.continueAction->setEnabled(false); m_actions.continueAction->setEnabled(false);
m_actions.exitAction->setEnabled(false); m_actions.exitAction->setEnabled(false);
am->command(Constants::STOP)->setKeySequence(QKeySequence()); am->command(Constants::STOP)->setKeySequence(QKeySequence());
am->command(PE::DEBUG)->setKeySequence(QKeySequence(PE::DEBUG_KEY)); am->command(Constants::DEBUG)->setKeySequence(QKeySequence(DEBUG_KEY));
//core->updateAdditionalContexts(m_anyContext, m_finishedContext); //core->updateAdditionalContexts(m_anyContext, m_finishedContext);
m_codeModelSnapshot = CPlusPlus::Snapshot(); m_codeModelSnapshot = CPlusPlus::Snapshot();
core->updateAdditionalContexts(m_anyContext, Context()); core->updateAdditionalContexts(m_anyContext, Context());
...@@ -2667,7 +2697,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -2667,7 +2697,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_actions.continueAction->setEnabled(false); m_actions.continueAction->setEnabled(false);
m_actions.exitAction->setEnabled(true); m_actions.exitAction->setEnabled(true);
am->command(Constants::STOP)->setKeySequence(QKeySequence(STOP_KEY)); am->command(Constants::STOP)->setKeySequence(QKeySequence(STOP_KEY));
am->command(PE::DEBUG)->setKeySequence(QKeySequence(STOP_KEY)); am->command(Constants::DEBUG)->setKeySequence(QKeySequence(STOP_KEY));
core->updateAdditionalContexts(m_anyContext, m_finishedContext); core->updateAdditionalContexts(m_anyContext, m_finishedContext);
} else { } else {
// Everything else is "undisturbable". // Everything else is "undisturbable".
...@@ -2675,7 +2705,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -2675,7 +2705,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_actions.continueAction->setEnabled(false); m_actions.continueAction->setEnabled(false);
m_actions.exitAction->setEnabled(false); m_actions.exitAction->setEnabled(false);
am->command(Constants::STOP)->setKeySequence(QKeySequence()); am->command(Constants::STOP)->setKeySequence(QKeySequence());
am->command(PE::DEBUG)->setKeySequence(QKeySequence()); am->command(Constants::DEBUG)->setKeySequence(QKeySequence());
core->updateAdditionalContexts(m_anyContext, m_undisturbableContext); core->updateAdditionalContexts(m_anyContext, m_undisturbableContext);
} }
...@@ -2738,6 +2768,13 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -2738,6 +2768,13 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_scriptConsoleWindow->setEnabled(stopped); m_scriptConsoleWindow->setEnabled(stopped);
} }
void DebuggerPluginPrivate::updateDebugActions()
{
ProjectExplorer::ProjectExplorerPlugin *peplugin = ProjectExplorer::ProjectExplorerPlugin::instance();
Project *project = peplugin->startupProject();
m_debugAction->setEnabled(peplugin->canRun(project, Constants::DEBUGMODE));
}
void DebuggerPluginPrivate::gotoLocation(const QString &file, int line, bool setMarker) void DebuggerPluginPrivate::gotoLocation(const QString &file, int line, bool setMarker)
{ {
// CDB might hit on breakpoints while shutting down. // CDB might hit on breakpoints while shutting down.
......
...@@ -122,7 +122,7 @@ DebuggerRunControlFactory::DebuggerRunControlFactory(QObject *parent, ...@@ -122,7 +122,7 @@ DebuggerRunControlFactory::DebuggerRunControlFactory(QObject *parent,
bool DebuggerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const bool DebuggerRunControlFactory::canRun(RunConfiguration *runConfiguration, const QString &mode) const
{ {
// return mode == ProjectExplorer::Constants::DEBUGMODE; // return mode == ProjectExplorer::Constants::DEBUGMODE;
return mode == ProjectExplorer::Constants::DEBUGMODE return mode == Constants::DEBUGMODE
&& qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration); && qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
} }
...@@ -208,7 +208,7 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu ...@@ -208,7 +208,7 @@ static DebuggerStartParameters localStartParameters(RunConfiguration *runConfigu
RunControl *DebuggerRunControlFactory::create RunControl *DebuggerRunControlFactory::create
(RunConfiguration *runConfiguration, const QString &mode) (RunConfiguration *runConfiguration, const QString &mode)
{ {
QTC_ASSERT(mode == ProjectExplorer::Constants::DEBUGMODE, return 0); QTC_ASSERT(mode == Constants::DEBUGMODE, return 0);
DebuggerStartParameters sp = localStartParameters(runConfiguration); DebuggerStartParameters sp = localStartParameters(runConfiguration);
return create(sp, runConfiguration); return create(sp, runConfiguration);
} }
...@@ -277,7 +277,7 @@ DebuggerRunnerPrivate::DebuggerRunnerPrivate(RunConfiguration *runConfiguration, ...@@ -277,7 +277,7 @@ DebuggerRunnerPrivate::DebuggerRunnerPrivate(RunConfiguration *runConfiguration,
DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration, DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration,
unsigned enabledEngines, const DebuggerStartParameters &sp) unsigned enabledEngines, const DebuggerStartParameters &sp)
: RunControl(runConfiguration, ProjectExplorer::Constants::DEBUGMODE), : RunControl(runConfiguration, Constants::DEBUGMODE),
d(new DebuggerRunnerPrivate(runConfiguration, enabledEngines)) d(new DebuggerRunnerPrivate(runConfiguration, enabledEngines))
{ {
connect(this, SIGNAL(finished()), this, SLOT(handleFinished())); connect(this, SIGNAL(finished()), this, SLOT(handleFinished()));
......
...@@ -87,9 +87,6 @@ OutputPane::OutputPane() : ...@@ -87,9 +87,6 @@ OutputPane::OutputPane() :
m_runIcon.addFile(Constants::ICON_RUN); m_runIcon.addFile(Constants::ICON_RUN);
m_runIcon.addFile(Constants::ICON_RUN_SMALL); m_runIcon.addFile(Constants::ICON_RUN_SMALL);
m_debugIcon.addFile(Constants::ICON_DEBUG);
m_debugIcon.addFile(Constants::ICON_DEBUG_SMALL);
// Rerun // Rerun
m_reRunButton->setIcon(m_runIcon); m_reRunButton->setIcon(m_runIcon);
m_reRunButton->setToolTip(tr("Re-run this run-configuration")); m_reRunButton->setToolTip(tr("Re-run this run-configuration"));
...@@ -394,7 +391,7 @@ void OutputPane::tabChanged(int i) ...@@ -394,7 +391,7 @@ void OutputPane::tabChanged(int i)
RunControl *rc = m_runControlTabs.at(index).runControl; RunControl *rc = m_runControlTabs.at(index).runControl;
m_stopAction->setEnabled(rc->isRunning()); m_stopAction->setEnabled(rc->isRunning());
m_reRunButton->setEnabled(!rc->isRunning()); m_reRunButton->setEnabled(!rc->isRunning());
m_reRunButton->setIcon(rc->runMode() == Constants::DEBUGMODE ? m_debugIcon : m_runIcon); m_reRunButton->setIcon(m_runIcon);
} }
} }
...@@ -404,7 +401,7 @@ void OutputPane::runControlStarted() ...@@ -404,7 +401,7 @@ void OutputPane::runControlStarted()
if (current && current == sender()) { if (current && current == sender()) {
m_reRunButton->setEnabled(false); m_reRunButton->setEnabled(false);
m_stopAction->setEnabled(true); m_stopAction->setEnabled(true);
m_reRunButton->setIcon(current->runMode() == Constants::DEBUGMODE ? m_debugIcon : m_runIcon); m_reRunButton->setIcon(m_runIcon);
} }
} }
...@@ -425,7 +422,7 @@ void OutputPane::runControlFinished() ...@@ -425,7 +422,7 @@ void OutputPane::runControlFinished()
if (current && current == sender()) { if (current && current == sender()) {
m_reRunButton->setEnabled(true); m_reRunButton->setEnabled(true);
m_stopAction->setEnabled(false); m_stopAction->setEnabled(false);
m_reRunButton->setIcon(current->runMode() == Constants::DEBUGMODE ? m_debugIcon : m_runIcon); m_reRunButton->setIcon(m_runIcon);
} }
// Check for asynchronous close. Close the tab. // Check for asynchronous close. Close the tab.
if (m_runControlTabs.at(senderIndex).asyncClosing) if (m_runControlTabs.at(senderIndex).asyncClosing)
......
...@@ -139,7 +139,6 @@ private: ...@@ -139,7 +139,6 @@ private:
QToolButton *m_reRunButton; QToolButton *m_reRunButton;
QToolButton *m_stopButton; QToolButton *m_stopButton;
QIcon m_runIcon; QIcon m_runIcon;
QIcon m_debugIcon;
}; };
......
...@@ -160,7 +160,6 @@ struct ProjectExplorerPluginPrivate { ...@@ -160,7 +160,6 @@ struct ProjectExplorerPluginPrivate {
QAction *m_runAction; QAction *m_runAction;
QAction *m_runActionContextMenu; QAction *m_runActionContextMenu;
QAction *m_cancelBuildAction; QAction *m_cancelBuildAction;
QAction *m_debugAction;
QAction *m_addNewFileAction; QAction *m_addNewFileAction;
QAction *m_addExistingFilesAction; QAction *m_addExistingFilesAction;
QAction *m_addNewSubprojectAction; QAction *m_addNewSubprojectAction;
...@@ -689,18 +688,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er ...@@ -689,18 +688,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
cmd = am->registerAction(d->m_cancelBuildAction, Constants::CANCELBUILD, globalcontext); cmd = am->registerAction(d->m_cancelBuildAction, Constants::CANCELBUILD, globalcontext);
mbuild->addAction(cmd, Constants::G_BUILD_CANCEL); mbuild->addAction(cmd, Constants::G_BUILD_CANCEL);
// debug action
QIcon debuggerIcon(":/projectexplorer/images/debugger_start_small.png");
debuggerIcon.addFile(":/projectexplorer/images/debugger_start.png");
d->m_debugAction = new QAction(debuggerIcon, tr("Start Debugging"), this);
cmd = am->registerAction(d->m_debugAction, Constants::DEBUG, globalcontext);
cmd->setAttribute(Core::Command::CA_UpdateText);
cmd->setAttribute(Core::Command::CA_UpdateIcon);
cmd->setDefaultText(tr("Start Debugging"));
cmd->setDefaultKeySequence(QKeySequence(Constants::DEBUG_KEY));
mstartdebugging->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
modeManager->addAction(cmd, Constants::P_ACTION_DEBUG);
// add new file action // add new file action
d->m_addNewFileAction = new QAction(tr("Add New..."), this); d->m_addNewFileAction = new QAction(tr("Add New..."), this);
cmd = am->registerAction(d->m_addNewFileAction, ProjectExplorer::Constants::ADDNEWFILE, cmd = am->registerAction(d->m_addNewFileAction, ProjectExplorer::Constants::ADDNEWFILE,
...@@ -841,7 +828,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er ...@@ -841,7 +828,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(d->m_runAction, SIGNAL(triggered()), this, SLOT(runProject())); connect(d->m_runAction, SIGNAL(triggered()), this, SLOT(runProject()));
connect(d->m_runActionContextMenu, SIGNAL(triggered()), this, SLOT(runProjectContextMenu())); connect(d->m_runActionContextMenu, SIGNAL(triggered()), this, SLOT(runProjectContextMenu()));
connect(d->m_cancelBuildAction, SIGNAL(triggered()), this, SLOT(cancelBuild())); connect(d->m_cancelBuildAction, SIGNAL(triggered()), this, SLOT(cancelBuild()));
connect(d->m_debugAction, SIGNAL(triggered()), this, SLOT(debugProject()));
connect(d->m_unloadAction, SIGNAL(triggered()), this, SLOT(unloadProject())); connect(d->m_unloadAction, SIGNAL(triggered()), this, SLOT(unloadProject()));
connect(d->m_clearSession, SIGNAL(triggered()), this, SLOT(clearSession())); connect(d->m_clearSession, SIGNAL(triggered()), this, SLOT(clearSession()));
connect(d->m_addNewFileAction, SIGNAL(triggered()), this, SLOT(addNewFile())); connect(d->m_addNewFileAction, SIGNAL(triggered()), this, SLOT(addNewFile()));
...@@ -856,6 +842,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er ...@@ -856,6 +842,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(d->m_renameFileAction, SIGNAL(triggered()), this, SLOT(renameFile())); connect(d->m_renameFileAction, SIGNAL(triggered()), this, SLOT(renameFile()));
connect(d->m_setStartupProjectAction, SIGNAL(triggered()), this, SLOT(setStartupProject())); connect(d->m_setStartupProjectAction, SIGNAL(triggered()), this, SLOT(setStartupProject()));
connect(this, SIGNAL(updateRunActions()), this, SLOT(slotUpdateRunActions()));
updateActions(); updateActions();
connect(Core::ICore::instance(), SIGNAL(coreAboutToOpen()), connect(Core::ICore::instance(), SIGNAL(coreAboutToOpen()),
...@@ -1368,7 +1356,7 @@ void ProjectExplorerPlugin::startRunControl(RunControl *runControl, const QStrin ...@@ -1368,7 +1356,7 @@ void ProjectExplorerPlugin::startRunControl(RunControl *runControl, const QStrin
this, SLOT(runControlFinished())); this, SLOT(runControlFinished()));
runControl->start(); runControl->start();
updateRunActions(); emit updateRunActions();
} }
void ProjectExplorerPlugin::buildQueueFinished(bool success) void ProjectExplorerPlugin::buildQueueFinished(bool success)
...@@ -1755,16 +1743,7 @@ void ProjectExplorerPlugin::runProject(Project *pro, QString mode) ...@@ -1755,16 +1743,7 @@ void ProjectExplorerPlugin::runProject(Project *pro, QString mode)
} else { } else {
executeRunConfiguration(pro->activeTarget()->activeRunConfiguration(), mode); executeRunConfiguration(pro->activeTarget()->activeRunConfiguration(), mode);
} }
updateRunActions(); emit updateRunActions();
}
void ProjectExplorerPlugin::debugProject()
{
Project *pro = startupProject();
if (!pro)
return;
runProject(pro, ProjectExplorer::Constants::DEBUGMODE);
} }
bool ProjectExplorerPlugin::showBuildConfigDialog() bool ProjectExplorerPlugin::showBuildConfigDialog()
...@@ -1794,7 +1773,7 @@ bool ProjectExplorerPlugin::showBuildConfigDialog() ...@@ -1794,7 +1773,7 @@ bool ProjectExplorerPlugin::showBuildConfigDialog()
void ProjectExplorerPlugin::runControlFinished() void ProjectExplorerPlugin::runControlFinished()
{ {
updateRunActions(); emit updateRunActions();
} }
void ProjectExplorerPlugin::startupProjectChanged() void ProjectExplorerPlugin::startupProjectChanged()
...@@ -1821,7 +1800,7 @@ void ProjectExplorerPlugin::startupProjectChanged() ...@@ -1821,7 +1800,7 @@ void ProjectExplorerPlugin::startupProjectChanged()
activeTargetChanged(); activeTargetChanged();
updateRunActions(); emit updateRunActions();
} }
void ProjectExplorerPlugin::activeTargetChanged() void ProjectExplorerPlugin::activeTargetChanged()
...@@ -1857,14 +1836,14 @@ void ProjectExplorerPlugin::activeRunConfigurationChanged() ...@@ -1857,14 +1836,14 @@ void ProjectExplorerPlugin::activeRunConfigurationChanged()
return; return;
if (previousRunConfiguration) { if (previousRunConfiguration) {
disconnect(previousRunConfiguration, SIGNAL(isEnabledChanged(bool)), disconnect(previousRunConfiguration, SIGNAL(isEnabledChanged(bool)),
this, SLOT(updateRunActions())); this, SIGNAL(updateRunActions()));
} }
previousRunConfiguration = rc; previousRunConfiguration = rc;
if (rc) { if (rc) {
connect(rc, SIGNAL(isEnabledChanged(bool)), connect(rc, SIGNAL(isEnabledChanged(bool)),
this, SLOT(updateRunActions())); this, SIGNAL(updateRunActions()));
} }
updateRunActions(); emit updateRunActions();
} }
// NBS TODO implement more than one runner // NBS TODO implement more than one runner
...@@ -1904,43 +1883,28 @@ void ProjectExplorerPlugin::updateDeployActions() ...@@ -1904,43 +1883,28 @@ void ProjectExplorerPlugin::updateDeployActions()
d->m_deploySessionAction->setEnabled(hasProjects && !building); d->m_deploySessionAction->setEnabled(hasProjects && !building);
updateRunActions(); emit updateRunActions();
} }
void ProjectExplorerPlugin::updateRunActions() bool ProjectExplorerPlugin::canRun(Project *project, const QString &runMode)
{ {
const Project *project = startupProject();
if (!project || if (!project ||
!project->activeTarget() || !project->activeTarget() ||
!project->activeTarget()->activeRunConfiguration()) { !project->activeTarget()->activeRunConfiguration()) {
return false;
d->m_runAction->setToolTip(tr("Cannot run without a project."));
d->m_debugAction->setToolTip(tr("Cannot debug without a project."));
d->m_runAction->setEnabled(false);
d->m_debugAction->setEnabled(false);
return;
} }
d->m_runAction->setToolTip(QString());
d->m_debugAction->setToolTip(QString());
RunConfiguration *activeRC = project->activeTarget()->activeRunConfiguration(); RunConfiguration *activeRC = project->activeTarget()->activeRunConfiguration();
bool canRun = findRunControlFactory(activeRC, ProjectExplorer::Constants::RUNMODE) bool canRun = findRunControlFactory(activeRC, runMode)
&& activeRC->isEnabled(); && activeRC->isEnabled();
const bool canDebug = findRunControlFactory(activeRC, ProjectExplorer::Constants::DEBUGMODE)
&& activeRC->isEnabled();
const bool building = d->m_buildManager->isBuilding(); const bool building = d->m_buildManager->isBuilding();
return (canRun && !building);
}
d->m_runAction->setEnabled(canRun && !building); void ProjectExplorerPlugin::slotUpdateRunActions()
{
canRun = session()->startupProject() && findRunControlFactory(activeRC, ProjectExplorer::Constants::RUNMODE); Project *project = startupProject();
d->m_runAction->setEnabled(canRun(project, ProjectExplorer::Constants::RUNMODE));
d->m_runActionContextMenu->setEnabled(canRun && !building);
d->m_debugAction->setEnabled(canDebug && !building);
} }
void ProjectExplorerPlugin::cancelBuild() void ProjectExplorerPlugin::cancelBuild()
......