Added byte widget address label to hex viewer widget

This commit is contained in:
Nav
2021-10-20 01:02:37 +01:00
parent 8433a87fbf
commit 2674984e36
6 changed files with 72 additions and 4 deletions

View File

@@ -349,6 +349,18 @@ QScrollBar::sub-line:vertical {
#hex-viewer-container #tool-bar, #hex-viewer-container #tool-bar,
#hex-viewer-container #search-bar { #hex-viewer-container #search-bar {
border-bottom: 1px solid #2F2F2D; 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 { #hex-viewer-container #tool-bar QToolButton {

View File

@@ -14,8 +14,13 @@ using Bloom::Targets::TargetMemoryDescriptor;
ByteWidgetContainer::ByteWidgetContainer( ByteWidgetContainer::ByteWidgetContainer(
const TargetMemoryDescriptor& targetMemoryDescriptor, const TargetMemoryDescriptor& targetMemoryDescriptor,
InsightWorker& insightWorker, InsightWorker& insightWorker,
QLabel* hoveredAddressLabel,
QWidget* parent 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->setObjectName("byte-widget-container");
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Ignored); this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Ignored);
@@ -126,6 +131,10 @@ void ByteWidgetContainer::onTargetStateChanged(Targets::TargetState newState) {
void ByteWidgetContainer::onByteWidgetEnter(ByteWidget* widget) { void ByteWidgetContainer::onByteWidgetEnter(ByteWidget* widget) {
this->hoveredByteWidget = widget; this->hoveredByteWidget = widget;
this->hoveredAddressLabel->setText(
"Relative Address (Absolute Address): " + widget->relativeAddressHex + " (" + widget->addressHex + ")"
);
if (!this->byteWidgetsByRowIndex.empty()) { if (!this->byteWidgetsByRowIndex.empty()) {
for (auto& byteWidget : this->byteWidgetsByColumnIndex.at(widget->currentColumnIndex)) { for (auto& byteWidget : this->byteWidgetsByColumnIndex.at(widget->currentColumnIndex)) {
byteWidget->update(); byteWidget->update();
@@ -140,6 +149,8 @@ void ByteWidgetContainer::onByteWidgetEnter(ByteWidget* widget) {
void ByteWidgetContainer::onByteWidgetLeave(ByteWidget* widget) { void ByteWidgetContainer::onByteWidgetLeave(ByteWidget* widget) {
this->hoveredByteWidget = std::nullopt; this->hoveredByteWidget = std::nullopt;
this->hoveredAddressLabel->setText("Relative Address (Absolute Address):");
if (!this->byteWidgetsByRowIndex.empty()) { if (!this->byteWidgetsByRowIndex.empty()) {
for (auto& byteWidget : this->byteWidgetsByColumnIndex.at(widget->currentColumnIndex)) { for (auto& byteWidget : this->byteWidgetsByColumnIndex.at(widget->currentColumnIndex)) {
byteWidget->update(); byteWidget->update();

View File

@@ -34,6 +34,7 @@ namespace Bloom::Widgets
ByteWidgetContainer( ByteWidgetContainer(
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor, const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
InsightWorker& insightWorker, InsightWorker& insightWorker,
QLabel* hoveredAddressLabel,
QWidget* parent QWidget* parent
); );
@@ -47,11 +48,11 @@ namespace Bloom::Widgets
private: private:
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor; const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
InsightWorker& insightWorker; InsightWorker& insightWorker;
QWidget* parent = nullptr; QWidget* parent = nullptr;
QLabel* hoveredAddressLabel = nullptr;
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
void adjustByteWidgets(); void adjustByteWidgets();

View File

@@ -42,11 +42,17 @@ HexViewerWidget::HexViewerWidget(
this->container->setContentsMargins(0, 0, 0, 0); this->container->setContentsMargins(0, 0, 0, 0);
this->toolBar = this->container->findChild<QWidget*>("tool-bar"); 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->refreshButton = this->container->findChild<QToolButton*>("refresh-memory-btn");
this->toolBar->setContentsMargins(0, 0, 0, 0); this->toolBar->setContentsMargins(0, 0, 0, 0);
this->toolBar->layout()->setContentsMargins(5, 0, 5, 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<QLabel*>("byte-address-label");
this->byteWidgetScrollArea = this->container->findChild<QScrollArea*>("byte-widget-scroll-area"); this->byteWidgetScrollArea = this->container->findChild<QScrollArea*>("byte-widget-scroll-area");
auto byteWidgetScrollAreaWidgetContainer = this->byteWidgetScrollArea->findChild<QWidget*>( auto byteWidgetScrollAreaWidgetContainer = this->byteWidgetScrollArea->findChild<QWidget*>(
"byte-widget-scroll-area-container" "byte-widget-scroll-area-container"
@@ -58,6 +64,7 @@ HexViewerWidget::HexViewerWidget(
this->byteWidgetContainer = new ByteWidgetContainer( this->byteWidgetContainer = new ByteWidgetContainer(
targetMemoryDescriptor, targetMemoryDescriptor,
insightWorker, insightWorker,
this->hoveredAddressLabel,
byteWidgetScrollAreaHorizontalLayout->parentWidget() byteWidgetScrollAreaHorizontalLayout->parentWidget()
); );

View File

@@ -44,11 +44,13 @@ namespace Bloom::Widgets
QWidget* container = nullptr; QWidget* container = nullptr;
QWidget* toolBar = nullptr; QWidget* toolBar = nullptr;
QWidget* bottomBar = nullptr;
ByteWidgetContainer* byteWidgetContainer = nullptr; ByteWidgetContainer* byteWidgetContainer = nullptr;
QWidget* byteWidgetScrollArea = nullptr; QWidget* byteWidgetScrollArea = nullptr;
QWidget* byteWidgetAddressContainer = nullptr; QWidget* byteWidgetAddressContainer = nullptr;
QVBoxLayout* byteWidgetAddressLayout = nullptr; QVBoxLayout* byteWidgetAddressLayout = nullptr;
QLabel* hoveredAddressLabel = nullptr;
Targets::TargetState targetState = Targets::TargetState::UNKNOWN; Targets::TargetState targetState = Targets::TargetState::UNKNOWN;

View File

@@ -113,7 +113,42 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<!-- <item>--> <item>
<widget class="QWidget" name="bottom-bar">
<property name="minimumHeight">
<number>27</number>
</property>
<property name="maximumHeight">
<number>27</number>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"/>
</property>
<layout class="QHBoxLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="byte-address-label">
<property name="text">
<string>Relative Address (Absolute Address):</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignTop">
<spacer name="horizontal-spacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<!-- <item>-->
<!-- <spacer name="vertical-spacer">--> <!-- <spacer name="vertical-spacer">-->
<!-- <property name="orientation">--> <!-- <property name="orientation">-->
<!-- <enum>Qt::Vertical</enum>--> <!-- <enum>Qt::Vertical</enum>-->