mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-30 00:35:25 +00:00
Navigate through graph view with arrows (#1441)
This commit is contained in:
parent
4673a23f05
commit
059723b013
@ -91,12 +91,6 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
|
|||||||
QShortcut *shortcut_prev_instr = new QShortcut(QKeySequence(Qt::Key_K), this);
|
QShortcut *shortcut_prev_instr = new QShortcut(QKeySequence(Qt::Key_K), this);
|
||||||
shortcut_prev_instr->setContext(Qt::WidgetShortcut);
|
shortcut_prev_instr->setContext(Qt::WidgetShortcut);
|
||||||
connect(shortcut_prev_instr, SIGNAL(activated()), this, SLOT(prevInstr()));
|
connect(shortcut_prev_instr, SIGNAL(activated()), this, SLOT(prevInstr()));
|
||||||
QShortcut *shortcut_next_instr_arrow = new QShortcut(QKeySequence::MoveToNextLine, this);
|
|
||||||
shortcut_next_instr_arrow->setContext(Qt::WidgetShortcut);
|
|
||||||
connect(shortcut_next_instr_arrow, SIGNAL(activated()), this, SLOT(nextInstr()));
|
|
||||||
QShortcut *shortcut_prev_instr_arrow = new QShortcut(QKeySequence::MoveToPreviousLine, this);
|
|
||||||
shortcut_prev_instr_arrow->setContext(Qt::WidgetShortcut);
|
|
||||||
connect(shortcut_prev_instr_arrow, SIGNAL(activated()), this, SLOT(prevInstr()));
|
|
||||||
shortcuts.append(shortcut_disassembly);
|
shortcuts.append(shortcut_disassembly);
|
||||||
shortcuts.append(shortcut_escape);
|
shortcuts.append(shortcut_escape);
|
||||||
shortcuts.append(shortcut_zoom_in);
|
shortcuts.append(shortcut_zoom_in);
|
||||||
@ -104,8 +98,6 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
|
|||||||
shortcuts.append(shortcut_zoom_reset);
|
shortcuts.append(shortcut_zoom_reset);
|
||||||
shortcuts.append(shortcut_next_instr);
|
shortcuts.append(shortcut_next_instr);
|
||||||
shortcuts.append(shortcut_prev_instr);
|
shortcuts.append(shortcut_prev_instr);
|
||||||
shortcuts.append(shortcut_next_instr_arrow);
|
|
||||||
shortcuts.append(shortcut_prev_instr_arrow);
|
|
||||||
|
|
||||||
// Export Graph menu
|
// Export Graph menu
|
||||||
mMenu->addSeparator();
|
mMenu->addSeparator();
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QKeyEvent>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
@ -486,6 +487,33 @@ void GraphView::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GraphView::keyPressEvent(QKeyEvent* event)
|
||||||
|
{
|
||||||
|
const int delta = static_cast<int>(30.0 / current_scale);
|
||||||
|
int dx = 0, dy = 0;
|
||||||
|
switch (event->key()) {
|
||||||
|
case Qt::Key_Up:
|
||||||
|
dy = -delta;
|
||||||
|
break;
|
||||||
|
case Qt::Key_Down:
|
||||||
|
dy = delta;
|
||||||
|
break;
|
||||||
|
case Qt::Key_Left:
|
||||||
|
dx = -delta;
|
||||||
|
break;
|
||||||
|
case Qt::Key_Right:
|
||||||
|
dx = delta;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
QAbstractScrollArea::keyPressEvent(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
offset.rx() += dx;
|
||||||
|
offset.ry() += dy;
|
||||||
|
viewport()->update();
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
|
||||||
void GraphView::mouseReleaseEvent(QMouseEvent *event)
|
void GraphView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -87,6 +87,8 @@ protected:
|
|||||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
|
void keyPressEvent(QKeyEvent *event) override;
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
void center();
|
void center();
|
||||||
|
Loading…
Reference in New Issue
Block a user