diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index b4456d5e..f7d162c1 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #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()); } diff --git a/src/widgets/DisassemblerGraphView.h b/src/widgets/DisassemblerGraphView.h index 3a4e3b6d..f784c02e 100644 --- a/src/widgets/DisassemblerGraphView.h +++ b/src/widgets/DisassemblerGraphView.h @@ -145,6 +145,8 @@ public slots: void nextInstr(); void prevInstr(); + void copySelection(); + protected: virtual void wheelEvent(QWheelEvent *event) override;