Added support for attaching and detaching memory inspection panes from the main insight window

This commit is contained in:
Nav
2022-07-16 19:12:12 +01:00
parent 4c3083e992
commit 34993f1733
5 changed files with 183 additions and 36 deletions

View File

@@ -32,6 +32,15 @@ namespace Bloom::Widgets
{
this->setObjectName("target-memory-inspection-pane");
const auto memoryName = QString(
this->targetMemoryDescriptor.type == TargetMemoryType::EEPROM
? "Internal EEPROM"
: "Internal RAM"
);
this->setWindowTitle("Memory Inspection - " + memoryName);
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
auto memoryInspectionPaneUiFile = QFile(
QString::fromStdString(Paths::compiledResourcesPath()
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/UiFiles/TargetMemoryInspectionPane.ui"
@@ -44,15 +53,13 @@ namespace Bloom::Widgets
auto uiLoader = UiLoader(this);
this->container = uiLoader.load(&memoryInspectionPaneUiFile, this);
this->container->setFixedSize(parent->width(), parent->maximumHeight());
this->container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
this->titleBar = this->container->findChild<QWidget*>("title-bar");
this->titleBar->layout()->setContentsMargins(7, 0, 7, 0);
auto* titleLabel = this->titleBar->findChild<Label*>("title");
titleLabel->setText(
this->targetMemoryDescriptor.type == TargetMemoryType::EEPROM ? "Internal EEPROM" : "Internal RAM"
);
titleLabel->setText(memoryName);
// Quick sanity check to ensure the validity of persisted settings.
this->sanitiseSettings();
@@ -73,6 +80,34 @@ namespace Bloom::Widgets
subContainerLayout->insertWidget(1, this->hexViewerWidget);
QObject::connect(
this,
&PaneWidget::paneActivated,
this,
&TargetMemoryInspectionPane::postActivate
);
QObject::connect(
this,
&PaneWidget::paneDeactivated,
this,
&TargetMemoryInspectionPane::postDeactivate
);
QObject::connect(
this,
&PaneWidget::paneAttached,
this,
&TargetMemoryInspectionPane::postAttach
);
QObject::connect(
this,
&PaneWidget::paneDetached,
this,
&TargetMemoryInspectionPane::postDetach
);
QObject::connect(
this->manageMemoryRegionsButton,
&QToolButton::clicked,
@@ -80,6 +115,20 @@ namespace Bloom::Widgets
&TargetMemoryInspectionPane::openMemoryRegionManagerWindow
);
QObject::connect(
this->detachPaneButton,
&QToolButton::clicked,
this,
&TargetMemoryInspectionPane::detach
);
QObject::connect(
this->attachPaneButton,
&QToolButton::clicked,
this,
&TargetMemoryInspectionPane::attach
);
QObject::connect(
&insightWorker,
&InsightWorker::targetStateUpdated,
@@ -181,22 +230,14 @@ namespace Bloom::Widgets
this->insightWorker.queueTask(readMemoryTask);
}
void TargetMemoryInspectionPane::activate() {
this->show();
this->activated = true;
this->postActivate();
}
void TargetMemoryInspectionPane::deactivate() {
this->hide();
this->activated = false;
this->postDeactivate();
}
void TargetMemoryInspectionPane::resizeEvent(QResizeEvent* event) {
const auto parentSize = this->parentPanel->size();
const auto width = parentSize.width() - 1;
this->container->setFixedSize(width, parentSize.height());
const auto size = this->size();
this->container->setFixedSize(size.width() - 1, size.height());
}
void TargetMemoryInspectionPane::closeEvent(QCloseEvent* event) {
this->deactivate();
QWidget::closeEvent(event);
}
void TargetMemoryInspectionPane::postActivate() {
@@ -211,6 +252,16 @@ namespace Bloom::Widgets
}
void TargetMemoryInspectionPane::postAttach() {
this->attachPaneButton->hide();
this->detachPaneButton->show();
}
void TargetMemoryInspectionPane::postDetach() {
this->detachPaneButton->hide();
this->attachPaneButton->show();
}
void TargetMemoryInspectionPane::sanitiseSettings() {
// Remove any invalid memory regions. It's very unlikely that there will be any, but not impossible.
auto processedFocusedMemoryRegions = std::vector<FocusedMemoryRegion>();

View File

@@ -38,9 +38,12 @@ namespace Bloom::Widgets
protected:
void resizeEvent(QResizeEvent* event) override;
void closeEvent(QCloseEvent* event) override;
void postActivate();
void postDeactivate();
void postAttach();
void postDetach();
private:
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;

View File

@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<widget class="QWidget" name="container">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"/>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>0</number>