Added selection count label to hex viewer
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <QFile>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLocale>
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
|
||||
#include "src/Insight/InsightSignals.hpp"
|
||||
@@ -75,6 +76,7 @@ namespace Bloom::Widgets
|
||||
this->bottomBar->layout()->setContentsMargins(5, 0, 5, 0);
|
||||
|
||||
this->hoveredAddressLabel = this->bottomBar->findChild<Label*>("byte-address-label");
|
||||
this->selectionCountLabel = this->bottomBar->findChild<Label*>("selection-count-label");
|
||||
|
||||
this->loadingHexViewerLabel = this->container->findChild<Label*>("loading-hex-viewer-label");
|
||||
|
||||
@@ -188,6 +190,13 @@ namespace Bloom::Widgets
|
||||
&HexViewerWidget::onHoveredAddress
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
this->byteItemGraphicsScene,
|
||||
&ItemGraphicsScene::selectionChanged,
|
||||
this,
|
||||
&HexViewerWidget::onByteSelectionChanged
|
||||
);
|
||||
|
||||
this->loadingHexViewerLabel->hide();
|
||||
this->byteItemGraphicsView->show();
|
||||
|
||||
@@ -317,4 +326,17 @@ namespace Bloom::Widgets
|
||||
"Relative address / Absolute address: " + relativeAddressHex + " / " + addressHex
|
||||
);
|
||||
}
|
||||
|
||||
void HexViewerWidget::onByteSelectionChanged(Targets::TargetMemorySize selectionCount) {
|
||||
if (selectionCount == 0) {
|
||||
this->selectionCountLabel->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
this->selectionCountLabel->setText(
|
||||
QLocale(QLocale::English).toString(selectionCount) + " " + QString(selectionCount == 1 ? "byte" : "bytes")
|
||||
+ " selected"
|
||||
);
|
||||
this->selectionCountLabel->show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace Bloom::Widgets
|
||||
ItemGraphicsView* byteItemGraphicsView = nullptr;
|
||||
ItemGraphicsScene* byteItemGraphicsScene = nullptr;
|
||||
Label* hoveredAddressLabel = nullptr;
|
||||
Label* selectionCountLabel = nullptr;
|
||||
|
||||
SvgToolButton* groupStackMemoryButton = nullptr;
|
||||
SvgToolButton* highlightFocusedMemoryButton = nullptr;
|
||||
@@ -84,5 +85,6 @@ namespace Bloom::Widgets
|
||||
void setDisplayAsciiEnabled(bool enabled);
|
||||
void onGoToAddressInputChanged();
|
||||
void onHoveredAddress(const std::optional<Targets::TargetMemoryAddress>& address);
|
||||
void onByteSelectionChanged(Targets::TargetMemorySize selectionCount);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -464,6 +464,7 @@ namespace Bloom::Widgets
|
||||
this->selectByteItem(*byteItem);
|
||||
}
|
||||
}
|
||||
emit this->selectionChanged(static_cast<Targets::TargetMemorySize>(this->selectedByteItemsByAddress.size()));
|
||||
}
|
||||
|
||||
for (const auto& item : hoveredItems) {
|
||||
@@ -649,10 +650,12 @@ namespace Bloom::Widgets
|
||||
void ItemGraphicsScene::toggleByteItemSelection(ByteItem& byteItem) {
|
||||
if (byteItem.selected) {
|
||||
this->deselectByteItem(byteItem);
|
||||
emit this->selectionChanged(static_cast<Targets::TargetMemorySize>(this->selectedByteItemsByAddress.size()));
|
||||
return;
|
||||
}
|
||||
|
||||
this->selectByteItem(byteItem);
|
||||
emit this->selectionChanged(static_cast<Targets::TargetMemorySize>(this->selectedByteItemsByAddress.size()));
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::clearByteItemSelection() {
|
||||
@@ -662,6 +665,7 @@ namespace Bloom::Widgets
|
||||
|
||||
this->selectedByteItemsByAddress.clear();
|
||||
this->update();
|
||||
emit this->selectionChanged(0);
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::selectAllByteItems() {
|
||||
@@ -672,6 +676,7 @@ namespace Bloom::Widgets
|
||||
}
|
||||
|
||||
this->update();
|
||||
emit this->selectionChanged(static_cast<Targets::TargetMemorySize>(this->selectedByteItemsByAddress.size()));
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::setAddressType(AddressType type) {
|
||||
|
||||
@@ -64,6 +64,7 @@ namespace Bloom::Widgets
|
||||
signals:
|
||||
void ready();
|
||||
void hoveredAddress(const std::optional<Targets::TargetMemoryAddress>& address);
|
||||
void selectionChanged(Targets::TargetMemorySize selectionCount);
|
||||
|
||||
protected:
|
||||
bool event(QEvent* event) override;
|
||||
|
||||
@@ -226,6 +226,13 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Label" name="selection-count-label">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -190,6 +190,14 @@
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#hex-viewer-container #bottom-bar #selection-count-label {
|
||||
border: none;
|
||||
/*border-left: 1px solid red;*/
|
||||
border-left: 1px solid #41423f;
|
||||
padding-left: 4px;
|
||||
min-width: 140px;
|
||||
}
|
||||
|
||||
#hex-viewer-container QScrollBar:vertical {
|
||||
background-color: transparent;
|
||||
width: 12px;
|
||||
|
||||
Reference in New Issue
Block a user