1- from PySide2 import QtCore
1+ from PySide2 import QtCore , QtGui
22from PySide2 .QtCore import Qt
33from PySide2 .QtWidgets import QApplication , QHBoxLayout , QVBoxLayout , QLabel , QWidget , QPushButton , QLineEdit , QToolBar , QToolButton , QMenu , QAction
44from binaryninja import execute_on_main_thread_and_wait , BinaryView
1313from . import AdapterSettingsDialog
1414from .. import binjaplug , DebugAdapter
1515
16+ def load_icon (fname_icon ):
17+ path_this_file = os .path .abspath (__file__ )
18+ path_this_dir = os .path .dirname (path_this_file )
19+ path_icons = os .path .join (path_this_dir , '..' , 'media' , 'icons' )
20+ path_icon = os .path .join (path_icons , fname_icon )
21+
22+ pixmap = QtGui .QPixmap (path_icon )
23+
24+ #pixmap.fill(QtGui.QColor('red'))
25+ #pixmap.setMask(pixmap.createMaskFromColor(QtGui.QColor('black'), QtGui.Qt.MaskOutColor))
26+
27+ icon = QtGui .QIcon ()
28+ icon .addPixmap (pixmap , QtGui .QIcon .Normal )
29+ icon .addPixmap (pixmap , QtGui .QIcon .Disabled )
30+
31+ return icon
32+
1633class DebugControlsWidget (QToolBar ):
1734 def __init__ (self , parent , name , data , debug_state ):
1835 if not type (data ) == BinaryView :
@@ -31,30 +48,54 @@ def __init__(self, parent, name, data, debug_state):
3148
3249 self .actionRun = QAction ("Run" , self )
3350 self .actionRun .triggered .connect (lambda : self .perform_run ())
51+ self .actionRun .setIcon (load_icon ('run.svg' ))
52+
3453 self .actionRestart = QAction ("Restart" , self )
3554 self .actionRestart .triggered .connect (lambda : self .perform_restart ())
55+ self .actionRestart .setIcon (load_icon ('restart.svg' ))
56+
3657 self .actionQuit = QAction ("Quit" , self )
3758 self .actionQuit .triggered .connect (lambda : self .perform_quit ())
59+ self .actionQuit .setIcon (load_icon ('cancel.svg' ))
60+
3861 self .actionAttach = QAction ("Attach" , self )
3962 self .actionAttach .triggered .connect (lambda : self .perform_attach ())
63+ self .actionAttach .setIcon (load_icon ('connect.svg' ))
64+
4065 self .actionDetach = QAction ("Detach" , self )
4166 self .actionDetach .triggered .connect (lambda : self .perform_detach ())
67+ self .actionDetach .setIcon (load_icon ('disconnect.svg' ))
68+
4269 self .actionSettings = QAction ("Settings..." , self )
4370 self .actionSettings .triggered .connect (lambda : self .perform_settings ())
71+
4472 self .actionPause = QAction ("Pause" , self )
4573 self .actionPause .triggered .connect (lambda : self .perform_pause ())
74+ self .actionPause .setIcon (load_icon ('pause.svg' ))
75+
4676 self .actionResume = QAction ("Resume" , self )
4777 self .actionResume .triggered .connect (lambda : self .perform_resume ())
78+ self .actionResume .setIcon (load_icon ('resume.svg' ))
79+
4880 self .actionStepIntoAsm = QAction ("Step Into (Assembly)" , self )
4981 self .actionStepIntoAsm .triggered .connect (lambda : self .perform_step_into_asm ())
82+ self .actionStepIntoAsm .setIcon (load_icon ('stepinto.svg' ))
83+
5084 self .actionStepIntoIL = QAction ("Step Into" , self )
5185 self .actionStepIntoIL .triggered .connect (lambda : self .perform_step_into_il ())
86+ self .actionStepIntoIL .setIcon (load_icon ('stepinto.svg' ))
87+
5288 self .actionStepOverAsm = QAction ("Step Over (Assembly)" , self )
5389 self .actionStepOverAsm .triggered .connect (lambda : self .perform_step_over_asm ())
90+ self .actionStepOverAsm .setIcon (load_icon ('stepover.svg' ))
91+
5492 self .actionStepOverIL = QAction ("Step Over" , self )
5593 self .actionStepOverIL .triggered .connect (lambda : self .perform_step_over_il ())
94+ self .actionStepOverIL .setIcon (load_icon ('stepover.svg' ))
95+
5696 self .actionStepReturn = QAction ("Step Return" , self )
5797 self .actionStepReturn .triggered .connect (lambda : self .perform_step_return ())
98+ self .actionStepReturn .setIcon (load_icon ('stepout.svg' ))
5899
59100 # session control menu
60101 self .controlMenu = QMenu ("Process Control" , self )
@@ -83,8 +124,13 @@ def __init__(self, parent, name, data, debug_state):
83124 self .addWidget (self .btnControl )
84125
85126 # execution control buttons
86- self .addAction (self .actionPause )
87- self .addAction (self .actionResume )
127+ self .btnPauseResume = QToolButton (self )
128+ self .btnPauseResume .setToolButtonStyle (Qt .ToolButtonTextBesideIcon )
129+ self .btnPauseResume .setDefaultAction (self .actionPause )
130+ self .addWidget (self .btnPauseResume )
131+
132+ #self.addAction(self.actionPause)
133+ #self.addAction(self.actionResume)
88134
89135 self .btnStepInto = QToolButton (self )
90136 self .btnStepInto .setMenu (self .stepIntoMenu )
@@ -101,7 +147,12 @@ def __init__(self, parent, name, data, debug_state):
101147 self .addWidget (self .btnStepOver )
102148
103149 # TODO: Step until returning from current function
104- self .addAction (self .actionStepReturn )
150+ self .btnStepReturn = QToolButton (self )
151+ self .btnStepReturn .setToolButtonStyle (Qt .ToolButtonTextBesideIcon )
152+ self .btnStepReturn .setDefaultAction (self .actionStepReturn )
153+ self .addWidget (self .btnStepReturn )
154+
155+ #self.addAction(self.actionStepReturn)
105156
106157 self .threadMenu = QMenu ("Threads" , self )
107158
@@ -132,7 +183,6 @@ def __del__(self):
132183 # -------------------------------------------------------------------------
133184 # Helpers
134185 # -------------------------------------------------------------------------
135-
136186 def can_exec (self ):
137187 return DebugAdapter .ADAPTER_TYPE .use_exec (self .debug_state .adapter_type )
138188
@@ -439,8 +489,8 @@ def set_default_process_action(self, action):
439489 self .btnControl .setDefaultAction (actions [action ])
440490
441491 def set_resume_pause_action (self , action ):
442- self . actionResume . setVisible ( action == " Resume" )
443- self .actionPause . setVisible ( action == "Pause" )
492+ lookup = { ' Resume' : self . actionResume , 'Pause' : self . actionPause }
493+ self .btnPauseResume . setDefaultAction ( lookup [ action ] )
444494
445495 def set_thread_list (self , threads ):
446496 def select_thread_fn (tid ):
0 commit comments