2
2
#include " Configuration.h"
3
3
#include " Bridge.h"
4
4
5
- Disassembly::Disassembly (QWidget* parent)
6
- : AbstractTableView(parent)
5
+ Disassembly::Disassembly (QWidget* parent) : AbstractTableView(parent)
7
6
{
8
- fontsUpdated ();
9
7
mMemPage = new MemoryPage (0 , 0 );
10
8
11
9
mInstBuffer .clear ();
@@ -32,6 +30,9 @@ Disassembly::Disassembly(QWidget* parent)
32
30
33
31
mGuiState = Disassembly::NoState;
34
32
33
+ // Update fonts immediately because they are used in calculations
34
+ updateFonts ();
35
+
35
36
setRowCount (mMemPage ->getSize ());
36
37
37
38
addColumnAt (getCharWidth () * 2 * sizeof (dsint) + 8 , " " , false ); // address
@@ -43,18 +44,41 @@ Disassembly::Disassembly(QWidget* parent)
43
44
44
45
backgroundColor = ConfigColor (" DisassemblyBackgroundColor" );
45
46
47
+ // Slots
46
48
connect (Bridge::getBridge (), SIGNAL (repaintGui ()), this , SLOT (reloadData ()));
49
+ connect (Bridge::getBridge (), SIGNAL (updateDump ()), this , SLOT (reloadData ()));
50
+ connect (Bridge::getBridge (), SIGNAL (dbgStateChanged (DBGSTATE)), this , SLOT (debugStateChanged (DBGSTATE)));
51
+
52
+ Initialize ();
47
53
}
48
54
49
- void Disassembly::colorsUpdated ()
55
+ void Disassembly::updateColors ()
50
56
{
51
- AbstractTableView::colorsUpdated ();
57
+ AbstractTableView::updateColors ();
52
58
backgroundColor = ConfigColor (" DisassemblyBackgroundColor" );
59
+
60
+ mInstructionHighlightColor = ConfigColor (" InstructionHighlightColor" );
61
+ mSelectionColor = ConfigColor (" DisassemblySelectionColor" );
62
+ mCipBackgroundColor = ConfigColor (" DisassemblyCipBackgroundColor" );
63
+ mBreakpointBackgroundColor = ConfigColor (" DisassemblyBreakpointBackgroundColor" );
64
+ mBreakpointColor = ConfigColor (" DisassemblyBreakpointColor" );
65
+ mCipColor = ConfigColor (" DisassemblyCipColor" );
66
+ mHardwareBreakpointBackgroundColor = ConfigColor (" DisassemblyHardwareBreakpointBackgroundColor" );
67
+ mHardwareBreakpointColor = ConfigColor (" DisassemblyHardwareBreakpointColor" );
68
+ mBookmarkBackgroundColor = ConfigColor (" DisassemblyBookmarkBackgroundColor" );
69
+ mBookmarkColor = ConfigColor (" DisassemblyBookmarkColor" );
70
+ mLabelColor = ConfigColor (" DisassemblyLabelColor" );
71
+ mLabelBackgroundColor = ConfigColor (" DisassemblyLabelBackgroundColor" );
72
+ mSelectedAddressBackgroundColor = ConfigColor (" DisassemblySelectedAddressBackgroundColor" );
73
+ mSelectedAddressColor = ConfigColor (" DisassemblySelectedAddressColor" );
74
+ mAddressBackgroundColor = ConfigColor (" DisassemblyAddressBackgroundColor" );
75
+ mAddressColor = ConfigColor (" DisassemblyAddressColor" );
76
+
53
77
CapstoneTokenizer::UpdateColors ();
54
78
mDisasm ->UpdateConfig ();
55
79
}
56
80
57
- void Disassembly::fontsUpdated ()
81
+ void Disassembly::updateFonts ()
58
82
{
59
83
setFont (ConfigFont (" Disassembly" ));
60
84
}
@@ -83,7 +107,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
83
107
84
108
if (mHighlightingMode )
85
109
{
86
- QPen pen (ConfigColor ( " InstructionHighlightColor " ) );
110
+ QPen pen (mInstructionHighlightColor );
87
111
pen.setWidth (2 );
88
112
painter->setPen (pen);
89
113
QRect rect = viewport ()->rect ();
@@ -95,7 +119,7 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
95
119
96
120
// Highlight if selected
97
121
if (wIsSelected)
98
- painter->fillRect (QRect (x, y, w, h), QBrush (ConfigColor ( " DisassemblySelectionColor " ) ));
122
+ painter->fillRect (QRect (x, y, w, h), QBrush (mSelectionColor ));
99
123
100
124
switch (col)
101
125
{
@@ -108,39 +132,39 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
108
132
bool isbookmark = DbgGetBookmarkAt (cur_addr);
109
133
if (mInstBuffer .at (rowOffset).rva == mCipRva && !mIsRunning ) // cip + not running
110
134
{
111
- painter->fillRect (QRect (x, y, w, h), QBrush (ConfigColor ( " DisassemblyCipBackgroundColor " ) ));
135
+ painter->fillRect (QRect (x, y, w, h), QBrush (mCipBackgroundColor ));
112
136
if (!isbookmark) // no bookmark
113
137
{
114
138
if (bpxtype & bp_normal) // normal breakpoint
115
139
{
116
- QColor bpColor = ConfigColor ( " DisassemblyBreakpointBackgroundColor " ) ;
140
+ QColor& bpColor = mBreakpointBackgroundColor ;
117
141
if (!bpColor.alpha ()) // we don't want transparent text
118
- bpColor = ConfigColor ( " DisassemblyBreakpointColor " ) ;
119
- if (bpColor == ConfigColor ( " DisassemblyCipBackgroundColor " ) )
120
- bpColor = ConfigColor ( " DisassemblyCipColor " ) ;
142
+ bpColor = mBreakpointColor ;
143
+ if (bpColor == mCipBackgroundColor )
144
+ bpColor = mCipColor ;
121
145
painter->setPen (QPen (bpColor));
122
146
}
123
147
else if (bpxtype & bp_hardware) // hardware breakpoint only
124
148
{
125
- QColor hwbpColor = ConfigColor ( " DisassemblyHardwareBreakpointBackgroundColor " ) ;
149
+ QColor hwbpColor = mHardwareBreakpointBackgroundColor ;
126
150
if (!hwbpColor.alpha ()) // we don't want transparent text
127
- hwbpColor = ConfigColor ( " DisassemblyHardwareBreakpointColor " ) ;
128
- if (hwbpColor == ConfigColor ( " DisassemblyCipBackgroundColor " ) )
129
- hwbpColor = ConfigColor ( " DisassemblyCipColor " ) ;
151
+ hwbpColor = mHardwareBreakpointColor ;
152
+ if (hwbpColor == mCipBackgroundColor )
153
+ hwbpColor = mCipColor ;
130
154
painter->setPen (hwbpColor);
131
155
}
132
156
else // no breakpoint
133
157
{
134
- painter->setPen (QPen (ConfigColor ( " DisassemblyCipColor " ) ));
158
+ painter->setPen (QPen (mCipColor ));
135
159
}
136
160
}
137
161
else // bookmark
138
162
{
139
- QColor bookmarkColor = ConfigColor ( " DisassemblyBookmarkBackgroundColor " ) ;
163
+ QColor bookmarkColor = mBookmarkBackgroundColor ;
140
164
if (!bookmarkColor.alpha ()) // we don't want transparent text
141
- bookmarkColor = ConfigColor ( " DisassemblyBookmarkColor " ) ;
142
- if (bookmarkColor == ConfigColor ( " DisassemblyCipBackgroundColor " ) )
143
- bookmarkColor = ConfigColor ( " DisassemblyCipColor " ) ;
165
+ bookmarkColor = mBookmarkColor ;
166
+ if (bookmarkColor == mCipBackgroundColor )
167
+ bookmarkColor = mCipColor ;
144
168
painter->setPen (QPen (bookmarkColor));
145
169
}
146
170
}
@@ -152,25 +176,25 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
152
176
{
153
177
if (bpxtype == bp_none) // label only
154
178
{
155
- painter->setPen (QPen (ConfigColor ( " DisassemblyLabelColor " ) )); // red -> address + label text
156
- painter->fillRect (QRect (x, y, w, h), QBrush (ConfigColor ( " DisassemblyLabelBackgroundColor " ) )); // fill label background
179
+ painter->setPen (QPen (mLabelColor )); // red -> address + label text
180
+ painter->fillRect (QRect (x, y, w, h), QBrush (mLabelBackgroundColor )); // fill label background
157
181
}
158
182
else // label+breakpoint
159
183
{
160
184
if (bpxtype & bp_normal) // label + normal breakpoint
161
185
{
162
- painter->setPen (QPen (ConfigColor ( " DisassemblyBreakpointColor " ) ));
163
- painter->fillRect (QRect (x, y, w, h), QBrush (ConfigColor ( " DisassemblyBreakpointBackgroundColor " ) )); // fill red
186
+ painter->setPen (QPen (mBreakpointColor ));
187
+ painter->fillRect (QRect (x, y, w, h), QBrush (mBreakpointBackgroundColor )); // fill red
164
188
}
165
189
else if (bpxtype & bp_hardware) // label + hardware breakpoint only
166
190
{
167
- painter->setPen (QPen (ConfigColor ( " DisassemblyHardwareBreakpointColor " ) ));
168
- painter->fillRect (QRect (x, y, w, h), QBrush (ConfigColor ( " DisassemblyHardwareBreakpointBackgroundColor " ) )); // fill ?
191
+ painter->setPen (QPen (mHardwareBreakpointColor ));
192
+ painter->fillRect (QRect (x, y, w, h), QBrush (mHardwareBreakpointBackgroundColor )); // fill ?
169
193
}
170
194
else // other cases -> do as normal
171
195
{
172
- painter->setPen (QPen (ConfigColor ( " DisassemblyLabelColor " ) )); // red -> address + label text
173
- painter->fillRect (QRect (x, y, w, h), QBrush (ConfigColor ( " DisassemblyLabelBackgroundColor " ) )); // fill label background
196
+ painter->setPen (QPen (mLabelColor )); // red -> address + label text
197
+ painter->fillRect (QRect (x, y, w, h), QBrush (mLabelBackgroundColor )); // fill label background
174
198
}
175
199
}
176
200
}
@@ -181,13 +205,13 @@ QString Disassembly::paintContent(QPainter* painter, dsint rowBase, int rowOffse
181
205
QColor background;
182
206
if (wIsSelected)
183
207
{
184
- background = ConfigColor ( " DisassemblySelectedAddressBackgroundColor " ) ;
185
- painter->setPen (QPen (ConfigColor ( " DisassemblySelectedAddressColor " ) )); // black address (DisassemblySelectedAddressColor)
208
+ background = mSelectedAddressBackgroundColor ;
209
+ painter->setPen (QPen (mSelectedAddressColor )); // black address (DisassemblySelectedAddressColor)
186
210
}
187
211
else
188
212
{
189
- background = ConfigColor ( " DisassemblyAddressBackgroundColor " ) ;
190
- painter->setPen (QPen (ConfigColor ( " DisassemblyAddressColor " ) )); // DisassemblyAddressColor
213
+ background = mAddressBackgroundColor ;
214
+ painter->setPen (QPen (mAddressColor )); // DisassemblyAddressColor
191
215
}
192
216
if (background.alpha ())
193
217
painter->fillRect (QRect (x, y, w, h), QBrush (background)); // fill background
0 commit comments