diff --git a/src/menus/DisassemblyContextMenu.cpp b/src/menus/DisassemblyContextMenu.cpp index ab02b885..c51225e2 100644 --- a/src/menus/DisassemblyContextMenu.cpp +++ b/src/menus/DisassemblyContextMenu.cpp @@ -25,11 +25,11 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent) initAction(&actionCopy, tr("Copy"), SLOT(on_actionCopy_triggered()), getCopySequence()); addAction(&actionCopy); - copySeparator = addSeparator(); - - initAction(&actionCopyAddr, tr("Copy address"), SLOT(on_actionCopyAddr_triggered())); + initAction(&actionCopyAddr, tr("Copy address"), SLOT(on_actionCopyAddr_triggered()), getCopyAddressSequence()); addAction(&actionCopyAddr); + copySeparator = addSeparator(); + initAction(&actionAddComment, tr("Add Comment"), SLOT(on_actionAddComment_triggered()), getCommentSequence()); addAction(&actionAddComment); @@ -388,6 +388,11 @@ QKeySequence DisassemblyContextMenu::getCommentSequence() const return {Qt::Key_Semicolon}; } +QKeySequence DisassemblyContextMenu::getCopyAddressSequence() const +{ + return {Qt::CTRL + Qt::SHIFT + Qt::Key_C}; +} + QKeySequence DisassemblyContextMenu::getSetToCodeSequence() const { return {Qt::Key_C}; diff --git a/src/menus/DisassemblyContextMenu.h b/src/menus/DisassemblyContextMenu.h index 06c3b484..5adba487 100644 --- a/src/menus/DisassemblyContextMenu.h +++ b/src/menus/DisassemblyContextMenu.h @@ -79,6 +79,7 @@ private slots: private: QKeySequence getCopySequence() const; QKeySequence getCommentSequence() const; + QKeySequence getCopyAddressSequence() const; QKeySequence getSetToCodeSequence() const; QKeySequence getSetAsStringSequence() const; QKeySequence getSetToDataSequence() const; diff --git a/src/widgets/HexdumpWidget.cpp b/src/widgets/HexdumpWidget.cpp index 303046ce..3a0c6001 100644 --- a/src/widgets/HexdumpWidget.cpp +++ b/src/widgets/HexdumpWidget.cpp @@ -13,6 +13,7 @@ #include #include #include +#include HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) : MemoryDockWidget(CutterCore::MemoryWidgetType::Hexdump, main, action), @@ -37,6 +38,11 @@ HexdumpWidget::HexdumpWidget(MainWindow *main, QAction *action) : //connect(ui->hexHexText, SIGNAL(cursorPositionChanged()), this, SLOT(highlightHexCurrentLine())); //highlightHexCurrentLine(); + auto cpyAddrShortcut = new QShortcut(QKeySequence{Qt::CTRL + Qt::SHIFT + Qt::Key_C}, this); + cpyAddrShortcut->setContext(Qt::WidgetWithChildrenShortcut); + ui->actionCopyAddressAtCursor->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_C); + connect(cpyAddrShortcut, &QShortcut::activated, this, &HexdumpWidget::on_actionCopyAddressAtCursor_triggered); + ui->copyMD5->setIcon(QIcon(":/img/icons/copy.svg")); ui->copySHA1->setIcon(QIcon(":/img/icons/copy.svg")); @@ -621,6 +627,11 @@ void HexdumpWidget::showHexdumpContextMenu(const QPoint &pt) // Set Hexdump popup menu QMenu *menu = ui->hexHexText->createStandardContextMenu(); menu->clear(); + + menu->addAction(ui->actionCopyAddressAtCursor); + + menu->addSeparator(); + /*menu->addAction(ui->actionHexCopy_Hexpair); menu->addAction(ui->actionHexCopy_ASCII); menu->addAction(ui->actionHexCopy_Text); @@ -983,6 +994,14 @@ void HexdumpWidget::scrollChanged() * Actions callback functions */ +void HexdumpWidget::on_actionCopyAddressAtCursor_triggered() +{ + auto addr = hexPositionToAddress(ui->hexHexText->textCursor().position()); + + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(RAddressString(addr)); +} + void HexdumpWidget::on_actionHideHexdump_side_panel_triggered() { if (ui->hexSideTab_2->isVisible()) { diff --git a/src/widgets/HexdumpWidget.h b/src/widgets/HexdumpWidget.h index 9b1d5caa..9768642d 100644 --- a/src/widgets/HexdumpWidget.h +++ b/src/widgets/HexdumpWidget.h @@ -137,6 +137,8 @@ private slots: void on_parseTypeComboBox_currentTextChanged(const QString &arg1); void on_parseEndianComboBox_currentTextChanged(const QString &arg1); + void on_actionCopyAddressAtCursor_triggered(); + void on_action1column_triggered(); void on_action2columns_triggered(); void on_action4columns_triggered(); diff --git a/src/widgets/HexdumpWidget.ui b/src/widgets/HexdumpWidget.ui index 00a779ec..9806a315 100644 --- a/src/widgets/HexdumpWidget.ui +++ b/src/widgets/HexdumpWidget.ui @@ -764,6 +764,14 @@ Copy Text + + + Copy Address + + + Copy Address at Cursor + + 1