Commit 94b1b1fd authored by hjk's avatar hjk

debugger: move 'break by function' menu items

Move menu to from the main debug window to the context menu of the
breakpoints view to avoid clutter in the main menus.
parent ea74cfd8
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "debuggeractions.h" #include "debuggeractions.h"
#include "ui_breakcondition.h" #include "ui_breakcondition.h"
#include "ui_breakbyfunction.h"
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QDir> #include <QtCore/QDir>
...@@ -48,6 +49,32 @@ ...@@ -48,6 +49,32 @@
using Debugger::Internal::BreakWindow; using Debugger::Internal::BreakWindow;
///////////////////////////////////////////////////////////////////////
//
// BreakByFunctionDialog
//
///////////////////////////////////////////////////////////////////////
class BreakByFunctionDialog : public QDialog, Ui::BreakByFunctionDialog
{
public:
explicit BreakByFunctionDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
QString functionName() const { return functionLineEdit->text(); }
};
///////////////////////////////////////////////////////////////////////
//
// BreakWindow
//
///////////////////////////////////////////////////////////////////////
BreakWindow::BreakWindow(QWidget *parent) BreakWindow::BreakWindow(QWidget *parent)
: QTreeView(parent), m_alwaysResizeColumnsToContents(false) : QTreeView(parent), m_alwaysResizeColumnsToContents(false)
{ {
...@@ -96,8 +123,14 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev) ...@@ -96,8 +123,14 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
QString str = enabled ? tr("Disable breakpoint") : tr("Enable breakpoint"); QString str = enabled ? tr("Disable breakpoint") : tr("Enable breakpoint");
QAction *act5 = new QAction(str, &menu); QAction *act5 = new QAction(str, &menu);
bool fullpath = indexIsValid && model()->data(index2, Qt::UserRole).toBool(); bool fullpath = indexIsValid && model()->data(index2, Qt::UserRole).toBool();
QString str1 = fullpath ? tr("Use short path") : tr("Use full path"); QString str6 = fullpath ? tr("Use short path") : tr("Use full path");
QAction *act6 = new QAction(str1, &menu); QAction *act6 = new QAction(str6, &menu);
QAction *act7 = new QAction(this);
act7->setText(tr("Set Breakpoint at Function..."));
QAction *act8 = new QAction(this);
act8->setText(tr("Set Breakpoint at Function \"main\""));
menu.addAction(act0); menu.addAction(act0);
menu.addAction(act3); menu.addAction(act3);
...@@ -108,6 +141,9 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev) ...@@ -108,6 +141,9 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
menu.addAction(act2); menu.addAction(act2);
menu.addAction(act4); menu.addAction(act4);
menu.addSeparator(); menu.addSeparator();
menu.addAction(act7);
menu.addAction(act8);
menu.addSeparator();
menu.addAction(theDebuggerAction(SettingsDialog)); menu.addAction(theDebuggerAction(SettingsDialog));
QAction *act = menu.exec(ev->globalPos()); QAction *act = menu.exec(ev->globalPos());
...@@ -128,6 +164,16 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev) ...@@ -128,6 +164,16 @@ void BreakWindow::contextMenuEvent(QContextMenuEvent *ev)
} else if (act == act6) { } else if (act == act6) {
model()->setData(index2, !fullpath); model()->setData(index2, !fullpath);
emit breakpointSynchronizationRequested(); emit breakpointSynchronizationRequested();
} else if (act == act7) {
BreakByFunctionDialog dlg(this);
if (dlg.exec())
emit breakByFunctionRequested(dlg.functionName());
} else if (act == act8) {
#ifdef Q_OS_WIN
emit breakByFunctionRequested("qMain");
#else
emit breakByFunctionRequested("main");
#endif
} }
} }
......
...@@ -50,6 +50,7 @@ signals: ...@@ -50,6 +50,7 @@ signals:
void breakpointDeleted(int index); void breakpointDeleted(int index);
void breakpointActivated(int index); void breakpointActivated(int index);
void breakpointSynchronizationRequested(); void breakpointSynchronizationRequested();
void breakByFunctionRequested(const QString &functionName);
private slots: private slots:
void rowActivated(const QModelIndex &index); void rowActivated(const QModelIndex &index);
......
...@@ -44,8 +44,6 @@ ...@@ -44,8 +44,6 @@
#include "threadswindow.h" #include "threadswindow.h"
#include "watchwindow.h" #include "watchwindow.h"
#include "ui_breakbyfunction.h"
#include "disassemblerhandler.h" #include "disassemblerhandler.h"
#include "breakhandler.h" #include "breakhandler.h"
#include "moduleshandler.h" #include "moduleshandler.h"
...@@ -128,27 +126,6 @@ static const char *stateName(int s) ...@@ -128,27 +126,6 @@ static const char *stateName(int s)
return "<unknown>"; return "<unknown>";
} }
///////////////////////////////////////////////////////////////////////
//
// BreakByFunctionDialog
//
///////////////////////////////////////////////////////////////////////
class BreakByFunctionDialog : public QDialog, Ui::BreakByFunctionDialog
{
Q_OBJECT
public:
explicit BreakByFunctionDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
QString functionName() const { return functionLineEdit->text(); }
};
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
// //
...@@ -300,6 +277,8 @@ void DebuggerManager::init() ...@@ -300,6 +277,8 @@ void DebuggerManager::init()
this, SIGNAL(sessionValueRequested(QString,QVariant*))); this, SIGNAL(sessionValueRequested(QString,QVariant*)));
connect(m_breakHandler, SIGNAL(setSessionValueRequested(QString,QVariant)), connect(m_breakHandler, SIGNAL(setSessionValueRequested(QString,QVariant)),
this, SIGNAL(setSessionValueRequested(QString,QVariant))); this, SIGNAL(setSessionValueRequested(QString,QVariant)));
connect(breakView, SIGNAL(breakByFunctionRequested(QString)),
this, SLOT(breakByFunction(QString)), Qt::QueuedConnection);
// Modules // Modules
QAbstractItemView *modulesView = QAbstractItemView *modulesView =
...@@ -403,12 +382,6 @@ void DebuggerManager::init() ...@@ -403,12 +382,6 @@ void DebuggerManager::init()
m_breakAction = new QAction(this); m_breakAction = new QAction(this);
m_breakAction->setText(tr("Toggle Breakpoint")); m_breakAction->setText(tr("Toggle Breakpoint"));
m_breakByFunctionAction = new QAction(this);
m_breakByFunctionAction->setText(tr("Set Breakpoint at Function..."));
m_breakAtMainAction = new QAction(this);
m_breakAtMainAction->setText(tr("Set Breakpoint at Function \"main\""));
m_watchAction = new QAction(this); m_watchAction = new QAction(this);
m_watchAction->setText(tr("Add to Watch Window")); m_watchAction->setText(tr("Add to Watch Window"));
...@@ -446,10 +419,6 @@ void DebuggerManager::init() ...@@ -446,10 +419,6 @@ void DebuggerManager::init()
this, SLOT(addToWatchWindow())); this, SLOT(addToWatchWindow()));
connect(m_breakAction, SIGNAL(triggered()), connect(m_breakAction, SIGNAL(triggered()),
this, SLOT(toggleBreakpoint())); this, SLOT(toggleBreakpoint()));
connect(m_breakByFunctionAction, SIGNAL(triggered()),
this, SLOT(breakByFunction()));
connect(m_breakAtMainAction, SIGNAL(triggered()),
this, SLOT(breakAtMain()));
connect(m_statusTimer, SIGNAL(timeout()), connect(m_statusTimer, SIGNAL(timeout()),
this, SLOT(clearStatusMessage())); this, SLOT(clearStatusMessage()));
...@@ -1144,22 +1113,6 @@ void DebuggerManager::breakByFunction(const QString &functionName) ...@@ -1144,22 +1113,6 @@ void DebuggerManager::breakByFunction(const QString &functionName)
attemptBreakpointSynchronization(); attemptBreakpointSynchronization();
} }
void DebuggerManager::breakByFunction()
{
BreakByFunctionDialog dlg(m_mainWindow);
if (dlg.exec())
breakByFunction(dlg.functionName());
}
void DebuggerManager::breakAtMain()
{
#ifdef Q_OS_WIN
breakByFunction("qMain");
#else
breakByFunction("main");
#endif
}
static bool isAllowedTransition(int from, int to) static bool isAllowedTransition(int from, int to)
{ {
return (from == -1) return (from == -1)
...@@ -1531,5 +1484,3 @@ void DebuggerManager::runTest(const QString &fileName) ...@@ -1531,5 +1484,3 @@ void DebuggerManager::runTest(const QString &fileName)
m_startParameters->workingDir.clear(); m_startParameters->workingDir.clear();
//startNewDebugger(StartInternal); //startNewDebugger(StartInternal);
} }
#include "debuggermanager.moc"
...@@ -277,10 +277,8 @@ public slots: ...@@ -277,10 +277,8 @@ public slots:
void runToLineExec(); void runToLineExec();
void runToFunctionExec(); void runToFunctionExec();
void toggleBreakpoint(); void toggleBreakpoint();
void breakByFunction();
void breakByFunction(const QString &functionName); void breakByFunction(const QString &functionName);
void setBreakpoint(const QString &fileName, int lineNumber); void setBreakpoint(const QString &fileName, int lineNumber);
void breakAtMain();
void activateFrame(int index); void activateFrame(int index);
void selectThread(int index); void selectThread(int index);
...@@ -460,8 +458,6 @@ private: ...@@ -460,8 +458,6 @@ private:
QAction *m_nextAction; QAction *m_nextAction;
QAction *m_watchAction; QAction *m_watchAction;
QAction *m_breakAction; QAction *m_breakAction;
QAction *m_breakByFunctionAction;
QAction *m_breakAtMainAction;
QAction *m_sepAction; QAction *m_sepAction;
QAction *m_stepIAction; QAction *m_stepIAction;
QAction *m_nextIAction; QAction *m_nextIAction;
......
...@@ -709,14 +709,6 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess ...@@ -709,14 +709,6 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
mdebug->addAction(cmd); mdebug->addAction(cmd);
//mcppcontext->addAction(cmd); //mcppcontext->addAction(cmd);
cmd = am->registerAction(m_manager->m_breakByFunctionAction,
Constants::BREAK_BY_FUNCTION, globalcontext);
mdebug->addAction(cmd);
cmd = am->registerAction(m_manager->m_breakAtMainAction,
Constants::BREAK_AT_MAIN, globalcontext);
mdebug->addAction(cmd);
sep = new QAction(this); sep = new QAction(this);
sep->setSeparator(true); sep->setSeparator(true);
cmd = am->registerAction(sep, QLatin1String("Debugger.Sep2"), globalcontext); cmd = am->registerAction(sep, QLatin1String("Debugger.Sep2"), globalcontext);
......
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