Register inspection window

This commit is contained in:
Nav
2021-09-18 22:41:08 +01:00
parent d2a8966a0a
commit dcdcd1d114
24 changed files with 1694 additions and 2 deletions

View File

@@ -3,11 +3,9 @@
#include <QApplication>
#include <QClipboard>
#include <QMenu>
#include <utility>
#include <QStyle>
#include "src/Helpers/Paths.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Insight/InsightWorker/Tasks/ReadTargetRegisters.hpp"
@@ -45,6 +43,8 @@ RegisterWidget::RegisterWidget(
this->layout->addWidget(this->valueLabel);
this->layout->addStretch(1);
this->connect(this, &ClickableWidget::doubleClicked, this, &RegisterWidget::openInspectionWindow);
this->connect(this->openInspectionWindowAction, &QAction::triggered, this, &RegisterWidget::openInspectionWindow);
this->connect(this->refreshValueAction, &QAction::triggered, this, &RegisterWidget::refreshValue);
this->connect(this->copyValueNameAction, &QAction::triggered, this, &RegisterWidget::copyName);
this->connect(this->copyValueHexAction, &QAction::triggered, this, &RegisterWidget::copyValueHex);
@@ -88,6 +88,23 @@ void RegisterWidget::clearInlineValue() {
this->valueLabel->clear();
}
void RegisterWidget::openInspectionWindow() {
if (!TargetRegisterInspectorWindow::registerSupported(this->descriptor)) {
return;
}
if (this->inspectWindow == nullptr) {
this->inspectWindow = new TargetRegisterInspectorWindow(
this->descriptor,
this->insightWorker,
this->currentRegister.has_value() ? std::optional(this->currentRegister->value) : std::nullopt
);
} else {
this->inspectWindow->show();
}
}
void RegisterWidget::refreshValue() {
auto readRegisterTask = new ReadTargetRegisters({this->descriptor});
@@ -155,6 +172,7 @@ void RegisterWidget::contextMenuEvent(QContextMenuEvent* event) {
this->setSelected(true);
auto menu = new QMenu(this);
menu->addAction(this->openInspectionWindowAction);
menu->addAction(this->refreshValueAction);
menu->addSeparator();
@@ -167,6 +185,8 @@ void RegisterWidget::contextMenuEvent(QContextMenuEvent* event) {
menu->addMenu(copyMenu);
this->openInspectionWindowAction->setEnabled(TargetRegisterInspectorWindow::registerSupported(this->descriptor));
const auto targetStopped = this->targetState == Targets::TargetState::STOPPED;
const auto targetStoppedAndValuePresent = targetStopped && this->currentRegister.has_value();
this->refreshValueAction->setEnabled(targetStopped);