Made addressLabelType changeable via context menu
This commit is contained in:
@@ -454,3 +454,14 @@ QScrollBar::sub-line:vertical {
|
|||||||
width: 12px;
|
width: 12px;
|
||||||
margin: 1px 3px 1px 0px;
|
margin: 1px 3px 1px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#hex-viewer-container #byte-item-address-container-context-menu.QMenu,
|
||||||
|
#hex-viewer-container #byte-item-address-container-context-menu QMenu {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#hex-viewer-container #byte-item-address-container-context-menu.QMenu::item,
|
||||||
|
#hex-viewer-container #byte-item-address-container-context-menu QMenu::item {
|
||||||
|
padding-left: 10px;
|
||||||
|
min-width: 150px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -47,6 +47,12 @@ namespace Bloom::Widgets
|
|||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ByteAddressContainer::invalidateChildItemCaches() {
|
||||||
|
for (auto& [rowIndex, addressItem] : this->addressItemsByRowIndex) {
|
||||||
|
addressItem->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ByteAddressContainer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
void ByteAddressContainer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||||
static const auto backgroundColor = QColor(0x35, 0x36, 0x33);
|
static const auto backgroundColor = QColor(0x35, 0x36, 0x33);
|
||||||
static const auto borderColor = QColor(0x41, 0x42, 0x3F);
|
static const auto borderColor = QColor(0x41, 0x42, 0x3F);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace Bloom::Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
void adjustAddressLabels(const std::map<std::size_t, std::vector<ByteItem*>>& byteItemsByRowIndex);
|
void adjustAddressLabels(const std::map<std::size_t, std::vector<ByteItem*>>& byteItemsByRowIndex);
|
||||||
|
void invalidateChildItemCaches();
|
||||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
|
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "ByteItemGraphicsScene.hpp"
|
#include "ByteItemGraphicsScene.hpp"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
#include "src/Insight/InsightSignals.hpp"
|
#include "src/Insight/InsightSignals.hpp"
|
||||||
|
|
||||||
@@ -52,6 +53,11 @@ namespace Bloom::Widgets
|
|||||||
this->addItem(byteWidget);
|
this->addItem(byteWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->displayRelativeAddressAction->setCheckable(true);
|
||||||
|
this->displayAbsoluteAddressAction->setCheckable(true);
|
||||||
|
|
||||||
|
this->setAddressType(this->settings.addressLabelType);
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
InsightSignals::instance(),
|
InsightSignals::instance(),
|
||||||
&InsightSignals::targetStateUpdated,
|
&InsightSignals::targetStateUpdated,
|
||||||
@@ -59,6 +65,23 @@ namespace Bloom::Widgets
|
|||||||
&ByteItemGraphicsScene::onTargetStateChanged
|
&ByteItemGraphicsScene::onTargetStateChanged
|
||||||
);
|
);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
this->displayRelativeAddressAction,
|
||||||
|
&QAction::triggered,
|
||||||
|
this,
|
||||||
|
[this] {
|
||||||
|
this->setAddressType(AddressType::RELATIVE);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
this->displayAbsoluteAddressAction,
|
||||||
|
&QAction::triggered,
|
||||||
|
this,
|
||||||
|
[this] {
|
||||||
|
this->setAddressType(AddressType::ABSOLUTE);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ByteItemGraphicsScene::updateValues(const Targets::TargetMemoryBuffer& buffer) {
|
void ByteItemGraphicsScene::updateValues(const Targets::TargetMemoryBuffer& buffer) {
|
||||||
@@ -389,6 +412,21 @@ namespace Bloom::Widgets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ByteItemGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) {
|
||||||
|
if (event->scenePos().x() <= ByteAddressContainer::WIDTH) {
|
||||||
|
auto* menu = new QMenu(this->getParent());
|
||||||
|
menu->setObjectName("byte-item-address-container-context-menu");
|
||||||
|
|
||||||
|
auto* addressTypeMenu = new QMenu("Address Type", menu);
|
||||||
|
addressTypeMenu->addAction(this->displayAbsoluteAddressAction);
|
||||||
|
addressTypeMenu->addAction(this->displayRelativeAddressAction);
|
||||||
|
menu->addMenu(addressTypeMenu);
|
||||||
|
|
||||||
|
menu->exec(event->screenPos());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ByteItemGraphicsScene::updateAnnotationValues(const Targets::TargetMemoryBuffer& buffer) {
|
void ByteItemGraphicsScene::updateAnnotationValues(const Targets::TargetMemoryBuffer& buffer) {
|
||||||
const auto memoryStartAddress = this->targetMemoryDescriptor.addressRange.startAddress;
|
const auto memoryStartAddress = this->targetMemoryDescriptor.addressRange.startAddress;
|
||||||
for (auto* valueAnnotationItem : this->valueAnnotationItems) {
|
for (auto* valueAnnotationItem : this->valueAnnotationItems) {
|
||||||
@@ -660,4 +698,13 @@ namespace Bloom::Widgets
|
|||||||
this->selectByteItem(byteItem);
|
this->selectByteItem(byteItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ByteItemGraphicsScene::setAddressType(AddressType type) {
|
||||||
|
this->settings.addressLabelType = type;
|
||||||
|
|
||||||
|
this->displayRelativeAddressAction->setChecked(this->settings.addressLabelType == AddressType::RELATIVE);
|
||||||
|
this->displayAbsoluteAddressAction->setChecked(this->settings.addressLabelType == AddressType::ABSOLUTE);
|
||||||
|
|
||||||
|
this->byteAddressContainer->invalidateChildItemCaches();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,12 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QGraphicsSceneMouseEvent>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QGraphicsSceneWheelEvent>
|
#include <QGraphicsSceneWheelEvent>
|
||||||
|
#include <QGraphicsSceneContextMenuEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <QGraphicsRectItem>
|
#include <QGraphicsRectItem>
|
||||||
#include <QPointF>
|
#include <QPointF>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
#include "src/Targets/TargetMemory.hpp"
|
#include "src/Targets/TargetMemory.hpp"
|
||||||
#include "src/Targets/TargetState.hpp"
|
#include "src/Targets/TargetState.hpp"
|
||||||
@@ -32,6 +34,7 @@
|
|||||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp"
|
||||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
|
||||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
|
||||||
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/AddressType.hpp"
|
||||||
|
|
||||||
namespace Bloom::Widgets
|
namespace Bloom::Widgets
|
||||||
{
|
{
|
||||||
@@ -67,6 +70,7 @@ namespace Bloom::Widgets
|
|||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent* mouseEvent) override;
|
void mouseMoveEvent(QGraphicsSceneMouseEvent* mouseEvent) override;
|
||||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent* mouseEvent) override;
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent* mouseEvent) override;
|
||||||
void keyPressEvent(QKeyEvent* keyEvent) override;
|
void keyPressEvent(QKeyEvent* keyEvent) override;
|
||||||
|
void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
||||||
@@ -104,6 +108,10 @@ namespace Bloom::Widgets
|
|||||||
std::optional<QPointF> rubberBandInitPoint = std::nullopt;
|
std::optional<QPointF> rubberBandInitPoint = std::nullopt;
|
||||||
|
|
||||||
|
|
||||||
|
// Address label container context menu actions
|
||||||
|
QAction* displayRelativeAddressAction = new QAction("Relative", this);
|
||||||
|
QAction* displayAbsoluteAddressAction = new QAction("Absolute", this);
|
||||||
|
|
||||||
QGraphicsView* getParent() const {
|
QGraphicsView* getParent() const {
|
||||||
return dynamic_cast<QGraphicsView*>(this->parent());
|
return dynamic_cast<QGraphicsView*>(this->parent());
|
||||||
}
|
}
|
||||||
@@ -133,5 +141,6 @@ namespace Bloom::Widgets
|
|||||||
void toggleByteItemSelection(ByteItem* byteItem);
|
void toggleByteItemSelection(ByteItem* byteItem);
|
||||||
void clearByteItemSelection();
|
void clearByteItemSelection();
|
||||||
void selectAllByteItems();
|
void selectAllByteItems();
|
||||||
|
void setAddressType(AddressType type);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user