Basic Block Highlight (#1533)

This commit is contained in:
optizone 2019-05-23 19:22:31 +03:00 committed by Florian Märkl
parent 214e6f4264
commit 31838a3a35
12 changed files with 272 additions and 65 deletions

View File

@ -7,6 +7,7 @@
#include "common/CrashHandler.h"
#include <QJsonObject>
#include <QJsonArray>
/**
* @brief Migrate Settings used before Cutter 1.8

View File

@ -8,8 +8,8 @@
#include "common/Configuration.h"
const QStringList ColorThemeWorker::cutterSpecificOptions = {
"linehl",
"wordhl",
"wordHighlight",
"lineHighlight",
"gui.main",
"gui.imports",
"highlightPC",
@ -31,6 +31,8 @@ const QStringList ColorThemeWorker::cutterSpecificOptions = {
};
const QStringList ColorThemeWorker::radare2UnusedOptions = {
"linehl",
"wordhl",
"graph.box",
"graph.box2",
"graph.box3",
@ -115,20 +117,26 @@ QString ColorThemeWorker::save(const QJsonDocument &theme, const QString &themeN
}
QJsonObject obj = theme.object();
QString line;
QColor::NameFormat format;
for (auto it = obj.constBegin(); it != obj.constEnd(); it++) {
QString line;
if (cutterSpecificOptions.contains(it.key())) {
line = "#~%1 %2\n";
format = QColor::HexArgb;
} else {
line = "ec %1 %2\n";
format = QColor::HexRgb;
}
QJsonArray arr = it.value().toArray();
if (arr.isEmpty()) {
fOut.write(line.arg(it.key())
.arg(it.value().toVariant().value<QColor>().name()).toUtf8());
.arg(it.value().toVariant().value<QColor>().name(format)).toUtf8());
} else if (arr.size() == 4) {
fOut.write(line.arg(it.key())
.arg(QColor(arr[0].toInt(), arr[1].toInt(), arr[2].toInt(), arr[3].toInt()).name(format)).toUtf8());
} else if (arr.size() == 3) {
fOut.write(line.arg(it.key())
.arg(QColor(arr[0].toInt(), arr[1].toInt(), arr[2].toInt()).name()).toUtf8());
.arg(QColor(arr[0].toInt(), arr[1].toInt(), arr[2].toInt()).name(format)).toUtf8());
}
}
@ -149,7 +157,7 @@ bool ColorThemeWorker::isThemeExist(const QString &name) const
QJsonDocument ColorThemeWorker::getTheme(const QString& themeName) const
{
int r, g, b;
int r, g, b, a;
QJsonObject theme;
QString curr = Config()->getColorTheme();
@ -172,14 +180,23 @@ QJsonDocument ColorThemeWorker::getTheme(const QString& themeName) const
if (sl.size() != 3 || sl[0][0] == '#') {
continue;
}
QColor(sl[2]).getRgb(&r, &g, &b);
theme.insert(sl[1], QJsonArray({r, g, b}));
QColor(sl[2]).getRgb(&r, &g, &b, &a);
theme.insert(sl[1], QJsonArray({r, g, b, a}));
}
for (auto &it : cutterSpecificOptions) {
if (!theme.contains(it)) {
mergeColors(Config()->getColor(it),
Config()->getColor("gui.background")).getRgb(&r, &g, &b, &a);
Config()->getColor(it).getRgb(&r, &g, &b, &a);
theme.insert(it, QJsonArray({r, g, b, a}));
}
}
} else {
for (auto &it : cutterSpecificOptions) {
mergeColors(Config()->getColor(it),
Config()->getColor("gui.background")).getRgb(&r, &g, &b);
theme.insert(it, QJsonArray({r, g, b}));
Config()->getColor("gui.background")).getRgb(&r, &g, &b, &a);
Config()->getColor(it).getRgb(&r, &g, &b, &a);
theme.insert(it, QJsonArray({r, g, b, a}));
}
}
@ -277,7 +294,7 @@ bool ColorThemeWorker::isFileTheme(const QString& filePath, bool* ok) const
QString options = (Core()->cmdj("ecj").object().keys() << cutterSpecificOptions)
.join('|')
.replace(".", "\\.");
QRegExp regexp = QRegExp(QString("((ec\\s+(%1)\\s+(((rgb:|#)([0-9a-fA-F]{3}){1,2})|(%2))))\\s*")
QRegExp regexp = QRegExp(QString("((ec\\s+(%1)\\s+(((rgb:|#)[0-9a-fA-F]{3,8})|(%2))))\\s*")
.arg(options)
.arg(colors));

View File

@ -248,8 +248,8 @@ void Configuration::loadNativeTheme()
setColor("gui.background", QColor(30, 30, 30));
setColor("gui.alt_background", QColor(42, 42, 42));
setColor("gui.disass_selected", QColor(35, 35, 35));
setColor("linehl", QColor(255, 255, 255, 15));
setColor("wordhl", QColor(20, 20, 20, 255));
setColor("lineHighlight", QColor(255, 255, 255, 15));
setColor("wordHighlight", QColor(20, 20, 20, 255));
setColor("highlightPC", QColor(87, 26, 7));
setColor("gui.tooltip.background", QColor(42, 44, 46));
setColor("gui.tooltip.foreground", QColor(250, 252, 254));
@ -259,8 +259,8 @@ void Configuration::loadNativeTheme()
setColor("gui.background", QColor(255, 255, 255));
setColor("gui.alt_background", QColor(245, 250, 255));
setColor("gui.disass_selected", QColor(255, 255, 255));
setColor("linehl", QColor(210, 210, 255, 150));
setColor("wordhl", QColor(179, 119, 214, 60));
setColor("lineHighlight", QColor(210, 210, 255, 150));
setColor("wordHighlight", QColor(179, 119, 214, 60));
setColor("highlightPC", QColor(214, 255, 210));
setColor("gui.dataoffset", QColor(0, 0, 0));
}
@ -291,8 +291,8 @@ void Configuration::loadLightTheme()
setColor("gui.background", QColor(255, 255, 255));
setColor("gui.alt_background", QColor(245, 250, 255));
setColor("gui.disass_selected", QColor(255, 255, 255));
setColor("linehl", QColor(210, 210, 255, 150));
setColor("wordhl", QColor(179, 119, 214, 60));
setColor("lineHighlight", QColor(210, 210, 255, 150));
setColor("wordHighlight", QColor(179, 119, 214, 60));
setColor("highlightPC", QColor(214, 255, 210));
setColor("gui.navbar.empty", QColor(220, 236, 245));
setColor("gui.navbar.err", QColor(3, 170, 245));
@ -363,8 +363,8 @@ void Configuration::loadDarkTheme()
// Disassembly line selected
setColor("gui.tooltip.background", QColor(42, 44, 46));
setColor("gui.tooltip.foreground", QColor(250, 252, 254));
setColor("linehl", QColor(21, 29, 29, 150));
setColor("wordhl", QColor(52, 58, 71, 255));
setColor("lineHighlight", QColor(21, 29, 29, 150));
setColor("wordHighlight", QColor(52, 58, 71, 255));
}
const QFont Configuration::getFont() const
@ -462,10 +462,10 @@ void Configuration::setColorTheme(const QString &theme)
QJsonObject colorTheme = ThemeWorker().getTheme(theme).object();
for (auto it = colorTheme.constBegin(); it != colorTheme.constEnd(); it++) {
QJsonArray rgb = it.value().toArray();
if (rgb.size() != 3) {
if (rgb.size() != 4) {
continue;
}
setColor(it.key(), QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt()));
setColor(it.key(), QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt(), rgb[3].toInt()));
}
// Trick Cutter to load colors that are not specified in standard theme

View File

@ -118,7 +118,7 @@ void XrefsDialog::highlightCurrentLine()
if (ui->previewTextEdit->isReadOnly()) {
QTextEdit::ExtraSelection selection = QTextEdit::ExtraSelection();
selection.format.setBackground(ConfigColor("linehl"));
selection.format.setBackground(ConfigColor("lineHighlight"));
selection.format.setProperty(QTextFormat::FullWidthSelection, true);
selection.cursor = ui->previewTextEdit->textCursor();
selection.cursor.clearSelection();

View File

@ -35,7 +35,15 @@ ColorThemeEditDialog::ColorThemeEditDialog(QWidget *parent) :
previewDisasmWidget, &DisassemblyWidget::colorsUpdatedSlot);
connect(ui->colorThemeListView, &ColorThemeListView::itemChanged,
ui->colorPicker, &ColorPicker::updateColor);
this, [this](const QColor& color) {
ui->colorPicker->updateColor(color);
QString optionName = ui->colorThemeListView->currentIndex()
.data(Qt::UserRole)
.value<ColorOption>()
.optionName;
ui->colorPicker->setAlphaEnabled(optionName == "wordHighlight" || optionName == "lineHighlight");
});
ui->colorThemeListView->setCurrentIndex(ui->colorThemeListView->model()->index(0, 0));
connect(ui->colorPicker, &ColorPicker::colorChanged, this, &ColorThemeEditDialog::colorOptionChanged);

View File

@ -33,11 +33,24 @@ void ColorPickArea::paintEvent(QPaintEvent* event)
p.setPen(QPen(Qt::black, 3));
QPoint curr = colorToPoint(currColor);
p.drawLine(curr - QPoint(0, 10), curr + QPoint(0, 10));
p.drawLine(curr - QPoint(10, 0), curr + QPoint(10, 0));
p.drawLine(curr - QPoint(0, 8), curr + QPoint(0, 8));
p.drawLine(curr - QPoint(8, 0), curr + QPoint(8, 0));
p.end();
QWidget::paintEvent(event);
}
void ColorPickArea::setColor(const QColor& c)
{
if (c == currColor) {
return;
}
QPoint p1 = colorToPoint(currColor);
QPoint p2 = colorToPoint(c);
currColor = c;
repaint(QRect(p2 - QPoint(10, 10), p2 + QPoint(10, 10)));
repaint(QRect(p1 - QPoint(10, 10), p1 + QPoint(10, 10)));
emit colorChanged(currColor);
}
ColorPickerWidget::ColorPickerWidget(QWidget* parent) : ColorPickWidgetAbstract(parent)
@ -63,11 +76,11 @@ void ColorPickerWidget::mouseMoveEvent(QMouseEvent* event)
QColor ColorPickArea::pointToColor(int x, int y) const
{
QColor color;
qreal h, s, v;
currColor.getHsvF(&h, &s, &v);
color.setHsvF((qreal)x / width(),
1.0 - (qreal)y / height(),
v);
qreal h, s, v, a;
currColor.getHsvF(&h, &s, &v, &a);
color.setHsvF(qreal(x) / width(),
1.0 - qreal(y) / height(),
v, a);
return color;
}
@ -75,7 +88,7 @@ QPoint ColorPickArea::colorToPoint(const QColor& color) const
{
qreal h, s, v;
color.getHsvF(&h, &s, &v);
return QPoint(h * width(), (1.0 - s) * height());
return QPointF(h * width(), (1.0 - s) * height()).toPoint();
}
void ColorPickerWidget::mouseEvent(QMouseEvent* event)
@ -91,15 +104,18 @@ void ColorPickerWidget::mouseEvent(QMouseEvent* event)
? rect().bottom() + 1
: rect().y());
}
currColor = pointToColor(pos.x(), pos.y());
emit colorChanged(currColor);
repaint(QRect(event->pos() - QPoint(10, 10), event->pos() + QPoint(10, 10)));
setColor(pointToColor(pos.x(), pos.y()));
}
void ColorPickWidgetAbstract::setColor(const QColor& color)
void ColorValueBar::setColor(const QColor& c)
{
currColor = color;
if (c == currColor) {
return;
}
currColor = c;
repaint();
emit colorChanged(currColor);
}
void ColorValueBar::paintEvent(QPaintEvent* event)
@ -110,22 +126,19 @@ void ColorValueBar::paintEvent(QPaintEvent* event)
currColor.getHsvF(&h, &s, &v);
v = 1.0 - v;
const int trianleSize = 10;
const int triangleSize = 10;
QRect barRect = rect();
barRect.setWidth(barRect.width() - trianleSize);
barRect.setWidth(barRect.width() - triangleSize);
for (int y = barRect.y(); y <= barRect.bottom(); y++) {
color.setHsvF(h, s, 1.0 - (qreal)y / height());
color.setHsvF(h, s, 1.0 - qreal(y) / height());
p.setPen(color);
p.drawLine(barRect.x(), y, barRect.right(), y);
}
p.setPen(palette().alternateBase().color());
p.drawRect(rect());
QRectF triangleRect = QRectF(barRect.right(), v * height() - trianleSize / 2,
trianleSize, trianleSize);
QRectF triangleRect = QRectF(barRect.right(), v * height() - triangleSize / 2,
triangleSize, triangleSize);
QPainterPath path;
path.moveTo(triangleRect.left(), triangleRect.top() + triangleRect.height() / 2);
@ -143,9 +156,9 @@ QColor ColorValueBar::pointToColor(int x, int y) const
{
Q_UNUSED(x)
QColor color = currColor;
qreal h, s, v;
color.getHsvF(&h, &s, &v);
color.setHsvF(h, s, 1.0 - (qreal)y / height());
qreal h, s, v, a;
color.getHsvF(&h, &s, &v, &a);
color.setHsvF(h, s, 1.0 - qreal(y) / height(), a);
return color;
}
@ -153,7 +166,7 @@ QPoint ColorValueBar::colorToPoint(const QColor& color) const
{
qreal h, s, v;
color.getHsvF(&h, &s, &v);
return QPoint(rect().x(), (1.0 - v) * height());
return QPoint(rect().x(), int((1.0 - v) * height()));
}
ColorPicker::ColorPicker(QWidget* parent) :
@ -166,12 +179,16 @@ ColorPicker::ColorPicker(QWidget* parent) :
this, &ColorPicker::setColor);
connect(ui->valuePickBar, &ColorValueBar::colorChanged,
this, &ColorPicker::setColor);
connect(ui->alphaChannelBar, &AlphaChannelBar::colorChanged,
this, [this](const QColor& color) { emit colorChanged(color); });
connect(this, &ColorPicker::colorChanged,
ui->colorPickArea, &ColorPickArea::setColor);
connect(this, &ColorPicker::colorChanged,
ui->valuePickBar, &ColorValueBar::setColor);
connect(this, &ColorPicker::colorChanged,
ui->colorShow, &ColorShowWidget::setColor);
connect(this, &ColorPicker::colorChanged,
ui->alphaChannelBar, &AlphaChannelBar::setColor);
connect(ui->hueSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, &ColorPicker::colorChannelChanged);
@ -247,6 +264,12 @@ void ColorPicker::updateColor(const QColor& color)
QSignalBlocker s5(ui->hueSpinBox);
QSignalBlocker s6(ui->hexLineEdit);
QSignalBlocker s7(ui->alphaChannelBar);
QSignalBlocker s8(ui->colorPickArea);
QSignalBlocker s9(ui->colorShow);
QSignalBlocker s10(ui->valuePickBar);
currColor = color;
ui->hexLineEdit->setText(currColor.name());
@ -266,6 +289,7 @@ void ColorPicker::updateColor(const QColor& color)
ui->valuePickBar->setColor(color);
ui->colorPickArea->setColor(color);
ui->colorShow->setColor(color);
ui->alphaChannelBar->setColor(color);
}
void ColorPicker::startPickingFromScreen()
@ -311,6 +335,11 @@ bool ColorPicker::isPickingFromScreen() const
return pickingFromScreen;
}
void ColorPicker::setAlphaEnabled(bool enabled)
{
ui->alphaChannelBar->setVisible(enabled);
}
void ColorPicker::stopPickingFromScreen()
{
if (pickingFromScreen) {
@ -323,11 +352,89 @@ void ColorPicker::stopPickingFromScreen()
ColorShowWidget::ColorShowWidget(QWidget* parent) : ColorPickWidgetAbstract(parent) { }
void ColorShowWidget::setColor(const QColor& c)
{
currColor = c;
repaint();
}
void ColorShowWidget::paintEvent(QPaintEvent* event)
{
QPainter p(this);
const int miniRectWidth = rect().width() / 2;
for (int y = rect().topLeft().ry(); y < rect().bottomRight().ry(); y++) {
for (int x = rect().topLeft().rx(); x < rect().bottomRight().rx(); x++) {
p.setPen(((x % miniRectWidth) / (miniRectWidth / 2)) == ((y % miniRectWidth) / (miniRectWidth / 2))
? Qt::white
: Qt::black);
p.drawPoint(x, y);
}
}
p.setPen(currColor);
p.setBrush(QBrush(currColor));
p.drawRect(event->rect());
p.end();
}
void AlphaChannelBar::setColor(const QColor& c)
{
if (c == currColor) {
return;
}
currColor = c;
repaint();
emit colorChanged(currColor);
}
void AlphaChannelBar::paintEvent(QPaintEvent* event)
{
QPainter p(this);
QRect barRect = rect();
qreal h, s, v, a;
currColor.getHsvF(&h, &s, &v, &a);
a = 1.0 - a;
const int triangleSize = 10;
barRect.setWidth(barRect.width() - triangleSize);
const int miniRectWidth = barRect.width() / 2;
for (int y = barRect.topLeft().ry(); y < barRect.bottomRight().ry(); y++) {
for (int x = barRect.topLeft().rx(); x < barRect.bottomRight().rx(); x++) {
p.setPen(((x % miniRectWidth) / (miniRectWidth / 2)) == ((y % miniRectWidth) / (miniRectWidth / 2))
? Qt::white
: Qt::black);
p.drawPoint(x, y);
p.setPen(pointToColor(x, y));
p.drawPoint(x, y);
}
}
QRectF triangleRect = QRectF(barRect.right(), a * height() - triangleSize / 2,
triangleSize, triangleSize);
QPainterPath path;
path.moveTo(triangleRect.left(), triangleRect.top() + triangleRect.height() / 2);
path.lineTo(triangleRect.topRight());
path.lineTo(triangleRect.bottomRight());
path.lineTo(triangleRect.left(), triangleRect.top() + triangleRect.height() / 2);
p.fillPath(path, palette().text().color());
p.end();
QWidget::paintEvent(event);
}
QColor AlphaChannelBar::pointToColor(int x, int y) const
{
Q_UNUSED(x)
QColor color = currColor;
qreal h, s, v;
color.getHsvF(&h, &s, &v);
color.setHsvF(h, s, v, 1.0 - qreal(y) / height());
return color;
}
QPoint AlphaChannelBar::colorToPoint(const QColor &) const
{
return QPoint();
}

View File

@ -19,7 +19,7 @@ signals:
void colorChanged(const QColor& color);
public slots:
virtual void setColor(const QColor& color);
virtual void setColor(const QColor& color) = 0;
protected:
QColor currColor;
@ -46,6 +46,8 @@ public:
*/
bool isPickingFromScreen() const;
void setAlphaEnabled(bool enabled);
public slots:
/**
@ -101,8 +103,7 @@ protected:
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
private:
void mouseEvent(QMouseEvent* event);
virtual void mouseEvent(QMouseEvent* event);
/**
* @brief pointToColor converts coordinates on widget to color these coordinates represents.
@ -121,6 +122,8 @@ class ColorShowWidget : public ColorPickWidgetAbstract
public:
explicit ColorShowWidget(QWidget *parent = nullptr);
void setColor(const QColor& c) override;
protected:
void paintEvent(QPaintEvent *event) override;
};
@ -135,6 +138,25 @@ class ColorPickArea : public ColorPickerWidget
public:
explicit ColorPickArea(QWidget *parent = nullptr);
void setColor(const QColor& c) override;
protected:
void paintEvent(QPaintEvent *event) override;
private:
QColor pointToColor(int x, int y) const override;
QPoint colorToPoint(const QColor& color) const override;
};
class AlphaChannelBar : public ColorPickerWidget
{
Q_OBJECT
public:
AlphaChannelBar(QWidget *parent = nullptr) : ColorPickerWidget(parent) {}
void setColor(const QColor& c) override;
protected:
void paintEvent(QPaintEvent *event) override;
@ -154,6 +176,8 @@ class ColorValueBar : public ColorPickerWidget
public:
ColorValueBar(QWidget *parent = nullptr) : ColorPickerWidget(parent) {}
void setColor(const QColor& c) override;
protected:
void paintEvent(QPaintEvent *event) override;

View File

@ -48,6 +48,16 @@
</property>
</widget>
</item>
<item>
<widget class="ColorPickerHelpers::AlphaChannelBar" name="alphaChannelBar" native="true">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -343,6 +353,12 @@
<header>widgets/ColorPicker.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ColorPickerHelpers::AlphaChannelBar</class>
<extends>QWidget</extends>
<header>widgets/ColorPicker.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@ -336,10 +336,10 @@ void ColorSettingsModel::updateTheme()
for (auto it = obj.constBegin(); it != obj.constEnd(); it++) {
QJsonArray rgb = it.value().toArray();
if (rgb.size() != 3) {
if (rgb.size() != 4) {
continue;
}
theme.push_back({it.key(), QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt()), false});
theme.push_back({it.key(), QColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt(), rgb[3].toInt()), false});
}
if (!theme.isEmpty()) {
@ -350,10 +350,10 @@ void ColorSettingsModel::updateTheme()
QJsonDocument ColorSettingsModel::getTheme() const
{
QJsonObject obj;
int r, g, b;
int r, g, b, a;
for (auto &it : theme) {
it.color.getRgb(&r, &g, &b);
obj.insert(it.optionName, QJsonArray({r, g, b}));
it.color.getRgb(&r, &g, &b, &a);
obj.insert(it.optionName, QJsonArray({r, g, b, a}));
}
return QJsonDocument(obj);
}
@ -739,13 +739,13 @@ const QMap<QString, OptionInfo> optionInfoMap__ = {
}
},
{
"linehl", {
"lineHighlight", {
QObject::tr("Selected line background color"),
QObject::tr("Line highlight")
}
},
{
"wordhl", {
"wordHighlight", {
QObject::tr("Background color of selected word"),
QObject::tr("Word higlight")
}

View File

@ -9,6 +9,7 @@
#include "common/SyntaxHighlighter.h"
#include "common/BasicBlockHighlighter.h"
#include <QColorDialog>
#include <QPainter>
#include <QJsonObject>
#include <QJsonArray>
@ -113,6 +114,39 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
contextMenu->addSeparator();
contextMenu->addAction(&actionSyncOffset);
QAction *highlightBB = new QAction(this);
actionUnhighlight.setVisible(false);
highlightBB->setText(tr("Highlight block"));
connect(highlightBB, &QAction::triggered, this, [this]() {
auto bbh = Core()->getBBHighlighter();
RVA currBlockEntry = blockForAddress(this->seekable->getOffset())->entry;
QColor background = disassemblyBackgroundColor;
if (auto block = bbh->getBasicBlock(currBlockEntry)) {
background = block->color;
}
QColor c = QColorDialog::getColor(background, this, QString(),
QColorDialog::DontUseNativeDialog);
if (c.isValid()) {
bbh->highlight(currBlockEntry, c);
}
Config()->colorsUpdated();
});
actionUnhighlight.setText(tr("Unhighlight block"));
connect(&actionUnhighlight, &QAction::triggered, this, [this]() {
auto bbh = Core()->getBBHighlighter();
bbh->clear(blockForAddress(this->seekable->getOffset())->entry);
Config()->colorsUpdated();
});
blockMenu->addAction(highlightBB);
blockMenu->addAction(&actionUnhighlight);
// Include all actions from generic context menu in block specific menu
blockMenu->addSeparator();
blockMenu->addActions(contextMenu->actions());
@ -455,9 +489,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block)
auto bb = Core()->getBBHighlighter()->getBasicBlock(block.entry);
if (bb) {
QColor color(bb->color);
color.setAlphaF(0.5);
p.setBrush(color);
// Add basic block highlighting transparent color
p.drawRect(blockX, blockY,
block.width, block.height);
}
@ -507,7 +539,7 @@ void DisassemblerGraphView::drawBlock(QPainter &p, GraphView::GraphBlock &block)
highlightWidth = block.width - widthBefore - (10 + 2 * padding);
}
QColor selectionColor = ConfigColor("wordhl");
QColor selectionColor = ConfigColor("wordHighlight");
p.fillRect(QRectF(blockX + charWidth * 3 + widthBefore, y, highlightWidth,
charHeight), selectionColor);
@ -714,7 +746,7 @@ void DisassemblerGraphView::colorsUpdatedSlot()
mDisabledBreakpointColor = disassemblyBackgroundColor;
graphNodeColor = ConfigColor("gui.border");
backgroundColor = ConfigColor("gui.background");
disassemblySelectionColor = ConfigColor("linehl");
disassemblySelectionColor = ConfigColor("lineHighlight");
PCSelectionColor = ConfigColor("highlightPC");
jmpColor = ConfigColor("graph.trufae");
@ -947,6 +979,7 @@ void DisassemblerGraphView::blockClicked(GraphView::GraphBlock &block, QMouseEve
blockMenu->setCurHighlightedWord(highlight_token->content);
}
if (event->button() == Qt::RightButton) {
actionUnhighlight.setVisible(Core()->getBBHighlighter()->getBasicBlock(block.entry));
event->accept();
blockMenu->exec(event->globalPos());
}

View File

@ -204,6 +204,7 @@ private:
QColor mDisabledBreakpointColor;
QAction actionExportGraph;
QAction actionUnhighlight;
QAction actionSyncOffset;
QLabel *emptyText = nullptr;

View File

@ -354,7 +354,7 @@ void DisassemblyWidget::highlightCurrentLine()
{
QList<QTextEdit::ExtraSelection> extraSelections;
QColor highlightColor = ConfigColor("linehl");
QColor highlightColor = ConfigColor("lineHighlight");
QColor highlightPCColor = ConfigColor("highlightPC");
// Highlight the current word
@ -600,7 +600,7 @@ QList<QTextEdit::ExtraSelection> DisassemblyWidget::getSameWordsSelections()
QList<QTextEdit::ExtraSelection> selections;
QTextEdit::ExtraSelection highlightSelection;
QTextDocument *document = mDisasTextEdit->document();
QColor highlightWordColor = ConfigColor("wordhl");
QColor highlightWordColor = ConfigColor("wordHighlight");
if (curHighlightedWord.isNull()) {
return QList<QTextEdit::ExtraSelection>();