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