debugger: re-organize actions

Task-number: QTCREATORBUG-5660
Change-Id: I25516dc5cab8035e3d1be7025435f1a762d1ee3c
Reviewed-on: http://codereview.qt.nokia.com/2585
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2011-08-03 18:57:37 +02:00
committed by hjk
parent 79d604667b
commit a4f23dc545
3 changed files with 57 additions and 46 deletions

View File

@@ -54,6 +54,7 @@ const char DEBUGMODE2[] = "Debugger.DebugMode2"; // Breaks on main.
const char INTERRUPT[] = "Debugger.Interrupt"; const char INTERRUPT[] = "Debugger.Interrupt";
const char CONTINUE[] = "Debugger.Continue"; const char CONTINUE[] = "Debugger.Continue";
const char STOP[] = "Debugger.Stop"; const char STOP[] = "Debugger.Stop";
const char HIDDEN_STOP[] = "Debugger.HiddenStop";
const char RESET[] = "Debugger.Reset"; const char RESET[] = "Debugger.Reset";
const char STEP[] = "Debugger.StepLine"; const char STEP[] = "Debugger.StepLine";
const char STEPOUT[] = "Debugger.StepOut"; const char STEPOUT[] = "Debugger.StepOut";

View File

@@ -1427,9 +1427,9 @@ void DebuggerEngine::detachDebugger()
void DebuggerEngine::exitDebugger() void DebuggerEngine::exitDebugger()
{ {
QTC_ASSERT(d->m_state == InferiorStopOk || d->m_state == InferiorUnrunnable, QTC_ASSERT(d->m_state == InferiorStopOk || d->m_state == InferiorUnrunnable
qDebug() << d->m_state); || d->m_state == InferiorRunOk, qDebug() << d->m_state);
d->queueShutdownInferior(); quitDebugger();
} }
void DebuggerEngine::executeStep() void DebuggerEngine::executeStep()

View File

@@ -1029,8 +1029,9 @@ public:
QString m_previousMode; QString m_previousMode;
QList<DebuggerStartParameters> m_scheduledStarts; QList<DebuggerStartParameters> m_scheduledStarts;
Utils::ProxyAction *m_visibleDebugAction; Utils::ProxyAction *m_visibleStartAction;
QAction *m_debugAction; Utils::ProxyAction *m_hiddenStopAction;
QAction *m_startAction;
QAction *m_startExternalAction; QAction *m_startExternalAction;
QAction *m_startRemoteAction; QAction *m_startRemoteAction;
QAction *m_startRemoteCdbAction; QAction *m_startRemoteCdbAction;
@@ -1146,7 +1147,7 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) :
m_cmdLineEnabledEngines = AllEngineTypes; m_cmdLineEnabledEngines = AllEngineTypes;
m_reverseToolButton = 0; m_reverseToolButton = 0;
m_debugAction = 0; m_startAction = 0;
m_startExternalAction = 0; m_startExternalAction = 0;
m_startRemoteAction = 0; m_startRemoteAction = 0;
m_startRemoteCdbAction = 0; m_startRemoteCdbAction = 0;
@@ -1365,13 +1366,11 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
} }
} }
// No corresponding debugger found. So we are ready to start one. // No corresponding debugger found. So we are ready to start one.
ICore *core = ICore::instance();
ActionManager *am = core->actionManager();
m_interruptAction->setEnabled(false); m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false); m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false); m_exitAction->setEnabled(false);
m_debugAction->setEnabled(true); m_startAction->setEnabled(true);
m_visibleDebugAction->setAction(am->command(Constants::DEBUG)->action()); m_visibleStartAction->setAction(m_startAction);
} }
void DebuggerPluginPrivate::languagesChanged() void DebuggerPluginPrivate::languagesChanged()
@@ -2043,37 +2042,39 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
bool actionsEnabled = DebuggerEngine::debuggerActionsEnabled(state); bool actionsEnabled = DebuggerEngine::debuggerActionsEnabled(state);
ICore *core = ICore::instance();
ActionManager *am = core->actionManager();
if (state == DebuggerNotReady) { if (state == DebuggerNotReady) {
QTC_ASSERT(false, /* We use the Core m_debugAction here */); QTC_ASSERT(false, /* We use the Core's m_debugAction here */);
// F5 starts debugging. It is "startable". // F5 starts debugging. It is "startable".
m_interruptAction->setEnabled(false); m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false); m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false); m_exitAction->setEnabled(false);
m_debugAction->setEnabled(true); m_startAction->setEnabled(true);
m_visibleDebugAction->setAction(am->command(Constants::DEBUG)->action()); m_visibleStartAction->setAction(m_startAction);
m_hiddenStopAction->setAction(m_undisturbableAction);
} else if (state == InferiorStopOk) { } else if (state == InferiorStopOk) {
// F5 continues, Shift-F5 kills. It is "continuable". // F5 continues, Shift-F5 kills. It is "continuable".
m_interruptAction->setEnabled(false); m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(true); m_continueAction->setEnabled(true);
m_exitAction->setEnabled(true); m_exitAction->setEnabled(true);
m_debugAction->setEnabled(false); m_startAction->setEnabled(false);
m_visibleDebugAction->setAction(am->command(Constants::CONTINUE)->action()); m_visibleStartAction->setAction(m_continueAction);
m_hiddenStopAction->setAction(m_exitAction);
} else if (state == InferiorRunOk) { } else if (state == InferiorRunOk) {
// Shift-F5 interrupts. It is also "interruptible". // Shift-F5 interrupts. It is also "interruptible".
m_interruptAction->setEnabled(true); m_interruptAction->setEnabled(true);
m_continueAction->setEnabled(false); m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false); m_exitAction->setEnabled(true);
m_debugAction->setEnabled(false); m_startAction->setEnabled(false);
m_visibleDebugAction->setAction(am->command(Constants::INTERRUPT)->action()); m_visibleStartAction->setAction(m_interruptAction);
m_hiddenStopAction->setAction(m_interruptAction);
} else if (state == DebuggerFinished) { } else if (state == DebuggerFinished) {
// We don't want to do anything anymore. // We don't want to do anything anymore.
m_interruptAction->setEnabled(false); m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false); m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false); m_exitAction->setEnabled(false);
m_debugAction->setEnabled(true); m_startAction->setEnabled(true);
m_visibleDebugAction->setAction(am->command(Constants::DEBUG)->action()); m_visibleStartAction->setAction(m_startAction);
m_hiddenStopAction->setAction(m_undisturbableAction);
m_codeModelSnapshot = CPlusPlus::Snapshot(); m_codeModelSnapshot = CPlusPlus::Snapshot();
setBusyCursor(false); setBusyCursor(false);
cleanupViews(); cleanupViews();
@@ -2082,15 +2083,17 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_interruptAction->setEnabled(false); m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false); m_continueAction->setEnabled(false);
m_exitAction->setEnabled(true); m_exitAction->setEnabled(true);
m_debugAction->setEnabled(false); m_startAction->setEnabled(false);
m_visibleDebugAction->setAction(am->command(Constants::DEBUG)->action()); m_visibleStartAction->setAction(m_startAction);
m_hiddenStopAction->setAction(m_undisturbableAction);
} else { } else {
// Everything else is "undisturbable". // Everything else is "undisturbable".
m_interruptAction->setEnabled(false); m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false); m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false); m_exitAction->setEnabled(false);
m_debugAction->setEnabled(false); m_startAction->setEnabled(false);
m_visibleDebugAction->setAction(m_undisturbableAction); m_visibleStartAction->setAction(m_undisturbableAction);
m_hiddenStopAction->setAction(m_undisturbableAction);
} }
m_startExternalAction->setEnabled(true); m_startExternalAction->setEnabled(true);
@@ -2156,8 +2159,8 @@ void DebuggerPluginPrivate::updateDebugActions()
Project *project = pe->startupProject(); Project *project = pe->startupProject();
const QString debugMode = _(Constants::DEBUGMODE); const QString debugMode = _(Constants::DEBUGMODE);
const bool canRun = pe->canRun(project, debugMode); const bool canRun = pe->canRun(project, debugMode);
m_debugAction->setEnabled(canRun); m_startAction->setEnabled(canRun);
m_debugAction->setToolTip(canRun ? QString() : pe->cannotRunReason(project, debugMode)); m_startAction->setToolTip(canRun ? QString() : pe->cannotRunReason(project, debugMode));
// Step into/next: Start and break at 'main' unless a debugger is running. // Step into/next: Start and break at 'main' unless a debugger is running.
if (m_snapshotHandler->currentIndex() < 0) { if (m_snapshotHandler->currentIndex() < 0) {
@@ -2811,7 +2814,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
m_plugin->addAutoReleasedObject(m_debuggerRunControlFactory); m_plugin->addAutoReleasedObject(m_debuggerRunControlFactory);
// The main "Start Debugging" action. // The main "Start Debugging" action.
act = m_debugAction = new QAction(this); act = m_startAction = new QAction(this);
QIcon debuggerIcon(":/projectexplorer/images/debugger_start_small.png"); QIcon debuggerIcon(":/projectexplorer/images/debugger_start_small.png");
debuggerIcon.addFile(":/projectexplorer/images/debugger_start.png"); debuggerIcon.addFile(":/projectexplorer/images/debugger_start.png");
act->setIcon(debuggerIcon); act->setIcon(debuggerIcon);
@@ -2854,20 +2857,20 @@ void DebuggerPluginPrivate::extensionsInitialized()
Command *cmd = 0; Command *cmd = 0;
ActionContainer *mstart = am->actionContainer(PE::M_DEBUG_STARTDEBUGGING); ActionContainer *mstart = am->actionContainer(PE::M_DEBUG_STARTDEBUGGING);
cmd = am->registerAction(m_debugAction, Constants::DEBUG, globalcontext); cmd = am->registerAction(m_startAction, Constants::DEBUG, globalcontext);
cmd->setDefaultText(tr("Start Debugging")); cmd->setDefaultText(tr("Start Debugging"));
cmd->setDefaultKeySequence(QKeySequence(Constants::DEBUG_KEY)); cmd->setDefaultKeySequence(QKeySequence(Constants::DEBUG_KEY));
cmd->setAttribute(Command::CA_UpdateText); cmd->setAttribute(Command::CA_UpdateText);
mstart->addAction(cmd, Core::Constants::G_DEFAULT_ONE); mstart->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
m_visibleDebugAction = new Utils::ProxyAction(this); m_visibleStartAction = new Utils::ProxyAction(this);
m_visibleDebugAction->initialize(m_debugAction); m_visibleStartAction->initialize(m_startAction);
m_visibleDebugAction->setAttribute(Utils::ProxyAction::UpdateText); m_visibleStartAction->setAttribute(Utils::ProxyAction::UpdateText);
m_visibleDebugAction->setAttribute(Utils::ProxyAction::UpdateIcon); m_visibleStartAction->setAttribute(Utils::ProxyAction::UpdateIcon);
m_visibleDebugAction->setAction(cmd->action()); m_visibleStartAction->setAction(cmd->action());
ModeManager *modeManager = ModeManager::instance(); ModeManager *modeManager = ModeManager::instance();
modeManager->addAction(m_visibleDebugAction, Constants::P_ACTION_DEBUG); modeManager->addAction(m_visibleStartAction, Constants::P_ACTION_DEBUG);
cmd = am->registerAction(m_startExternalAction, cmd = am->registerAction(m_startExternalAction,
Constants::STARTEXTERNAL, globalcontext); Constants::STARTEXTERNAL, globalcontext);
@@ -2912,7 +2915,6 @@ void DebuggerPluginPrivate::extensionsInitialized()
cmd = am->registerAction(m_interruptAction, cmd = am->registerAction(m_interruptAction,
Constants::INTERRUPT, globalcontext); Constants::INTERRUPT, globalcontext);
cmd->setDefaultText(tr("Interrupt Debugger")); cmd->setDefaultText(tr("Interrupt Debugger"));
cmd->setDefaultKeySequence(QKeySequence(Constants::STOP_KEY));
debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE);
cmd = am->registerAction(m_continueAction, cmd = am->registerAction(m_continueAction,
@@ -2922,10 +2924,18 @@ void DebuggerPluginPrivate::extensionsInitialized()
cmd = am->registerAction(m_exitAction, cmd = am->registerAction(m_exitAction,
Constants::STOP, globalcontext); Constants::STOP, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::STOP_KEY));
cmd->setDefaultText(tr("Stop Debugger")); cmd->setDefaultText(tr("Stop Debugger"));
debugMenu->addAction(cmd, CC::G_DEFAULT_ONE); debugMenu->addAction(cmd, CC::G_DEFAULT_ONE);
m_hiddenStopAction = new Utils::ProxyAction(this);
m_hiddenStopAction->initialize(m_exitAction);
m_hiddenStopAction->setAttribute(Utils::ProxyAction::UpdateText);
m_hiddenStopAction->setAttribute(Utils::ProxyAction::UpdateIcon);
cmd = am->registerAction(m_hiddenStopAction,
Constants::HIDDEN_STOP, globalcontext);
cmd->setDefaultKeySequence(QKeySequence(Constants::STOP_KEY));
cmd = am->registerAction(m_resetAction, cmd = am->registerAction(m_resetAction,
Constants::RESET, globalcontext); Constants::RESET, globalcontext);
//cmd->setDefaultKeySequence(QKeySequence(Constants::RESET_KEY)); //cmd->setDefaultKeySequence(QKeySequence(Constants::RESET_KEY));
@@ -3113,15 +3123,15 @@ void DebuggerPluginPrivate::extensionsInitialized()
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(m_visibleDebugAction)); hbox->addWidget(toolButton(m_visibleStartAction));
hbox->addWidget(toolButton(am->command(STOP)->action())); hbox->addWidget(toolButton(m_exitAction));
hbox->addWidget(toolButton(am->command(NEXT)->action())); hbox->addWidget(toolButton(m_nextAction));
hbox->addWidget(toolButton(am->command(STEP)->action())); hbox->addWidget(toolButton(m_stepAction));
hbox->addWidget(toolButton(am->command(STEPOUT)->action())); hbox->addWidget(toolButton(m_stepOutAction));
hbox->addWidget(toolButton(am->command(OPERATE_BY_INSTRUCTION)->action())); hbox->addWidget(toolButton(action(OperateByInstruction)));
//hbox->addWidget(new Utils::StyledSeparator); //hbox->addWidget(new Utils::StyledSeparator);
m_reverseToolButton = toolButton(am->command(REVERSE)->action()); m_reverseToolButton = toolButton(m_reverseDirectionAction);
hbox->addWidget(m_reverseToolButton); hbox->addWidget(m_reverseToolButton);
//m_reverseToolButton->hide(); //m_reverseToolButton->hide();
@@ -3285,7 +3295,7 @@ DebuggerMainWindow *DebuggerPlugin::mainWindow()
QAction *DebuggerPlugin::visibleDebugAction() QAction *DebuggerPlugin::visibleDebugAction()
{ {
return theDebuggerCore->m_visibleDebugAction; return theDebuggerCore->m_visibleStartAction;
} }
} // namespace Debugger } // namespace Debugger