| 713 | } |
| 714 | |
| 715 | void DisassemblyView::openContextMenu(QPoint pos) |
| 716 | { |
| 717 | if (!cpu().isAlive()) |
| 718 | return; |
| 719 | |
| 720 | // Dont open context menu when used on column title row |
| 721 | if (pos.y() / m_rowHeight == 0) |
| 722 | return; |
| 723 | |
| 724 | QMenu* menu = new QMenu(this); |
| 725 | menu->setAttribute(Qt::WA_DeleteOnClose); |
| 726 | |
| 727 | QAction* copy_address_action = menu->addAction(tr("Copy Address")); |
| 728 | connect(copy_address_action, &QAction::triggered, this, &DisassemblyView::contextCopyAddress); |
| 729 | |
| 730 | QAction* copy_instruction_hex_action = menu->addAction(tr("Copy Instruction Hex")); |
| 731 | connect(copy_instruction_hex_action, &QAction::triggered, this, &DisassemblyView::contextCopyInstructionHex); |
| 732 | |
| 733 | QAction* copy_instruction_text_action = menu->addAction(tr("&Copy Instruction Text")); |
| 734 | copy_instruction_text_action->setShortcut(QKeySequence(Qt::Key_C)); |
| 735 | connect(copy_instruction_text_action, &QAction::triggered, this, &DisassemblyView::contextCopyInstructionText); |
| 736 | |
| 737 | if (cpu().GetSymbolGuardian().FunctionExistsWithStartingAddress(m_selectedAddressStart)) |
| 738 | { |
| 739 | QAction* copy_function_name_action = menu->addAction(tr("Copy Function Name")); |
| 740 | connect(copy_function_name_action, &QAction::triggered, this, &DisassemblyView::contextCopyFunctionName); |
| 741 | } |
| 742 | |
| 743 | QAction* paste_instruction_text_action = menu->addAction(tr("Paste Instruction Text")); |
| 744 | connect(paste_instruction_text_action, &QAction::triggered, this, &DisassemblyView::contextPasteInstructionText); |
| 745 | |
| 746 | menu->addSeparator(); |
| 747 | |
| 748 | if (AddressCanRestore(m_selectedAddressStart, m_selectedAddressEnd)) |
| 749 | { |
| 750 | QAction* restore_instruction_action = menu->addAction(tr("Restore Instruction(s)")); |
| 751 | connect(restore_instruction_action, &QAction::triggered, this, &DisassemblyView::contextRestoreInstruction); |
| 752 | } |
| 753 | |
| 754 | QAction* assemble_new_instruction = menu->addAction(tr("Asse&mble new Instruction(s)")); |
| 755 | assemble_new_instruction->setShortcut(QKeySequence(Qt::Key_M)); |
| 756 | connect(assemble_new_instruction, &QAction::triggered, this, &DisassemblyView::contextAssembleInstruction); |
| 757 | |
| 758 | QAction* nop_instruction_action = menu->addAction(tr("NOP Instruction(s)")); |
| 759 | connect(nop_instruction_action, &QAction::triggered, this, &DisassemblyView::contextNoopInstruction); |
| 760 | |
| 761 | menu->addSeparator(); |
| 762 | |
| 763 | QAction* run_to_cursor_action = menu->addAction(tr("Run to Cursor")); |
| 764 | connect(run_to_cursor_action, &QAction::triggered, this, &DisassemblyView::contextRunToCursor); |
| 765 | |
| 766 | QAction* jump_to_cursor_action = menu->addAction(tr("&Jump to Cursor")); |
| 767 | jump_to_cursor_action->setShortcut(QKeySequence(Qt::Key_J)); |
| 768 | connect(jump_to_cursor_action, &QAction::triggered, this, &DisassemblyView::contextJumpToCursor); |
| 769 | |
| 770 | QAction* toggle_breakpoint_action = menu->addAction(tr("Toggle &Breakpoint")); |
| 771 | toggle_breakpoint_action->setShortcut(QKeySequence(Qt::Key_B)); |
| 772 | connect(toggle_breakpoint_action, &QAction::triggered, this, &DisassemblyView::contextToggleBreakpoint); |
nothing calls this directly
no test coverage detected