mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 10:58:51 +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 <QVBoxLayout>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
#include "Cutter.h"
|
#include "Cutter.h"
|
||||||
#include "common/Colors.h"
|
#include "common/Colors.h"
|
||||||
@ -114,6 +116,8 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
|
|||||||
initFont();
|
initFont();
|
||||||
colorsUpdatedSlot();
|
colorsUpdatedSlot();
|
||||||
|
|
||||||
|
connect(mMenu, SIGNAL(copy()), this, SLOT(copySelection()));
|
||||||
|
|
||||||
header = new QTextEdit(viewport());
|
header = new QTextEdit(viewport());
|
||||||
header->setFixedHeight(30);
|
header->setFixedHeight(30);
|
||||||
header->setReadOnly(true);
|
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)
|
DisassemblerGraphView::Token *DisassemblerGraphView::getToken(Instr *instr, int x)
|
||||||
{
|
{
|
||||||
x -= (int) (3 * charWidth); // Ignore left margin
|
x -= (int) (3 * charWidth); // Ignore left margin
|
||||||
@ -828,6 +840,7 @@ void DisassemblerGraphView::blockClicked(GraphView::GraphBlock &block, QMouseEve
|
|||||||
seekLocal(addr);
|
seekLocal(addr);
|
||||||
|
|
||||||
mMenu->setOffset(addr);
|
mMenu->setOffset(addr);
|
||||||
|
mMenu->setCanCopy(highlight_token);
|
||||||
if (event->button() == Qt::RightButton) {
|
if (event->button() == Qt::RightButton) {
|
||||||
mMenu->exec(event->globalPos());
|
mMenu->exec(event->globalPos());
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,8 @@ public slots:
|
|||||||
void nextInstr();
|
void nextInstr();
|
||||||
void prevInstr();
|
void prevInstr();
|
||||||
|
|
||||||
|
void copySelection();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void wheelEvent(QWheelEvent *event) override;
|
virtual void wheelEvent(QWheelEvent *event) override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user