GUI: toggle overview option in graph
This commit is contained in:
parent
984670efc4
commit
e918b773e7
|
@ -22,6 +22,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget* parent)
|
|||
this->scroll_base_x = 0;
|
||||
this->scroll_base_y = 0;
|
||||
this->scroll_mode = false;
|
||||
this->drawOverview = false;
|
||||
this->blocks.clear();
|
||||
|
||||
//Create timer to automatically refresh view when it needs to be updated
|
||||
|
@ -282,8 +283,10 @@ void DisassemblerGraphView::paintEvent(QPaintEvent* event)
|
|||
if(!this->ready || !DbgIsDebugging())
|
||||
return;
|
||||
|
||||
//paintOverview(p, viewportRect, xofs, yofs);
|
||||
paintNormal(p, viewportRect, xofs, yofs);
|
||||
if(drawOverview)
|
||||
paintOverview(p, viewportRect, xofs, yofs);
|
||||
else
|
||||
paintNormal(p, viewportRect, xofs, yofs);
|
||||
}
|
||||
|
||||
bool DisassemblerGraphView::isMouseEventInBlock(QMouseEvent* event)
|
||||
|
@ -426,40 +429,58 @@ bool DisassemblerGraphView::find_instr(duint addr, Instr & instrOut)
|
|||
|
||||
void DisassemblerGraphView::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if(event->button() != Qt::LeftButton && event->button() != Qt::RightButton)
|
||||
return;
|
||||
|
||||
if(!this->isMouseEventInBlock(event))
|
||||
if(drawOverview)
|
||||
{
|
||||
//Click outside any block, enter scrolling mode
|
||||
if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
//TODO: overview scroll
|
||||
}
|
||||
else if(event->button() == Qt::RightButton)
|
||||
{
|
||||
QMenu wMenu(this);
|
||||
wMenu.addAction(mToggleOverviewAction);
|
||||
wMenu.exec(event->globalPos()); //execute context menu
|
||||
}
|
||||
}
|
||||
else if(this->isMouseEventInBlock(event))
|
||||
{
|
||||
//Check for click on a token and highlight it
|
||||
Token token;
|
||||
if(this->getTokenForMouseEvent(event, token))
|
||||
this->highlight_token = HighlightToken::fromToken(token);
|
||||
else
|
||||
this->highlight_token = nullptr;
|
||||
|
||||
//Update current instruction
|
||||
duint instr = this->getInstrForMouseEvent(event);
|
||||
if(instr != 0)
|
||||
this->cur_instr = instr;
|
||||
else
|
||||
this->cur_instr = 0;
|
||||
|
||||
this->viewport()->update();
|
||||
|
||||
if((instr != 0) && (event->button() == Qt::RightButton))
|
||||
{
|
||||
QMenu wMenu(this);
|
||||
mMenuBuilder->build(&wMenu);
|
||||
wMenu.exec(event->globalPos()); //execute context menu
|
||||
}
|
||||
}
|
||||
else if(event->button() == Qt::LeftButton)
|
||||
{
|
||||
//Left click outside any block, enter scrolling mode
|
||||
this->scroll_base_x = event->x();
|
||||
this->scroll_base_y = event->y();
|
||||
this->scroll_mode = true;
|
||||
this->setCursor(Qt::ClosedHandCursor);
|
||||
this->viewport()->grabMouse();
|
||||
return;
|
||||
}
|
||||
|
||||
//Check for click on a token and highlight it
|
||||
Token token;
|
||||
if(this->getTokenForMouseEvent(event, token))
|
||||
this->highlight_token = HighlightToken::fromToken(token);
|
||||
else
|
||||
this->highlight_token = nullptr;
|
||||
|
||||
//Update current instruction
|
||||
duint instr = this->getInstrForMouseEvent(event);
|
||||
if(instr != 0)
|
||||
this->cur_instr = instr;
|
||||
else
|
||||
this->cur_instr = 0;
|
||||
|
||||
this->viewport()->update();
|
||||
|
||||
if((instr != 0) && (event->button() == Qt::RightButton))
|
||||
else if(event->button() == Qt::RightButton)
|
||||
{
|
||||
//Right click outside of block
|
||||
QMenu wMenu(this);
|
||||
mMenuBuilder->build(&wMenu);
|
||||
wMenu.addAction(mToggleOverviewAction);
|
||||
wMenu.exec(event->globalPos()); //execute context menu
|
||||
}
|
||||
}
|
||||
|
@ -1249,6 +1270,10 @@ void DisassemblerGraphView::setupContextMenu()
|
|||
{
|
||||
return this->cur_instr != 0;
|
||||
});
|
||||
mMenuBuilder->addSeparator();
|
||||
|
||||
mToggleOverviewAction = makeShortcutAction(DIcon("graph.png"), tr("Toggle &Overview"), SLOT(toggleOverviewSlot()), "ActionGraphToggleOverview");
|
||||
mMenuBuilder->addAction(mToggleOverviewAction);
|
||||
}
|
||||
|
||||
void DisassemblerGraphView::followDisassemblerSlot()
|
||||
|
@ -1272,3 +1297,9 @@ void DisassemblerGraphView::shortcutsUpdatedSlot()
|
|||
for(const auto & actionShortcut : actionShortcutPairs)
|
||||
actionShortcut.action->setShortcut(ConfigShortcut(actionShortcut.shortcut));
|
||||
}
|
||||
|
||||
void DisassemblerGraphView::toggleOverviewSlot()
|
||||
{
|
||||
drawOverview = !drawOverview;
|
||||
this->viewport()->update();
|
||||
}
|
||||
|
|
|
@ -255,6 +255,7 @@ public slots:
|
|||
void colorsUpdatedSlot();
|
||||
void fontsUpdatedSlot();
|
||||
void shortcutsUpdatedSlot();
|
||||
void toggleOverviewSlot();
|
||||
|
||||
signals:
|
||||
void showCpu();
|
||||
|
@ -287,6 +288,8 @@ private:
|
|||
std::vector<int> row_edge_y;
|
||||
CachedFontMetrics* mFontMetrics;
|
||||
MenuBuilder* mMenuBuilder;
|
||||
bool drawOverview;
|
||||
QAction* mToggleOverviewAction;
|
||||
|
||||
protected:
|
||||
#include "ActionHelpers.h"
|
||||
|
|
|
@ -413,6 +413,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
|
|||
defaultShortcuts.insert("ActionExecuteCommandScript", Shortcut(tr("Actions -> Execute Script Command"), "X"));
|
||||
defaultShortcuts.insert("ActionRefresh", Shortcut(tr("Actions -> Refresh"), "F5"));
|
||||
defaultShortcuts.insert("ActionGraph", Shortcut(tr("Actions -> Graph"), "G"));
|
||||
defaultShortcuts.insert("ActionGraphToggleOverview", Shortcut(tr("Actions -> Graph -> Toggle overview"), "O"));
|
||||
|
||||
Shortcuts = defaultShortcuts;
|
||||
|
||||
|
|
Loading…
Reference in New Issue