Go-to-address function in hex viewer
This commit is contained in:
@@ -421,6 +421,26 @@ QScrollBar::sub-line:vertical {
|
|||||||
qproperty-buttonHeight: 21;
|
qproperty-buttonHeight: 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#hex-viewer-container #tool-bar #go-to-address-input {
|
||||||
|
min-width: 100px;
|
||||||
|
max-width: 100px;
|
||||||
|
min-height: 15px;
|
||||||
|
max-height: 15px;
|
||||||
|
border: none;
|
||||||
|
background-color: transparent;
|
||||||
|
font-size: 13px;
|
||||||
|
color: #848486;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hex-viewer-container #tool-bar #go-to-address-input:focus {
|
||||||
|
/*background-color: #2f312e;*/
|
||||||
|
color: #afb1b3;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hex-viewer-container #tool-bar #go-to-address-input:disabled {
|
||||||
|
color: #686767;
|
||||||
|
}
|
||||||
|
|
||||||
#hex-viewer-container QScrollArea,
|
#hex-viewer-container QScrollArea,
|
||||||
#hex-viewer-container #graphics-view-container,
|
#hex-viewer-container #graphics-view-container,
|
||||||
#hex-viewer-container #graphics-view-container #graphics-view {
|
#hex-viewer-container #graphics-view-container #graphics-view {
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ ByteItemContainerGraphicsView::ByteItemContainerGraphicsView(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ByteItemContainerGraphicsView::scrollToByteItemAtAddress(std::uint32_t address) {
|
||||||
|
this->centerOn(this->scene->getByteItemPositionByAddress(address));
|
||||||
|
}
|
||||||
|
|
||||||
bool ByteItemContainerGraphicsView::event(QEvent* event) {
|
bool ByteItemContainerGraphicsView::event(QEvent* event) {
|
||||||
const auto eventType = event->type();
|
const auto eventType = event->type();
|
||||||
if (eventType == QEvent::Type::EnabledChange) {
|
if (eventType == QEvent::Type::EnabledChange) {
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ namespace Bloom::Widgets
|
|||||||
return this->scene;
|
return this->scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scrollToByteItemAtAddress(std::uint32_t address);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent* event) override;
|
bool event(QEvent* event) override;
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|||||||
@@ -221,6 +221,14 @@ void ByteItemGraphicsScene::invalidateChildItemCaches() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPointF ByteItemGraphicsScene::getByteItemPositionByAddress(std::uint32_t address) {
|
||||||
|
if (this->byteItemsByAddress.contains(address)) {
|
||||||
|
return this->byteItemsByAddress.at(address)->pos();
|
||||||
|
}
|
||||||
|
|
||||||
|
return QPointF();
|
||||||
|
}
|
||||||
|
|
||||||
bool ByteItemGraphicsScene::event(QEvent* event) {
|
bool ByteItemGraphicsScene::event(QEvent* event) {
|
||||||
if (event->type() == QEvent::Type::GraphicsSceneLeave && this->hoveredByteWidget.has_value()) {
|
if (event->type() == QEvent::Type::GraphicsSceneLeave && this->hoveredByteWidget.has_value()) {
|
||||||
this->onByteWidgetLeave();
|
this->onByteWidgetLeave();
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ namespace Bloom::Widgets
|
|||||||
void adjustSize(bool forced = false);
|
void adjustSize(bool forced = false);
|
||||||
void setEnabled(bool enabled);
|
void setEnabled(bool enabled);
|
||||||
void invalidateChildItemCaches();
|
void invalidateChildItemCaches();
|
||||||
|
QPointF getByteItemPositionByAddress(std::uint32_t address);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void byteWidgetsAdjusted();
|
void byteWidgetsAdjusted();
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ HexViewerWidget::HexViewerWidget(
|
|||||||
this->displayAnnotationsButton = this->container->findChild<SvgToolButton*>("display-annotations-btn");
|
this->displayAnnotationsButton = this->container->findChild<SvgToolButton*>("display-annotations-btn");
|
||||||
this->displayAsciiButton = this->container->findChild<SvgToolButton*>("display-ascii-btn");
|
this->displayAsciiButton = this->container->findChild<SvgToolButton*>("display-ascii-btn");
|
||||||
|
|
||||||
|
this->goToAddressInput = this->container->findChild<TextInput*>("go-to-address-input");
|
||||||
|
|
||||||
this->toolBar->setContentsMargins(0, 0, 0, 0);
|
this->toolBar->setContentsMargins(0, 0, 0, 0);
|
||||||
this->toolBar->layout()->setContentsMargins(5, 0, 5, 1);
|
this->toolBar->layout()->setContentsMargins(5, 0, 5, 1);
|
||||||
|
|
||||||
@@ -137,6 +139,20 @@ HexViewerWidget::HexViewerWidget(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
this->goToAddressInput,
|
||||||
|
&QLineEdit::textEdited,
|
||||||
|
this,
|
||||||
|
&HexViewerWidget::onGoToAddressInputChanged
|
||||||
|
);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
this->goToAddressInput,
|
||||||
|
&TextInput::focusChanged,
|
||||||
|
this,
|
||||||
|
&HexViewerWidget::onGoToAddressInputChanged
|
||||||
|
);
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
&insightWorker,
|
&insightWorker,
|
||||||
&InsightWorker::targetStateUpdated,
|
&InsightWorker::targetStateUpdated,
|
||||||
@@ -211,3 +227,18 @@ void HexViewerWidget::setDisplayAsciiEnabled(bool enabled) {
|
|||||||
|
|
||||||
this->byteItemGraphicsScene->invalidateChildItemCaches();
|
this->byteItemGraphicsScene->invalidateChildItemCaches();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HexViewerWidget::onGoToAddressInputChanged() {
|
||||||
|
auto addressConversionOk = false;
|
||||||
|
const auto address = this->goToAddressInput->text().toUInt(&addressConversionOk, 16);
|
||||||
|
|
||||||
|
const auto& memoryAddressRange = this->targetMemoryDescriptor.addressRange;
|
||||||
|
|
||||||
|
if (addressConversionOk && memoryAddressRange.contains(address) && this->goToAddressInput->hasFocus()) {
|
||||||
|
this->byteItemGraphicsScene->setHighlightedAddresses({address});
|
||||||
|
this->byteItemGraphicsView->scrollToByteItemAtAddress(address);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->byteItemGraphicsScene->setHighlightedAddresses({});
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
||||||
|
|
||||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp"
|
||||||
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.hpp"
|
||||||
|
|
||||||
#include "HexViewerWidgetSettings.hpp"
|
#include "HexViewerWidgetSettings.hpp"
|
||||||
#include "ByteItemContainerGraphicsView.hpp"
|
#include "ByteItemContainerGraphicsView.hpp"
|
||||||
@@ -70,6 +71,8 @@ namespace Bloom::Widgets
|
|||||||
SvgToolButton* displayAnnotationsButton = nullptr;
|
SvgToolButton* displayAnnotationsButton = nullptr;
|
||||||
SvgToolButton* displayAsciiButton = nullptr;
|
SvgToolButton* displayAsciiButton = nullptr;
|
||||||
|
|
||||||
|
TextInput* goToAddressInput = nullptr;
|
||||||
|
|
||||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||||
|
|
||||||
void onTargetStateChanged(Targets::TargetState newState);
|
void onTargetStateChanged(Targets::TargetState newState);
|
||||||
@@ -78,5 +81,6 @@ namespace Bloom::Widgets
|
|||||||
void setFocusedMemoryHighlightingEnabled(bool enabled);
|
void setFocusedMemoryHighlightingEnabled(bool enabled);
|
||||||
void setAnnotationsEnabled(bool enabled);
|
void setAnnotationsEnabled(bool enabled);
|
||||||
void setDisplayAsciiEnabled(bool enabled);
|
void setDisplayAsciiEnabled(bool enabled);
|
||||||
|
void onGoToAddressInputChanged();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,6 +162,28 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="separator"/>
|
<widget class="QFrame" name="separator"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontal-spacer">
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>1</width>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="TextInput" name="go-to-address-input">
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Go to address...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="separator"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontal-spacer">
|
<spacer name="horizontal-spacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
|||||||
Reference in New Issue
Block a user