mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 02:48:49 +00:00
Add 'Copy' context menu option to graph view (#1097)
This commit is contained in:
parent
b0bb1f0610
commit
d05fdd3d44
@ -14,6 +14,8 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
#include <QClipboard>
|
||||
#include <QApplication>
|
||||
|
||||
#include "Cutter.h"
|
||||
#include "common/Colors.h"
|
||||
@ -114,6 +116,8 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
|
||||
initFont();
|
||||
colorsUpdatedSlot();
|
||||
|
||||
connect(mMenu, SIGNAL(copy()), this, SLOT(copySelection()));
|
||||
|
||||
header = new QTextEdit(viewport());
|
||||
header->setFixedHeight(30);
|
||||
header->setReadOnly(true);
|
||||
@ -782,6 +786,14 @@ void DisassemblerGraphView::seekLocal(RVA addr, bool update_viewport)
|
||||
}
|
||||
}
|
||||
|
||||
void DisassemblerGraphView::copySelection()
|
||||
{
|
||||
if (!highlight_token) return;
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(highlight_token->content);
|
||||
}
|
||||
|
||||
DisassemblerGraphView::Token *DisassemblerGraphView::getToken(Instr *instr, int x)
|
||||
{
|
||||
x -= (int) (3 * charWidth); // Ignore left margin
|
||||
@ -828,6 +840,7 @@ void DisassemblerGraphView::blockClicked(GraphView::GraphBlock &block, QMouseEve
|
||||
seekLocal(addr);
|
||||
|
||||
mMenu->setOffset(addr);
|
||||
mMenu->setCanCopy(highlight_token);
|
||||
if (event->button() == Qt::RightButton) {
|
||||
mMenu->exec(event->globalPos());
|
||||
}
|
||||
|
@ -145,6 +145,8 @@ public slots:
|
||||
void nextInstr();
|
||||
void prevInstr();
|
||||
|
||||
void copySelection();
|
||||
|
||||
protected:
|
||||
virtual void wheelEvent(QWheelEvent *event) override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user