From d3d23e554c7a7b7b6779518b30c0525f26e46800 Mon Sep 17 00:00:00 2001 From: Nav Date: Thu, 11 Nov 2021 19:09:58 +0000 Subject: [PATCH] Added slots for toggling memory highlighting in the HexViewerWidget --- .../HexViewerWidget/HexViewerWidget.cpp | 35 +++++++++++++++++++ .../HexViewerWidget/HexViewerWidget.hpp | 10 ++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp index f1748439..f687aedf 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp @@ -43,7 +43,10 @@ HexViewerWidget::HexViewerWidget( this->toolBar = this->container->findChild("tool-bar"); this->bottomBar = this->container->findChild("bottom-bar"); + this->refreshButton = this->container->findChild("refresh-memory-btn"); + this->highlightStackMemoryButton = this->container->findChild("highlight-stack-memory-btn"); + this->highlightFocusedMemoryButton = this->container->findChild("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(); +} diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp index 543763bd..849a18d2 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp @@ -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(); }; }