Used a signal for updating hovered address label in hex viewer
This commit is contained in:
@@ -84,7 +84,6 @@ namespace Bloom::Widgets
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->settings,
|
||||
this->hoveredAddressLabel,
|
||||
this->container
|
||||
);
|
||||
|
||||
@@ -181,6 +180,14 @@ namespace Bloom::Widgets
|
||||
this,
|
||||
[this] {
|
||||
this->byteItemGraphicsScene = this->byteItemGraphicsView->getScene();
|
||||
|
||||
QObject::connect(
|
||||
this->byteItemGraphicsScene,
|
||||
&ItemGraphicsScene::hoveredAddress,
|
||||
this,
|
||||
&HexViewerWidget::onHoveredAddress
|
||||
);
|
||||
|
||||
this->loadingHexViewerLabel->hide();
|
||||
this->byteItemGraphicsView->show();
|
||||
|
||||
@@ -288,4 +295,26 @@ namespace Bloom::Widgets
|
||||
|
||||
this->byteItemGraphicsScene->selectByteItems({});
|
||||
}
|
||||
|
||||
void HexViewerWidget::onHoveredAddress(const std::optional<Targets::TargetMemoryAddress>& address) {
|
||||
if (!address.has_value()) {
|
||||
this->hoveredAddressLabel->setText("Relative address / Absolute address:");
|
||||
return;
|
||||
}
|
||||
|
||||
const auto addressHex = "0x" + QString::number(
|
||||
*address,
|
||||
16
|
||||
).rightJustified(8, '0').toUpper();
|
||||
|
||||
const auto relativeAddress = *address - this->targetMemoryDescriptor.addressRange.startAddress;
|
||||
const auto relativeAddressHex = "0x" + QString::number(
|
||||
relativeAddress,
|
||||
16
|
||||
).rightJustified(8, '0').toUpper();
|
||||
|
||||
this->hoveredAddressLabel->setText(
|
||||
"Relative address / Absolute address: " + relativeAddressHex + " / " + addressHex
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <QResizeEvent>
|
||||
#include <QShowEvent>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
@@ -82,5 +83,6 @@ namespace Bloom::Widgets
|
||||
void setAnnotationsEnabled(bool enabled);
|
||||
void setDisplayAsciiEnabled(bool enabled);
|
||||
void onGoToAddressInputChanged();
|
||||
void onHoveredAddress(const std::optional<Targets::TargetMemoryAddress>& address);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace Bloom::Widgets
|
||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
HexViewerWidgetSettings& settings,
|
||||
Label* hoveredAddressLabel,
|
||||
QGraphicsView* parent
|
||||
)
|
||||
: state(
|
||||
@@ -31,7 +30,6 @@ namespace Bloom::Widgets
|
||||
)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
, hoveredAddressLabel(hoveredAddressLabel)
|
||||
, parent(parent)
|
||||
, QGraphicsScene(parent)
|
||||
{
|
||||
@@ -602,21 +600,6 @@ namespace Bloom::Widgets
|
||||
|
||||
this->state.hoveredByteItem = &byteItem;
|
||||
|
||||
const auto addressHex = "0x" + QString::number(
|
||||
byteItem.startAddress,
|
||||
16
|
||||
).rightJustified(8, '0').toUpper();
|
||||
|
||||
const auto relativeAddress = byteItem.startAddress - this->state.memoryDescriptor.addressRange.startAddress;
|
||||
const auto relativeAddressHex = "0x" + QString::number(
|
||||
relativeAddress,
|
||||
16
|
||||
).rightJustified(8, '0').toUpper();
|
||||
|
||||
this->hoveredAddressLabel->setText(
|
||||
"Relative Address / Absolute Address: " + relativeAddressHex + " / " + addressHex
|
||||
);
|
||||
|
||||
if (this->state.settings.highlightHoveredRowAndCol) {
|
||||
const auto byteItemScenePos = byteItem.position();
|
||||
this->hoverRectX->setPos(0, byteItemScenePos.y());
|
||||
@@ -630,6 +613,7 @@ namespace Bloom::Widgets
|
||||
}
|
||||
|
||||
this->update();
|
||||
emit this->hoveredAddress(byteItem.startAddress);
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::onByteItemLeave() {
|
||||
@@ -637,11 +621,11 @@ namespace Bloom::Widgets
|
||||
this->state.hoveredByteItem = nullptr;
|
||||
}
|
||||
|
||||
this->hoveredAddressLabel->setText("Relative Address / Absolute Address:");
|
||||
|
||||
this->hoverRectX->setVisible(false);
|
||||
this->hoverRectY->setVisible(false);
|
||||
this->update();
|
||||
|
||||
emit this->hoveredAddress(std::nullopt);
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::clearSelectionRectItem() {
|
||||
|
||||
@@ -48,7 +48,6 @@ namespace Bloom::Widgets
|
||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
HexViewerWidgetSettings& settings,
|
||||
Label* hoveredAddressLabel,
|
||||
QGraphicsView* parent
|
||||
);
|
||||
|
||||
@@ -64,6 +63,7 @@ namespace Bloom::Widgets
|
||||
|
||||
signals:
|
||||
void ready();
|
||||
void hoveredAddress(const std::optional<Targets::TargetMemoryAddress>& address);
|
||||
|
||||
protected:
|
||||
bool event(QEvent* event) override;
|
||||
@@ -96,7 +96,6 @@ namespace Bloom::Widgets
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
QGraphicsView* parent = nullptr;
|
||||
Label* hoveredAddressLabel = nullptr;
|
||||
|
||||
ByteAddressContainer* byteAddressContainer = nullptr;
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace Bloom::Widgets
|
||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
HexViewerWidgetSettings& settings,
|
||||
Label* hoveredAddressLabel,
|
||||
QWidget* parent
|
||||
)
|
||||
: QGraphicsView(parent)
|
||||
@@ -34,7 +33,6 @@ namespace Bloom::Widgets
|
||||
focusedMemoryRegions,
|
||||
excludedMemoryRegions,
|
||||
settings,
|
||||
hoveredAddressLabel,
|
||||
this
|
||||
);
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace Bloom::Widgets
|
||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
HexViewerWidgetSettings& settings,
|
||||
Label* hoveredAddressLabel,
|
||||
QWidget* parent
|
||||
);
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>3</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
@@ -215,7 +215,7 @@
|
||||
<item>
|
||||
<widget class="Label" name="byte-address-label">
|
||||
<property name="text">
|
||||
<string>Relative Address / Absolute Address:</string>
|
||||
<string>Relative address / Absolute address:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user