11import os
22import tempfile
33
4- from PySide6 .QtCore import QThreadPool , QTimer
5- from PySide6 .QtGui import QShortcut , QKeySequence , QFont
4+ from PySide6 .QtCore import QThreadPool , QTimer , Qt
5+ from PySide6 .QtGui import QShortcut , QKeySequence , QFont , QAction , QCursor
66from PySide6 .QtWidgets import (
77 QWidget , QVBoxLayout , QLabel , QHBoxLayout ,
8- QMessageBox , QLineEdit , QPlainTextEdit
8+ QMessageBox , QLineEdit , QPlainTextEdit , QMenu , QStyle
99)
1010
1111from core .concurrency .worker import Worker
@@ -41,6 +41,8 @@ def __init__(self, info_tab: MachOInfoTab):
4141 self .disasm_view .setReadOnly (True )
4242 self .disasm_view .setLineWrapMode (QPlainTextEdit .NoWrap )
4343 self .disasm_view .setUndoRedoEnabled (False )
44+ self .disasm_view .setContextMenuPolicy (Qt .ContextMenuPolicy .CustomContextMenu )
45+ self .disasm_view .customContextMenuRequested .connect (self .context_menu )
4446
4547 font = QFont ("Consolas" )
4648 font .setStyleHint (QFont .Monospace )
@@ -64,6 +66,32 @@ def __init__(self, info_tab: MachOInfoTab):
6466
6567 self .disasm_view .verticalScrollBar ().valueChanged .connect (self ._on_scroll )
6668
69+ def context_menu (self ):
70+ if self .disasm_view .document ().isEmpty ():
71+ return
72+
73+ menu = QMenu (self )
74+ export_action = QAction ("Export to file" )
75+ export_action .setIcon (self .style ().standardIcon (QStyle .StandardPixmap .SP_DialogSaveButton ))
76+ export_action .triggered .connect (self ._export_to_file )
77+
78+ mark_action = QAction ("Mark" )
79+ mark_action .setIcon (self .style ().standardIcon (QStyle .StandardPixmap .SP_TitleBarCloseButton ))
80+ mark_action .triggered .connect (self ._mark_location )
81+
82+ menu .addAction (export_action )
83+ menu .addAction (mark_action )
84+
85+ menu .exec_ (QCursor .pos ())
86+
87+ def _export_to_file (self ):
88+ # todo
89+ pass
90+
91+ def _mark_location (self ):
92+ # todo
93+ pass
94+
6795 def _focus_search (self ):
6896 self .search_box .setFocus ()
6997 self .search_box .selectAll ()
0 commit comments