GUI: resolved issue #86 (context menu in memory map)

This commit is contained in:
Mr. eXoDia 2014-06-25 21:02:00 +02:00
parent cab27a38d5
commit 97abb21408
6 changed files with 45 additions and 3 deletions

View File

@ -81,7 +81,7 @@ void SearchListView::listKeyPressed(QKeyEvent* event)
}
mSearchBox->setText(newText);
}
else if((event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) && event->modifiers()==Qt::NoModifier) //user pressed enter
else if((event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter)) //user pressed enter
emit enterPressedSignal();
}

View File

@ -50,6 +50,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
// Memory Map View
mMemMapView = new MemoryMapView();
connect(mMemMapView, SIGNAL(showCpu()), this, SLOT(displayCpuWidget()));
mMemMapView->setWindowTitle("Memory Map");
mMemMapView->setWindowIcon(QIcon(":/icons/images/memory-map.png"));
mMemMapView->hide();

View File

@ -21,8 +21,27 @@ MemoryMapView::MemoryMapView(StdTable *parent) : StdTable(parent)
setupContextMenu();
}
void MemoryMapView::keyPressEvent(QKeyEvent* event)
{
int key = event->key();
if(key == Qt::Key_Enter || key == Qt::Key_Return)
followDisassemblerSlot();
else
StdTable::keyPressEvent(event);
}
void MemoryMapView::setupContextMenu()
{
//Follow in Dump
mFollowDump = new QAction("&Follow in Dump", this);
connect(mFollowDump, SIGNAL(triggered()), this, SLOT(followDumpSlot()));
//Follow in Disassembler
mFollowDisassembly = new QAction("Follow in &Disassembler", this);
mFollowDisassembly->setShortcutContext(Qt::WidgetShortcut);
mFollowDisassembly->setShortcut(QKeySequence("enter"));
connect(mFollowDisassembly, SIGNAL(triggered()), this, SLOT(followDisassemblerSlot()));
//Breakpoint menu
mBreakpointMenu = new QMenu("Memory &Breakpoint", this);
@ -78,6 +97,9 @@ void MemoryMapView::contextMenuSlot(const QPoint &pos)
if(!DbgIsDebugging())
return;
QMenu* wMenu = new QMenu(this); //create context menu
wMenu->addAction(mFollowDisassembly);
wMenu->addAction(mFollowDump);
wMenu->addSeparator();
wMenu->addMenu(mBreakpointMenu);
QMenu wCopyMenu("&Copy", this);
setupCopyMenu(&wCopyMenu);
@ -173,7 +195,7 @@ QString MemoryMapView::paintContent(QPainter *painter, int_t rowBase, int rowOff
}
else if(col == 2) //info
{
QString wStr = getCellContent(rowBase + rowOffset, col);
QString wStr = StdTable::paintContent(painter, rowBase, rowOffset, col, x, y, w, h);;
if(wStr.startsWith(" \""))
{
painter->setPen(ConfigColor("MemoryMapSectionTextColor"));
@ -262,7 +284,20 @@ void MemoryMapView::stateChangedSlot(DBGSTATE state)
BridgeFree(wMemMapStruct.page);
reloadData(); //refresh memory map
}
}
void MemoryMapView::followDumpSlot()
{
QString addr_text = getCellContent(getInitialSelection(), 0);
DbgCmdExecDirect(QString("dump "+addr_text).toUtf8().constData());
emit showCpu();
}
void MemoryMapView::followDisassemblerSlot()
{
QString addr_text = getCellContent(getInitialSelection(), 0);
DbgCmdExecDirect(QString("disasm "+addr_text).toUtf8().constData());
emit showCpu();
}
void MemoryMapView::memoryAccessSingleshootSlot()

View File

@ -11,12 +11,16 @@ class MemoryMapView : public StdTable
public:
explicit MemoryMapView(StdTable *parent = 0);
QString paintContent(QPainter *painter, int_t rowBase, int rowOffset, int col, int x, int y, int w, int h);
void keyPressEvent(QKeyEvent* event);
void setupContextMenu();
signals:
void showCpu();
public slots:
void stateChangedSlot(DBGSTATE state);
void followDumpSlot();
void followDisassemblerSlot();
void memoryAccessSingleshootSlot();
void memoryAccessRestoreSlot();
void memoryWriteSingleshootSlot();

View File

@ -20,7 +20,7 @@ RegistersView::RegistersView(QWidget * parent) : QAbstractScrollArea(parent), mV
wCM_ToggleValue->setShortcut(Qt::Key_Space);
wCM_CopyToClipboard = new QAction(tr("Copy Value to Clipboard"),this);
wCM_CopyToClipboard->setShortcut(QKeySequence::Copy);
wCM_FollowInDisassembly = new QAction(tr("Follow in Diassembly"),this);
wCM_FollowInDisassembly = new QAction(tr("Follow in Disassembler"),this);
wCM_FollowInDump = new QAction(tr("Follow in Dump"),this);

View File

@ -83,6 +83,8 @@ SymbolView::~SymbolView()
void SymbolView::setupContextMenu()
{
mFollowSymbolAction = new QAction("&Follow in Disassembler", this);
mFollowSymbolAction->setShortcutContext(Qt::WidgetShortcut);
mFollowSymbolAction->setShortcut(QKeySequence("enter"));
connect(mFollowSymbolAction, SIGNAL(triggered()), this, SLOT(symbolFollow()));
mFollowSymbolDumpAction = new QAction("Follow in &Dump", this);