From 2674984e365a84d9b4db4fec4bc6be935ac3fd23 Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 20 Oct 2021 01:02:37 +0100 Subject: [PATCH] Added byte widget address label to hex viewer widget --- .../Stylesheets/InsightWindow.qss | 12 ++++++ .../HexViewerWidget/ByteWidgetContainer.cpp | 13 ++++++- .../HexViewerWidget/ByteWidgetContainer.hpp | 5 ++- .../HexViewerWidget/HexViewerWidget.cpp | 7 ++++ .../HexViewerWidget/HexViewerWidget.hpp | 2 + .../UiFiles/HexViewerWidget.ui | 37 ++++++++++++++++++- 6 files changed, 72 insertions(+), 4 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss b/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss index 7991aafd..ef20edc1 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss +++ b/src/Insight/UserInterfaces/InsightWindow/Stylesheets/InsightWindow.qss @@ -349,6 +349,18 @@ QScrollBar::sub-line:vertical { #hex-viewer-container #tool-bar, #hex-viewer-container #search-bar { border-bottom: 1px solid #2F2F2D; + +#hex-viewer-container #bottom-bar { + border-top: 1px solid #41423f; +} + +#hex-viewer-container #bottom-bar QLabel { + font-size: 13px; + color: rgba(175, 177, 179, 0.72); +} + +#hex-viewer-container #bottom-bar QLabel:disabled { + color: rgba(175, 177, 179, 0.3); } #hex-viewer-container #tool-bar QToolButton { diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteWidgetContainer.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteWidgetContainer.cpp index 92bc5837..7ad9f268 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteWidgetContainer.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteWidgetContainer.cpp @@ -14,8 +14,13 @@ using Bloom::Targets::TargetMemoryDescriptor; ByteWidgetContainer::ByteWidgetContainer( const TargetMemoryDescriptor& targetMemoryDescriptor, InsightWorker& insightWorker, + QLabel* hoveredAddressLabel, QWidget* parent -): QWidget(parent), targetMemoryDescriptor(targetMemoryDescriptor), insightWorker(insightWorker), parent(parent) { +): QWidget(parent), +targetMemoryDescriptor(targetMemoryDescriptor), +insightWorker(insightWorker), +hoveredAddressLabel(hoveredAddressLabel), +parent(parent) { this->setObjectName("byte-widget-container"); this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Ignored); @@ -126,6 +131,10 @@ void ByteWidgetContainer::onTargetStateChanged(Targets::TargetState newState) { void ByteWidgetContainer::onByteWidgetEnter(ByteWidget* widget) { this->hoveredByteWidget = widget; + this->hoveredAddressLabel->setText( + "Relative Address (Absolute Address): " + widget->relativeAddressHex + " (" + widget->addressHex + ")" + ); + if (!this->byteWidgetsByRowIndex.empty()) { for (auto& byteWidget : this->byteWidgetsByColumnIndex.at(widget->currentColumnIndex)) { byteWidget->update(); @@ -140,6 +149,8 @@ void ByteWidgetContainer::onByteWidgetEnter(ByteWidget* widget) { void ByteWidgetContainer::onByteWidgetLeave(ByteWidget* widget) { this->hoveredByteWidget = std::nullopt; + this->hoveredAddressLabel->setText("Relative Address (Absolute Address):"); + if (!this->byteWidgetsByRowIndex.empty()) { for (auto& byteWidget : this->byteWidgetsByColumnIndex.at(widget->currentColumnIndex)) { byteWidget->update(); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteWidgetContainer.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteWidgetContainer.hpp index 86cd354b..d96964d9 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteWidgetContainer.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteWidgetContainer.hpp @@ -34,6 +34,7 @@ namespace Bloom::Widgets ByteWidgetContainer( const Targets::TargetMemoryDescriptor& targetMemoryDescriptor, InsightWorker& insightWorker, + QLabel* hoveredAddressLabel, QWidget* parent ); @@ -47,11 +48,11 @@ namespace Bloom::Widgets private: const Targets::TargetMemoryDescriptor& targetMemoryDescriptor; + Targets::TargetState targetState = Targets::TargetState::UNKNOWN; InsightWorker& insightWorker; QWidget* parent = nullptr; - - Targets::TargetState targetState = Targets::TargetState::UNKNOWN; + QLabel* hoveredAddressLabel = nullptr; void adjustByteWidgets(); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp index 747d351c..852aa30d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp @@ -42,11 +42,17 @@ HexViewerWidget::HexViewerWidget( this->container->setContentsMargins(0, 0, 0, 0); this->toolBar = this->container->findChild("tool-bar"); + this->bottomBar = this->container->findChild("bottom-bar"); this->refreshButton = this->container->findChild("refresh-memory-btn"); this->toolBar->setContentsMargins(0, 0, 0, 0); this->toolBar->layout()->setContentsMargins(5, 0, 5, 0); + this->bottomBar->setContentsMargins(0, 0, 0, 0); + this->bottomBar->layout()->setContentsMargins(5, 0, 5, 0); + + this->hoveredAddressLabel = this->bottomBar->findChild("byte-address-label"); + this->byteWidgetScrollArea = this->container->findChild("byte-widget-scroll-area"); auto byteWidgetScrollAreaWidgetContainer = this->byteWidgetScrollArea->findChild( "byte-widget-scroll-area-container" @@ -58,6 +64,7 @@ HexViewerWidget::HexViewerWidget( this->byteWidgetContainer = new ByteWidgetContainer( targetMemoryDescriptor, insightWorker, + this->hoveredAddressLabel, byteWidgetScrollAreaHorizontalLayout->parentWidget() ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp index 0c6c327a..fb7182fb 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp @@ -44,11 +44,13 @@ namespace Bloom::Widgets QWidget* container = nullptr; QWidget* toolBar = nullptr; + QWidget* bottomBar = nullptr; ByteWidgetContainer* byteWidgetContainer = nullptr; QWidget* byteWidgetScrollArea = nullptr; QWidget* byteWidgetAddressContainer = nullptr; QVBoxLayout* byteWidgetAddressLayout = nullptr; + QLabel* hoveredAddressLabel = nullptr; Targets::TargetState targetState = Targets::TargetState::UNKNOWN; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/UiFiles/HexViewerWidget.ui b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/UiFiles/HexViewerWidget.ui index edb1b5e0..1857f0f6 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/UiFiles/HexViewerWidget.ui +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/UiFiles/HexViewerWidget.ui @@ -113,7 +113,42 @@ - + + + + 27 + + + 27 + + + + + + + 3 + + + 0 + + + + + Relative Address (Absolute Address): + + + + + + + Qt::Horizontal + + + + + + +