Added slots for toggling memory highlighting in the HexViewerWidget

This commit is contained in:
Nav
2021-11-11 19:09:58 +00:00
parent 31b9b8d321
commit d3d23e554c
2 changed files with 42 additions and 3 deletions

View File

@@ -43,7 +43,10 @@ HexViewerWidget::HexViewerWidget(
this->toolBar = this->container->findChild<QWidget*>("tool-bar");
this->bottomBar = this->container->findChild<QWidget*>("bottom-bar");
this->refreshButton = this->container->findChild<QToolButton*>("refresh-memory-btn");
this->highlightStackMemoryButton = this->container->findChild<SvgToolButton*>("highlight-stack-memory-btn");
this->highlightFocusedMemoryButton = this->container->findChild<SvgToolButton*>("highlight-focused-memory-btn");
this->toolBar->setContentsMargins(0, 0, 0, 0);
this->toolBar->layout()->setContentsMargins(5, 0, 5, 1);
@@ -67,6 +70,20 @@ HexViewerWidget::HexViewerWidget(
this->byteItemGraphicsScene = this->byteItemGraphicsView->getScene();
byteItemGraphicsViewLayout->insertWidget(0, this->byteItemGraphicsView);
QObject::connect(
this->highlightStackMemoryButton,
&QToolButton::clicked,
this,
&HexViewerWidget::toggleStackMemoryHighlighting
);
QObject::connect(
this->highlightFocusedMemoryButton,
&QToolButton::clicked,
this,
&HexViewerWidget::toggleFocusedMemoryHighlighting
);
QObject::connect(
&insightWorker,
&InsightWorker::targetStateUpdated,
@@ -127,3 +144,21 @@ void HexViewerWidget::onByteWidgetsAdjusted() {
// labelItem->widget()->deleteLater();
// }
}
void HexViewerWidget::toggleStackMemoryHighlighting() {
auto enable = !this->settings.highlightStackMemory;
this->highlightStackMemoryButton->setChecked(enable);
this->settings.highlightStackMemory = enable;
this->byteItemGraphicsScene->update();
}
void HexViewerWidget::toggleFocusedMemoryHighlighting() {
auto enable = !this->settings.highlightFocusedMemory;
this->highlightFocusedMemoryButton->setChecked(enable);
this->settings.highlightFocusedMemory = enable;
this->byteItemGraphicsScene->update();
}

View File

@@ -19,6 +19,8 @@
#include "HexViewerWidgetSettings.hpp"
#include "ByteItemContainerGraphicsView.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp"
namespace Bloom::Widgets
{
class HexViewerWidget: public QWidget
@@ -51,15 +53,17 @@ namespace Bloom::Widgets
ByteItemContainerGraphicsView* byteItemGraphicsView = nullptr;
ByteItemGraphicsScene* byteItemGraphicsScene = nullptr;
QWidget* byteWidgetScrollArea = nullptr;
QWidget* byteWidgetAddressContainer = nullptr;
QVBoxLayout* byteWidgetAddressLayout = nullptr;
QLabel* hoveredAddressLabel = nullptr;
SvgToolButton* highlightStackMemoryButton = nullptr;
SvgToolButton* highlightFocusedMemoryButton = nullptr;
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
private slots:
void onTargetStateChanged(Targets::TargetState newState);
void onByteWidgetsAdjusted();
void toggleStackMemoryHighlighting();
void toggleFocusedMemoryHighlighting();
};
}