From 58f987cd071bf0487236c264b397e0acf51c2949 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 10 Oct 2011 13:38:58 +0200 Subject: [PATCH] Debugger: Always show "Start Debugging" methods Don't rely on the 'current' project settings for actions like Attach to QML port. Also, group the actions in a General, Cpp and QML part, and add separators in between. Change-Id: I3103a6fc777180a69eee128d39d19de17f312ff3 Reviewed-on: http://codereview.qt-project.org/6323 Sanity-Review: Qt Sanity Bot Reviewed-by: hjk --- src/plugins/debugger/debuggerconstants.h | 4 ++ src/plugins/debugger/debuggerplugin.cpp | 67 +++++++++++++++++---------- src/plugins/remotelinux/remotelinuxplugin.cpp | 4 +- 3 files changed, 49 insertions(+), 26 deletions(-) diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index fa179279ea..a3cdc77500 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -46,6 +46,10 @@ const char C_DEBUGMODE[] = "Debugger.DebugMode"; const char C_CPPDEBUGGER[] = "Gdb Debugger"; const char C_QMLDEBUGGER[] = "Qml/JavaScript Debugger"; +// Menu Groups +const char G_START_CPP[] = "Debugger.Group.Start.Cpp"; +const char G_START_QML[] = "Debugger.Group.Start.Cpp"; + // Project Explorer run mode (RUN/DEBUG) const char DEBUGMODE[] = "Debugger.DebugMode"; const char DEBUGMODE2[] = "Debugger.DebugMode2"; // Breaks on main. diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index d810ee3104..bb06bb951b 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1400,16 +1400,6 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project) void DebuggerPluginPrivate::languagesChanged() { - const bool debuggerIsCPP = - m_mainWindow->activeDebugLanguages() & CppLanguage; - //qDebug() << "DEBUGGER IS CPP: " << debuggerIsCPP; - m_startExternalAction->setVisible(debuggerIsCPP); - m_attachExternalAction->setVisible(debuggerIsCPP); - m_attachCoreAction->setVisible(debuggerIsCPP); - m_startRemoteAction->setVisible(debuggerIsCPP); - m_attachRemoteAction->setVisible(debuggerIsCPP); - m_detachAction->setVisible(debuggerIsCPP); - m_attachToQmlPortAction->setVisible(m_mainWindow->activeDebugLanguages() & QmlLanguage); } void DebuggerPluginPrivate::debugProject() @@ -2962,6 +2952,12 @@ void DebuggerPluginPrivate::extensionsInitialized() act->setText(tr("Detach Debugger")); connect(act, SIGNAL(triggered()), SLOT(handleExecDetach())); + // "Start Debugging" sub-menu + // groups: + // G_DEFAULT_ONE + // G_START_CPP + // G_START_QML + Command *cmd = 0; ActionContainer *mstart = am->actionContainer(PE::M_DEBUG_STARTDEBUGGING); @@ -2969,7 +2965,7 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd->setDefaultText(tr("Start Debugging")); cmd->setDefaultKeySequence(QKeySequence(Constants::DEBUG_KEY)); cmd->setAttribute(Command::CA_UpdateText); - mstart->addAction(cmd, Core::Constants::G_DEFAULT_ONE); + mstart->addAction(cmd, CC::G_DEFAULT_ONE); m_visibleStartAction = new Utils::ProxyAction(this); m_visibleStartAction->initialize(m_startAction); @@ -2983,52 +2979,54 @@ void DebuggerPluginPrivate::extensionsInitialized() cmd = am->registerAction(m_startExternalAction, "Debugger.StartExternal", globalcontext); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, CC::G_DEFAULT_ONE); + mstart->addAction(cmd, Constants::G_START_CPP); cmd = am->registerAction(m_attachExternalAction, "Debugger.AttachExternal", globalcontext); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, CC::G_DEFAULT_ONE); + mstart->addAction(cmd, Constants::G_START_CPP); cmd = am->registerAction(m_attachCoreAction, "Debugger.AttachCore", globalcontext); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, CC::G_DEFAULT_ONE); + mstart->addAction(cmd, Constants::G_START_CPP); cmd = am->registerAction(m_startRemoteAction, "Debugger.StartRemote", globalcontext); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, CC::G_DEFAULT_ONE); + mstart->addAction(cmd, Constants::G_START_CPP); cmd = am->registerAction(m_attachRemoteAction, "Debugger.AttachRemote", globalcontext); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, CC::G_DEFAULT_ONE); + mstart->addAction(cmd, Constants::G_START_CPP); - cmd = am->registerAction(m_attachToQmlPortAction, - "Debugger.AttachToQmlPort", globalcontext); - cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, CC::G_DEFAULT_ONE); #ifdef WITH_LLDB cmd = am->registerAction(m_startRemoteLldbAction, "Debugger.RemoteLldb", globalcontext); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, CC::G_DEFAULT_ONE); + mstart->addAction(cmd, Constants::G_START_CPP); #endif if (m_startRemoteCdbAction) { cmd = am->registerAction(m_startRemoteCdbAction, "Debugger.AttachRemoteCdb", globalcontext); cmd->setAttribute(Command::CA_Hide); - mstart->addAction(cmd, CC::G_DEFAULT_ONE); + mstart->addAction(cmd, Constants::G_START_CPP); } - QAction *sep = new QAction(this); + QAction *sep = new QAction(mstart); sep->setSeparator(true); - cmd = am->registerAction(sep, "Debugger.Sep.Start", globalcontext); - mstart->addAction(cmd); + cmd = am->registerAction(sep, + "Debugger.Start.Qml", globalcontext); + mstart->addAction(cmd, Constants::G_START_QML); + + cmd = am->registerAction(m_attachToQmlPortAction, + "Debugger.AttachToQmlPort", globalcontext); + cmd->setAttribute(Command::CA_Hide); + mstart->addAction(cmd, Constants::G_START_QML); cmd = am->registerAction(m_detachAction, "Debugger.Detach", globalcontext); @@ -3378,6 +3376,25 @@ DebuggerPlugin::~DebuggerPlugin() bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMessage) { + ICore *core = ICore::instance(); + QTC_ASSERT(core, return true); + + // Menu groups + const Context globalcontext(CC::C_GLOBAL); + + Core::ActionManager *am = core->actionManager(); + ActionContainer *mstart = am->actionContainer(PE::M_DEBUG_STARTDEBUGGING); + + mstart->appendGroup(Constants::G_START_CPP); + mstart->appendGroup(Constants::G_START_QML); + + // add cpp separator + QAction *sep = new QAction(mstart); + sep->setSeparator(true); + Command *cmd = am->registerAction(sep, + "Debugger.Start.Cpp", globalcontext); + mstart->addAction(cmd, Constants::G_START_CPP); + return theDebuggerCore->initialize(arguments, errorMessage); } diff --git a/src/plugins/remotelinux/remotelinuxplugin.cpp b/src/plugins/remotelinux/remotelinuxplugin.cpp index aa47157a60..a540372627 100644 --- a/src/plugins/remotelinux/remotelinuxplugin.cpp +++ b/src/plugins/remotelinux/remotelinuxplugin.cpp @@ -48,6 +48,8 @@ #include #include +#include + #include #include @@ -92,7 +94,7 @@ void RemoteLinuxPlugin::extensionsInitialized() QAction *startGdbServerAction = new QAction(tr("Start Remote Debug Server"), 0); Command *cmd = am->registerAction(startGdbServerAction, "StartGdbServer", globalcontext); cmd->setDefaultText(tr("Start Gdbserver")); - mstart->addAction(cmd, Constants::G_DEFAULT_TWO); + mstart->addAction(cmd, Debugger::Constants::G_START_CPP); connect(startGdbServerAction, SIGNAL(triggered()), SLOT(startGdbServer())); } -- 2.11.0