Refactored Insight GUI to accommodate the many changes made to Bloom's internals
Also lots of tidying.
This commit is contained in:
@@ -11,26 +11,28 @@
|
||||
using namespace Exceptions;
|
||||
|
||||
AboutWindow::AboutWindow(QWidget* parent): QObject(parent) {
|
||||
auto aboutWindowUiFile = QFile(QString::fromStdString(
|
||||
auto aboutWindowUiFile = QFile{
|
||||
QString::fromStdString(
|
||||
Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/UiFiles/AboutWindow.ui"
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/UiFiles/AboutWindow.ui"
|
||||
)
|
||||
);
|
||||
auto aboutWindowStylesheet = QFile(QString::fromStdString(
|
||||
};
|
||||
auto aboutWindowStylesheet = QFile{
|
||||
QString::fromStdString(
|
||||
Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/AboutWindow.qss"
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/AboutWindow.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!aboutWindowUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open AboutWindow UI file");
|
||||
throw Exception{"Failed to open AboutWindow UI file"};
|
||||
}
|
||||
|
||||
if (!aboutWindowStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open AboutWindow QSS file");
|
||||
throw Exception{"Failed to open AboutWindow QSS file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->windowWidget = uiLoader.load(&aboutWindowUiFile, parent);
|
||||
this->windowWidget->setStyleSheet(aboutWindowStylesheet.readAll());
|
||||
this->windowWidget->setFixedSize(400, 300);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,6 +12,8 @@
|
||||
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetVariantDescriptor.hpp"
|
||||
#include "src/Targets/TargetPinoutDescriptor.hpp"
|
||||
|
||||
#include "Widgets/Label.hpp"
|
||||
#include "Widgets/SvgToolButton.hpp"
|
||||
@@ -20,6 +22,7 @@
|
||||
#include "Widgets/PanelWidget.hpp"
|
||||
#include "Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp"
|
||||
#include "Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp"
|
||||
#include "Widgets/TargetMemoryInspectionPane/ToolButton.hpp"
|
||||
#include "Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPaneSettings.hpp"
|
||||
#include "Widgets/TaskIndicator/TaskIndicator.hpp"
|
||||
#include "AboutWindow.hpp"
|
||||
@@ -33,7 +36,8 @@ public:
|
||||
InsightProjectSettings& insightProjectSettings,
|
||||
const InsightConfig& insightConfig,
|
||||
const EnvironmentConfig& environmentConfig,
|
||||
const Targets::TargetDescriptor& targetDescriptor
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
const Targets::TargetState& targetState
|
||||
);
|
||||
|
||||
protected:
|
||||
@@ -49,7 +53,7 @@ private:
|
||||
TargetConfig targetConfig;
|
||||
|
||||
const Targets::TargetDescriptor& targetDescriptor;
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
QWidget* windowContainer = nullptr;
|
||||
QMenuBar* mainMenuBar = nullptr;
|
||||
@@ -68,60 +72,46 @@ private:
|
||||
Widgets::TargetRegistersPaneWidget* targetRegistersSidePane = nullptr;
|
||||
QToolButton* targetRegistersButton = nullptr;
|
||||
|
||||
Widgets::Label* ioUnavailableWidget = nullptr;
|
||||
Widgets::InsightTargetWidgets::TargetPackageWidgetContainer* ioContainerWidget = nullptr;
|
||||
Widgets::InsightTargetWidgets::TargetPackageWidget* targetPackageWidget = nullptr;
|
||||
|
||||
QWidget* bottomMenuBar = nullptr;
|
||||
QHBoxLayout* bottomMenuBarLayout = nullptr;
|
||||
Widgets::PanelWidget* bottomPanel = nullptr;
|
||||
Widgets::TargetMemoryInspectionPane* ramInspectionPane = nullptr;
|
||||
Widgets::TargetMemoryInspectionPane* eepromInspectionPane = nullptr;
|
||||
Widgets::TargetMemoryInspectionPane* flashInspectionPane = nullptr;
|
||||
std::map<
|
||||
Targets::TargetMemoryType,
|
||||
Widgets::TargetMemoryInspectionPaneSettings
|
||||
> memoryInspectionPaneSettingsByMemoryType;
|
||||
QToolButton* ramInspectionButton = nullptr;
|
||||
QToolButton* eepromInspectionButton = nullptr;
|
||||
QToolButton* flashInspectionButton = nullptr;
|
||||
std::vector<Widgets::TargetMemoryInspectionPane*> memoryInspectionPaneWidgets = {};
|
||||
|
||||
QWidget* footer = nullptr;
|
||||
Widgets::Label* targetStatusLabel = nullptr;
|
||||
Widgets::Label* programCounterValueLabel = nullptr;
|
||||
Widgets::TaskIndicator* taskIndicator = nullptr;
|
||||
|
||||
std::map<QString, Targets::TargetVariant> supportedVariantsByName;
|
||||
const Targets::TargetVariant* selectedVariant = nullptr;
|
||||
std::optional<Targets::TargetVariant> previouslySelectedVariant;
|
||||
const Targets::TargetVariantDescriptor* selectedVariantDescriptor = nullptr;
|
||||
bool uiDisabled = false;
|
||||
|
||||
static bool isVariantSupported(const Targets::TargetVariant& variant);
|
||||
static bool isPinoutSupported(const Targets::TargetPinoutDescriptor& pinoutDescriptor);
|
||||
|
||||
void setUiDisabled(bool disable);
|
||||
|
||||
void populateVariantMenu();
|
||||
void selectDefaultVariant();
|
||||
void selectVariant(const Targets::TargetVariant* variant);
|
||||
void selectVariant(const Targets::TargetVariantDescriptor* variantDescriptor);
|
||||
void createPanes();
|
||||
|
||||
void adjustPanels();
|
||||
void adjustMinimumSize();
|
||||
|
||||
void onTargetStateUpdate(Targets::TargetState newState);
|
||||
void onTargetStateUpdate(Targets::TargetState newState, Targets::TargetState previousState);
|
||||
void refresh();
|
||||
void refreshPinStates();
|
||||
void refreshProgramCounter(std::optional<std::function<void(void)>> callback = std::nullopt);
|
||||
void refreshPadStates();
|
||||
void openReportIssuesUrl();
|
||||
void openGettingStartedUrl();
|
||||
void openAboutWindow();
|
||||
void toggleTargetRegistersPane();
|
||||
void toggleRamInspectionPane();
|
||||
void toggleMemoryInspectionPane(Widgets::TargetMemoryInspectionPane* pane);
|
||||
void toggleEepromInspectionPane();
|
||||
void toggleFlashInspectionPane();
|
||||
void onRegistersPaneStateChanged();
|
||||
void onRamInspectionPaneStateChanged();
|
||||
void onEepromInspectionPaneStateChanged();
|
||||
void onFlashInspectionPaneStateChanged();
|
||||
void onMemoryInspectionPaneStateChanged(Widgets::TargetMemoryInspectionPane* pane, Widgets::ToolButton* toolBtn);
|
||||
void onProgrammingModeEnabled();
|
||||
void onProgrammingModeDisabled();
|
||||
};
|
||||
|
||||
@@ -188,38 +188,14 @@ QToolTip {
|
||||
border-top: 1px solid #2F2F2D;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #ram-inspection-btn,
|
||||
#bottom-menu-bar #eeprom-inspection-btn,
|
||||
#bottom-menu-bar #flash-inspection-btn {
|
||||
#bottom-menu-bar QToolButton {
|
||||
position: relative;
|
||||
border: none;
|
||||
min-height: 22px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #ram-inspection-btn {
|
||||
min-width: 73px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #eeprom-inspection-btn {
|
||||
min-width: 99px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #flash-inspection-btn {
|
||||
min-width: 85px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #ram-inspection-btn #ram-inspection-btn-icon,
|
||||
#bottom-menu-bar #eeprom-inspection-btn #eeprom-inspection-btn-icon,
|
||||
#bottom-menu-bar #flash-inspection-btn #flash-inspection-btn-icon {
|
||||
margin-left: 6px;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar #ram-inspection-btn #ram-inspection-btn-label,
|
||||
#bottom-menu-bar #eeprom-inspection-btn #eeprom-inspection-btn-label,
|
||||
#bottom-menu-bar #flash-inspection-btn #flash-inspection-btn-label {
|
||||
#bottom-menu-bar QToolButton QLabel {
|
||||
color: #999a9d;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
#bottom-menu-bar QToolButton:hover,
|
||||
|
||||
@@ -250,159 +250,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="ram-inspection-btn">
|
||||
<property name="toolTip">
|
||||
<string>Inspect RAM</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="disabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="SvgWidget" name="ram-inspection-btn-icon">
|
||||
<property name="containerHeight">
|
||||
<number>22</number>
|
||||
</property>
|
||||
<property name="containerWidth">
|
||||
<number>26</number>
|
||||
</property>
|
||||
<property name="svgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon.svg</string>
|
||||
</property>
|
||||
<property name="disabledSvgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon-disabled.svg</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="Label" name="ram-inspection-btn-label">
|
||||
<property name="text">
|
||||
<string>RAM</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<spacer name="horizontal-spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="eeprom-inspection-btn">
|
||||
<property name="toolTip">
|
||||
<string>Inspect EEPROM</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="disabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="SvgWidget" name="eeprom-inspection-btn-icon">
|
||||
<property name="containerHeight">
|
||||
<number>22</number>
|
||||
</property>
|
||||
<property name="containerWidth">
|
||||
<number>26</number>
|
||||
</property>
|
||||
<property name="svgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon.svg</string>
|
||||
</property>
|
||||
<property name="disabledSvgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon-disabled.svg</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="Label" name="eeprom-inspection-btn-label">
|
||||
<property name="text">
|
||||
<string>EEPROM</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<spacer name="horizontal-spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="flash-inspection-btn">
|
||||
<property name="toolTip">
|
||||
<string>Inspect FLASH</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="disabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="SvgWidget" name="flash-inspection-btn-icon">
|
||||
<property name="containerHeight">
|
||||
<number>22</number>
|
||||
</property>
|
||||
<property name="containerWidth">
|
||||
<number>26</number>
|
||||
</property>
|
||||
<property name="svgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon.svg</string>
|
||||
</property>
|
||||
<property name="disabledSvgFilePath">
|
||||
<string>:/compiled/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon-disabled.svg</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="Label" name="flash-inspection-btn-label">
|
||||
<property name="text">
|
||||
<string>FLASH</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<spacer name="horizontal-spacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontal-spacer">
|
||||
<property name="orientation">
|
||||
|
||||
@@ -16,12 +16,14 @@
|
||||
|
||||
using namespace Widgets;
|
||||
|
||||
UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
UiLoader::UiLoader(QObject* parent)
|
||||
: QUiLoader(parent)
|
||||
{
|
||||
this->customWidgetConstructorsByWidgetName = {
|
||||
{
|
||||
"Label",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new Label(parent);
|
||||
auto* widget = new Label{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -30,7 +32,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"RotatableLabel",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new RotatableLabel("", parent);
|
||||
auto* widget = new RotatableLabel{"", parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -39,7 +41,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"LabeledSeparator",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new LabeledSeparator(parent);
|
||||
auto* widget = new LabeledSeparator{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -48,7 +50,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"TextInput",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new TextInput(parent);
|
||||
auto* widget = new TextInput{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -57,7 +59,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"PlainTextEdit",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new PlainTextEdit(parent);
|
||||
auto* widget = new PlainTextEdit{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -66,7 +68,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"PushButton",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new PushButton(parent);
|
||||
auto* widget = new PushButton{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -75,7 +77,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"ExpandingHeightScrollAreaWidget",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new ExpandingHeightScrollAreaWidget(parent);
|
||||
auto* widget = new ExpandingHeightScrollAreaWidget{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -84,7 +86,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"SvgWidget",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new SvgWidget(parent);
|
||||
auto* widget = new SvgWidget{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -93,7 +95,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"SvgToolButton",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new SvgToolButton(parent);
|
||||
auto* widget = new SvgToolButton{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
@@ -102,7 +104,7 @@ UiLoader::UiLoader(QObject* parent): QUiLoader(parent) {
|
||||
{
|
||||
"TargetPackageWidgetContainer",
|
||||
[this] (QWidget* parent, const QString& name) {
|
||||
auto* widget = new InsightTargetWidgets::TargetPackageWidgetContainer(parent);
|
||||
auto* widget = new InsightTargetWidgets::TargetPackageWidgetContainer{parent};
|
||||
widget->setObjectName(name);
|
||||
widget->setStyleSheet(parent->styleSheet());
|
||||
return widget;
|
||||
|
||||
@@ -11,7 +11,9 @@ namespace Widgets
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ClickableWidget(QWidget* parent): QFrame(parent) {};
|
||||
explicit ClickableWidget(QWidget* parent)
|
||||
: QFrame(parent)
|
||||
{};
|
||||
|
||||
signals:
|
||||
void rightClicked();
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Widgets
|
||||
void aborted();
|
||||
|
||||
protected:
|
||||
PushButton* confirmButton = new PushButton(this);
|
||||
PushButton* cancelButton = new PushButton(this);
|
||||
PushButton* confirmButton = new PushButton{this};
|
||||
PushButton* cancelButton = new PushButton{this};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,29 +21,29 @@ namespace Widgets
|
||||
this->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
this->setWindowTitle(windowTitle);
|
||||
|
||||
auto dialogUiFile = QFile(
|
||||
auto dialogUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/UiFiles/Dialog.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto dialogStylesheet = QFile(
|
||||
auto dialogStylesheet = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/Dialog/Stylesheets/Dialog.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!dialogUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open Dialog UI file");
|
||||
throw Exception{"Failed to open Dialog UI file"};
|
||||
}
|
||||
|
||||
if (!dialogStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open Dialog stylesheet file");
|
||||
throw Exception{"Failed to open Dialog stylesheet file"};
|
||||
}
|
||||
|
||||
this->setStyleSheet(dialogStylesheet.readAll());
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&dialogUiFile, this);
|
||||
|
||||
this->textLabel = this->container->findChild<Label*>("text-label");
|
||||
@@ -58,10 +58,10 @@ namespace Widgets
|
||||
|
||||
void Dialog::showEvent(QShowEvent* event) {
|
||||
const auto containerSize = this->container->sizeHint();
|
||||
const auto windowSize = QSize(
|
||||
const auto windowSize = QSize{
|
||||
std::max(containerSize.width(), 500),
|
||||
std::max(containerSize.height(), 100)
|
||||
);
|
||||
};
|
||||
|
||||
this->setFixedSize(windowSize);
|
||||
this->container->setFixedSize(windowSize);
|
||||
|
||||
@@ -22,29 +22,29 @@ namespace Widgets
|
||||
this->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
this->setWindowTitle(windowTitle);
|
||||
|
||||
auto dialogueUiFile = QFile(
|
||||
auto dialogueUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/UiFiles/ErrorDialogue.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto dialogueStylesheet = QFile(
|
||||
auto dialogueStylesheet = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/Stylesheets/ErrorDialogue.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!dialogueUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open ErrorDialogue UI file");
|
||||
throw Exception{"Failed to open ErrorDialogue UI file"};
|
||||
}
|
||||
|
||||
if (!dialogueStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open ErrorDialogue stylesheet file");
|
||||
throw Exception{"Failed to open ErrorDialogue stylesheet file"};
|
||||
}
|
||||
|
||||
this->setStyleSheet(dialogueStylesheet.readAll());
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&dialogueUiFile, this);
|
||||
|
||||
this->errorMessageDescriptionLabel = this->container->findChild<Label*>(
|
||||
@@ -61,10 +61,10 @@ namespace Widgets
|
||||
|
||||
void ErrorDialogue::showEvent(QShowEvent* event) {
|
||||
const auto containerSize = this->container->sizeHint();
|
||||
const auto windowSize = QSize(
|
||||
const auto windowSize = QSize{
|
||||
std::max(containerSize.width(), 500),
|
||||
std::max(containerSize.height(), 100)
|
||||
);
|
||||
};
|
||||
|
||||
this->setFixedSize(windowSize);
|
||||
this->container->setFixedSize(windowSize);
|
||||
|
||||
@@ -11,7 +11,9 @@ namespace Widgets
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ExpandingHeightScrollAreaWidget(QWidget* parent): QScrollArea(parent) {};
|
||||
explicit ExpandingHeightScrollAreaWidget(QWidget* parent)
|
||||
: QScrollArea(parent)
|
||||
{};
|
||||
|
||||
protected:
|
||||
[[nodiscard]] QSize scrollAreaSize() const {
|
||||
|
||||
@@ -11,25 +11,25 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void LabeledSeparator::paintEvent(QPaintEvent* event) {
|
||||
auto painter = QPainter(this);
|
||||
auto painter = QPainter{this};
|
||||
this->drawWidget(painter);
|
||||
}
|
||||
|
||||
void LabeledSeparator::drawWidget(QPainter& painter) {
|
||||
const auto fontMetrics = painter.fontMetrics();
|
||||
const auto titleSize = fontMetrics.size(Qt::TextFlag::TextSingleLine, this->title);
|
||||
const auto titleRect = QRect(
|
||||
QPoint(this->marginLeft, (this->height() - titleSize.height()) / 2),
|
||||
const auto titleRect = QRect{
|
||||
QPoint{this->marginLeft, (this->height() - titleSize.height()) / 2},
|
||||
titleSize
|
||||
);
|
||||
};
|
||||
|
||||
const auto lineYPosition = titleRect.y() + (titleRect.height() / 2);
|
||||
const auto line = QLine(
|
||||
const auto line = QLine{
|
||||
titleRect.right() + 8,
|
||||
lineYPosition,
|
||||
this->width() - this->marginRight,
|
||||
lineYPosition
|
||||
);
|
||||
};
|
||||
|
||||
painter.drawText(titleRect, Qt::AlignCenter, this->title);
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Widgets
|
||||
static constexpr int DEFAULT_HEIGHT = 20;
|
||||
|
||||
QString title;
|
||||
QColor lineColor = QColor(0x4A, 0x4A, 0x4A);
|
||||
QColor lineColor = QColor{0x4A, 0x4A, 0x4A};
|
||||
int marginLeft = 0;
|
||||
int marginRight = 10;
|
||||
};
|
||||
|
||||
@@ -7,26 +7,36 @@
|
||||
#include <QWidget>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsScene>
|
||||
#include <set>
|
||||
|
||||
#include "src/Helpers/DereferenceLessComparator.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
class ListItem: public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
using ListItemSetType = std::set<ListItem*, DereferenceLessComparator<ListItem*>>;
|
||||
|
||||
bool selected = false;
|
||||
QSize size = QSize();
|
||||
bool excluded = false;
|
||||
QSize size = {};
|
||||
|
||||
ListItem() = default;
|
||||
|
||||
explicit ListItem(QGraphicsItem* parent)
|
||||
: QGraphicsItem(parent)
|
||||
{}
|
||||
|
||||
[[nodiscard]] QRectF boundingRect() const override {
|
||||
return QRectF(QPointF(0, 0), this->size);
|
||||
return QRectF{QPointF{0, 0}, this->size};
|
||||
}
|
||||
|
||||
virtual void onGeometryChanged() {
|
||||
return;
|
||||
}
|
||||
virtual void onGeometryChanged() {}
|
||||
|
||||
virtual bool operator < (const ListItem& rhs) const = 0;
|
||||
virtual bool operator < (const ListItem& rhs) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator > (const ListItem& rhs) const {
|
||||
return rhs < *this;
|
||||
|
||||
@@ -8,15 +8,12 @@
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
ListScene::ListScene(
|
||||
ListScene::ListItemSetType&& items,
|
||||
QGraphicsView* parent
|
||||
)
|
||||
ListScene::ListScene(const ListItem::ListItemSetType& items, QGraphicsView* parent)
|
||||
: QGraphicsScene(parent)
|
||||
, parent(parent)
|
||||
{
|
||||
this->setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
this->setItems(std::move(items));
|
||||
this->setItems(items);
|
||||
}
|
||||
|
||||
void ListScene::setSelectionLimit(std::uint8_t selectionLimit) {
|
||||
@@ -32,7 +29,7 @@ namespace Widgets
|
||||
auto startYPosition = this->margins.top();
|
||||
|
||||
for (auto& listItem : this->listItems) {
|
||||
if (!listItem->isVisible()) {
|
||||
if (listItem->excluded || !listItem->isVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -54,7 +51,7 @@ namespace Widgets
|
||||
this->update();
|
||||
}
|
||||
|
||||
void ListScene::setItems(const ListScene::ListItemSetType& items) {
|
||||
void ListScene::setItems(const ListItem::ListItemSetType& items) {
|
||||
this->clearListItems();
|
||||
|
||||
this->listItems = items;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <QPointF>
|
||||
|
||||
#include "ListItem.hpp"
|
||||
#include "src/Helpers/DereferenceLessComparator.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
@@ -22,17 +21,16 @@ namespace Widgets
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using ListItemSetType = std::set<ListItem*, DereferenceLessComparator<ListItem*>>;
|
||||
QMargins margins = QMargins(0, 0, 0, 10);
|
||||
QMargins margins = {0, 0, 0, 10};
|
||||
|
||||
ListScene(
|
||||
ListScene::ListItemSetType&& items,
|
||||
const ListItem::ListItemSetType& items,
|
||||
QGraphicsView* parent
|
||||
);
|
||||
|
||||
void refreshGeometry();
|
||||
void setSelectionLimit(std::uint8_t selectionLimit);
|
||||
void setItems(const ListScene::ListItemSetType& items);
|
||||
void setItems(const ListItem::ListItemSetType& items);
|
||||
void addListItem(ListItem* item);
|
||||
void removeListItem(ListItem* item);
|
||||
void clearListItems();
|
||||
@@ -53,7 +51,7 @@ namespace Widgets
|
||||
void keyPressEvent(QKeyEvent* keyEvent) override;
|
||||
|
||||
private:
|
||||
ListScene::ListItemSetType listItems;
|
||||
ListItem::ListItemSetType listItems;
|
||||
QGraphicsView* const parent;
|
||||
bool enabled = false;
|
||||
bool keyNavigationEnabled = true;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Widgets
|
||||
{
|
||||
ListView::ListView(
|
||||
ListScene::ListItemSetType&& items,
|
||||
ListItem::ListItemSetType&& items,
|
||||
QWidget* parent
|
||||
)
|
||||
: QGraphicsView(parent)
|
||||
@@ -19,7 +19,7 @@ namespace Widgets
|
||||
this->setCacheMode(QGraphicsView::CacheModeFlag::CacheNone);
|
||||
this->setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
this->scene = new ListScene(std::move(items), this);
|
||||
this->scene = new ListScene{std::move(items), this};
|
||||
this->setScene(this->scene);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
ListView(
|
||||
ListScene::ListItemSetType&& items,
|
||||
ListItem::ListItemSetType&& items,
|
||||
QWidget* parent
|
||||
);
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ namespace Widgets
|
||||
bool open = false;
|
||||
|
||||
PanelState() = default;
|
||||
PanelState(int size, bool open): size(size), open(open) {};
|
||||
PanelState(int size, bool open)
|
||||
: size(size)
|
||||
, open(open)
|
||||
{};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Widgets
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
this->setMaximumResize(this->window()->height() - 100);
|
||||
|
||||
auto* layout = new QHBoxLayout(this);
|
||||
auto* layout = new QHBoxLayout{this};
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
this->setLayout(layout);
|
||||
@@ -30,7 +30,7 @@ namespace Widgets
|
||||
this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::MinimumExpanding);
|
||||
this->setMaximumResize(this->window()->width() - 100);
|
||||
|
||||
auto* layout = new QVBoxLayout(this);
|
||||
auto* layout = new QVBoxLayout{this};
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
this->setLayout(layout);
|
||||
@@ -83,8 +83,6 @@ namespace Widgets
|
||||
}
|
||||
|
||||
bool PanelWidget::eventFilter(QObject* object, QEvent* event) {
|
||||
const auto eventType = event->type();
|
||||
|
||||
if (event->isSinglePointEvent()) {
|
||||
auto* pointerEvent = dynamic_cast<QSinglePointEvent*>(event);
|
||||
|
||||
@@ -168,23 +166,23 @@ namespace Widgets
|
||||
|
||||
switch (this->panelType) {
|
||||
case PanelWidgetType::LEFT: {
|
||||
return std::pair(
|
||||
QPoint(currentSize.width() - this->handleSize, 0),
|
||||
QPoint(currentSize.width(), currentSize.height())
|
||||
);
|
||||
return std::pair{
|
||||
QPoint{currentSize.width() - this->handleSize, 0},
|
||||
QPoint{currentSize.width(), currentSize.height()}
|
||||
};
|
||||
}
|
||||
case PanelWidgetType::RIGHT: {
|
||||
return std::pair(
|
||||
QPoint(0, 0),
|
||||
QPoint(this->handleSize, currentSize.height())
|
||||
);
|
||||
return std::pair{
|
||||
QPoint{0, 0},
|
||||
QPoint{this->handleSize, currentSize.height()}
|
||||
};
|
||||
}
|
||||
case PanelWidgetType::BOTTOM:
|
||||
default: {
|
||||
return std::pair(
|
||||
QPoint(0, 0),
|
||||
QPoint(currentSize.width(), this->handleSize)
|
||||
);
|
||||
return std::pair{
|
||||
QPoint{0, 0},
|
||||
QPoint{currentSize.width(), this->handleSize}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,9 +190,8 @@ namespace Widgets
|
||||
bool PanelWidget::isPositionWithinHandleArea(const QPoint& position) const {
|
||||
const auto handleArea = this->getHandleArea();
|
||||
|
||||
return (
|
||||
return
|
||||
position.x() >= handleArea.first.x() && position.x() <= handleArea.second.x()
|
||||
&& position.y() >= handleArea.first.y() && position.y() <= handleArea.second.y()
|
||||
);
|
||||
&& position.y() >= handleArea.first.y() && position.y() <= handleArea.second.y();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
namespace Widgets
|
||||
{
|
||||
void RotatableLabel::paintEvent(QPaintEvent* event) {
|
||||
auto painter = QPainter(this);
|
||||
auto painter = QPainter{this};
|
||||
const auto containerSize = this->getContainerSize();
|
||||
const auto textSize = QLabel::minimumSizeHint();
|
||||
const auto margins = this->contentsMargins();
|
||||
@@ -13,7 +13,7 @@ namespace Widgets
|
||||
painter.setClipRect(0, 0, containerSize.width(), containerSize.height());
|
||||
painter.save();
|
||||
painter.setPen(Qt::PenStyle::SolidLine);
|
||||
painter.setPen(QColor(this->isEnabled() ? "#999a9d" : "#808484"));
|
||||
painter.setPen(QColor{this->isEnabled() ? "#999a9d" : "#808484"});
|
||||
painter.translate(std::ceil(containerSize.width() / 2), std::ceil(containerSize.height() / 2));
|
||||
painter.rotate(this->angle);
|
||||
painter.drawText(
|
||||
@@ -29,7 +29,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
QSize RotatableLabel::getContainerSize() const {
|
||||
auto size = QSize();
|
||||
auto size = QSize{};
|
||||
auto textSize = QLabel::sizeHint();
|
||||
|
||||
if (this->angle % 360 == 0 || this->angle % 180 == 0) {
|
||||
@@ -52,11 +52,11 @@ namespace Widgets
|
||||
|
||||
size.setWidth(static_cast<int>(
|
||||
std::cos(angleRadians) * textSize.width()
|
||||
+ std::ceil(std::sin(angleRadians) * textSize.height())
|
||||
+ std::ceil(std::sin(angleRadians) * textSize.height())
|
||||
));
|
||||
size.setHeight(static_cast<int>(
|
||||
std::sin(angleRadians) * textSize.width()
|
||||
+ std::ceil(std::cos(angleRadians) * textSize.height())
|
||||
+ std::ceil(std::cos(angleRadians) * textSize.height())
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Widgets
|
||||
|
||||
void SvgToolButton::contextMenuEvent(QContextMenuEvent* event) {
|
||||
if (this->contextMenu != nullptr) {
|
||||
this->contextMenu->exec(this->mapToGlobal(QPoint(0, this->height())));
|
||||
this->contextMenu->exec(this->mapToGlobal(QPoint{0, this->height()}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
namespace Widgets
|
||||
{
|
||||
SvgWidget::SvgWidget(QWidget* parent): QFrame(parent) {
|
||||
this->renderer.setAspectRatioMode(Qt::AspectRatioMode::KeepAspectRatioByExpanding);
|
||||
this->renderer->setAspectRatioMode(Qt::AspectRatioMode::KeepAspectRatioByExpanding);
|
||||
}
|
||||
|
||||
void SvgWidget::startSpin() {
|
||||
if (this->spinningAnimation == nullptr) {
|
||||
this->spinningAnimation = new QPropertyAnimation(this, "angle", this);
|
||||
this->spinningAnimation = new QPropertyAnimation{this, "angle", this};
|
||||
this->spinningAnimation->setDuration(2000);
|
||||
this->spinningAnimation->setStartValue(0);
|
||||
this->spinningAnimation->setEndValue(360);
|
||||
@@ -33,7 +33,7 @@ namespace Widgets
|
||||
|
||||
void SvgWidget::paintEvent(QPaintEvent* paintEvent) {
|
||||
auto painter = QPainter(this);
|
||||
auto svgSize = this->renderer.defaultSize();
|
||||
auto svgSize = this->renderer->defaultSize();
|
||||
auto margins = this->contentsMargins();
|
||||
const auto containerSize = this->frameSize();
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Widgets
|
||||
);
|
||||
}
|
||||
|
||||
this->renderer.render(&painter, QRectF(
|
||||
this->renderer->render(&painter, QRectF(
|
||||
std::ceil(
|
||||
static_cast<float>(containerSize.width() - svgSize.width()) / 2 + static_cast<float>(margins.left())
|
||||
),
|
||||
@@ -66,10 +66,10 @@ namespace Widgets
|
||||
void SvgWidget::changeEvent(QEvent* event) {
|
||||
if (event->type() == QEvent::EnabledChange && !this->disabledSvgFilePath.isEmpty()) {
|
||||
if (!this->isEnabled()) {
|
||||
this->renderer.load(this->disabledSvgFilePath);
|
||||
this->renderer->load(this->disabledSvgFilePath);
|
||||
|
||||
} else {
|
||||
this->renderer.load(this->svgFilePath);
|
||||
this->renderer->load(this->svgFilePath);
|
||||
}
|
||||
|
||||
this->repaint();
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Widgets
|
||||
|
||||
void setSvgFilePath(const QString& svgFilePath) {
|
||||
this->svgFilePath = svgFilePath;
|
||||
this->renderer.load(this->svgFilePath);
|
||||
this->renderer->load(this->svgFilePath);
|
||||
}
|
||||
|
||||
QString getSvgFilePath() {
|
||||
@@ -86,7 +86,7 @@ namespace Widgets
|
||||
void changeEvent(QEvent* event) override;
|
||||
|
||||
private:
|
||||
QSvgRenderer renderer = new QSvgRenderer(this);
|
||||
QSvgRenderer* renderer = new QSvgRenderer{this};
|
||||
QString svgFilePath;
|
||||
QString disabledSvgFilePath;
|
||||
int containerWidth = 0;
|
||||
|
||||
@@ -4,16 +4,19 @@
|
||||
|
||||
ExcludedMemoryRegion::ExcludedMemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
)
|
||||
: MemoryRegion(name, memoryType, MemoryRegionType::EXCLUDED, addressRange)
|
||||
: MemoryRegion(
|
||||
name,
|
||||
MemoryRegionType::EXCLUDED,
|
||||
addressRange
|
||||
)
|
||||
{}
|
||||
|
||||
ExcludedMemoryRegion::ExcludedMemoryRegion(const QJsonObject& jsonObject)
|
||||
: MemoryRegion(jsonObject)
|
||||
{
|
||||
if (this->type != MemoryRegionType::EXCLUDED) {
|
||||
throw Exceptions::Exception("Invalid memory region type");
|
||||
throw Exceptions::Exception{"Invalid memory region type"};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,9 +7,8 @@ class ExcludedMemoryRegion: public MemoryRegion
|
||||
public:
|
||||
ExcludedMemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
);
|
||||
|
||||
ExcludedMemoryRegion(const QJsonObject& jsonObject);
|
||||
explicit ExcludedMemoryRegion(const QJsonObject& jsonObject);
|
||||
};
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
|
||||
FocusedMemoryRegion::FocusedMemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
)
|
||||
: MemoryRegion(name, memoryType, MemoryRegionType::FOCUSED, addressRange)
|
||||
: MemoryRegion(
|
||||
name,
|
||||
MemoryRegionType::FOCUSED,
|
||||
addressRange
|
||||
)
|
||||
{}
|
||||
|
||||
FocusedMemoryRegion::FocusedMemoryRegion(const QJsonObject& jsonObject)
|
||||
@@ -16,11 +19,11 @@ FocusedMemoryRegion::FocusedMemoryRegion(const QJsonObject& jsonObject)
|
||||
using Exceptions::Exception;
|
||||
|
||||
if (this->type != MemoryRegionType::FOCUSED) {
|
||||
throw Exception("Invalid memory region type");
|
||||
throw Exception{"Invalid memory region type"};
|
||||
}
|
||||
|
||||
if (!jsonObject.contains("dataType") || !jsonObject.contains("endianness")) {
|
||||
throw Exception("Missing data");
|
||||
throw Exception{"Missing data"};
|
||||
}
|
||||
|
||||
this->dataType = FocusedMemoryRegion::regionDataTypesByName.at(jsonObject.find("dataType")->toString());
|
||||
|
||||
@@ -22,12 +22,10 @@ public:
|
||||
|
||||
FocusedMemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
);
|
||||
|
||||
FocusedMemoryRegion(const QJsonObject& jsonObject);
|
||||
|
||||
explicit FocusedMemoryRegion(const QJsonObject& jsonObject);
|
||||
QJsonObject toJson() const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Widgets
|
||||
static constexpr int leftMargin = 10;
|
||||
|
||||
const auto addressItemCount = this->addressItems.size();
|
||||
decltype(this->addressItems)::size_type rowIndex = 0;
|
||||
auto rowIndex = decltype(this->addressItems)::size_type{0};
|
||||
|
||||
for (const auto& byteItem : firstByteItemByLine) {
|
||||
auto addressItem = addressItemCount > 0 && rowIndex <= addressItemCount - 1
|
||||
@@ -49,8 +49,8 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void ByteAddressContainer::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||
static const auto backgroundColor = QColor(0x35, 0x36, 0x33);
|
||||
static const auto borderColor = QColor(0x41, 0x42, 0x3F);
|
||||
static const auto backgroundColor = QColor{0x35, 0x36, 0x33};
|
||||
static const auto borderColor = QColor{0x41, 0x42, 0x3F};
|
||||
|
||||
painter->setPen(Qt::PenStyle::NoPen);
|
||||
painter->setBrush(backgroundColor);
|
||||
|
||||
@@ -15,15 +15,10 @@ namespace Widgets
|
||||
public:
|
||||
static constexpr int WIDTH = 88;
|
||||
|
||||
ByteAddressContainer(const HexViewerSharedState& hexViewerState);
|
||||
explicit ByteAddressContainer(const HexViewerSharedState& hexViewerState);
|
||||
|
||||
[[nodiscard]] QRectF boundingRect() const override {
|
||||
return QRectF(
|
||||
0,
|
||||
0,
|
||||
ByteAddressContainer::WIDTH,
|
||||
this->scene()->height()
|
||||
);
|
||||
return {0, 0, ByteAddressContainer::WIDTH, this->scene()->height()};
|
||||
}
|
||||
|
||||
void adjustAddressLabels(const std::vector<const ByteItem*>& firstByteItemByLine);
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Widgets
|
||||
{}
|
||||
|
||||
void ByteAddressItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||
static auto fontColor = QColor(0x8F, 0x91, 0x92);
|
||||
static auto font = QFont("'Ubuntu', sans-serif");
|
||||
static auto fontColor = QColor{0x8F, 0x91, 0x92};
|
||||
static auto font = QFont{"'Ubuntu', sans-serif"};
|
||||
font.setPixelSize(12);
|
||||
|
||||
painter->setRenderHints(
|
||||
@@ -28,7 +28,7 @@ namespace Widgets
|
||||
Qt::AlignLeft,
|
||||
this->hexViewerState.settings.addressLabelType == AddressType::RELATIVE
|
||||
? "0x" + QString::number(
|
||||
this->address - this->hexViewerState.memoryDescriptor.addressRange.startAddress,
|
||||
this->address - this->hexViewerState.memorySegmentDescriptor.addressRange.startAddress,
|
||||
16
|
||||
).rightJustified(8, '0').toUpper()
|
||||
: "0x" + QString::number(this->address, 16).rightJustified(8, '0').toUpper()
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
#include "ByteItem.hpp"
|
||||
#include "HexViewerSharedState.hpp"
|
||||
|
||||
@@ -19,12 +21,7 @@ namespace Widgets
|
||||
explicit ByteAddressItem(const HexViewerSharedState& hexViewerState, QGraphicsItem* parent);
|
||||
|
||||
[[nodiscard]] QRectF boundingRect() const override {
|
||||
return {
|
||||
0,
|
||||
0,
|
||||
ByteAddressItem::WIDTH,
|
||||
ByteAddressItem::HEIGHT
|
||||
};
|
||||
return {0, 0, ByteAddressItem::WIDTH, ByteAddressItem::HEIGHT};
|
||||
}
|
||||
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace Widgets
|
||||
|
||||
explicit ByteItem(Targets::TargetMemoryAddress address);
|
||||
|
||||
QSize size() const override {
|
||||
return QSize(ByteItem::WIDTH, ByteItem::HEIGHT);
|
||||
[[nodiscard]] QSize size() const override {
|
||||
return {ByteItem::WIDTH, ByteItem::HEIGHT};
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
@@ -56,11 +56,11 @@ namespace Widgets
|
||||
|
||||
const auto regionStartAddress = this->focusedMemoryRegion.addressRange.startAddress;
|
||||
const auto regionEndAddress = this->focusedMemoryRegion.addressRange.endAddress;
|
||||
const auto startIndex = regionStartAddress - hexViewerState.memoryDescriptor.addressRange.startAddress;
|
||||
auto value = Targets::TargetMemoryBuffer(
|
||||
const auto startIndex = regionStartAddress - hexViewerState.memorySegmentDescriptor.addressRange.startAddress;
|
||||
auto value = Targets::TargetMemoryBuffer{
|
||||
hexViewerState.data->begin() + startIndex,
|
||||
hexViewerState.data->begin() + startIndex + (regionEndAddress - regionStartAddress + 1)
|
||||
);
|
||||
};
|
||||
|
||||
if (this->focusedMemoryRegion.endianness == Targets::TargetMemoryEndianness::LITTLE) {
|
||||
std::reverse(value.begin(), value.end());
|
||||
@@ -90,7 +90,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
if (valueSize <= 4) {
|
||||
std::int32_t integerValue = 0;
|
||||
auto integerValue = std::int32_t{0};
|
||||
for (const auto& byte : value) {
|
||||
integerValue = (integerValue << 8) | byte;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace Widgets
|
||||
break;
|
||||
}
|
||||
|
||||
std::int64_t integerValue = 0;
|
||||
auto integerValue = std::int64_t{0};
|
||||
for (const auto& byte : value) {
|
||||
integerValue = (integerValue << 8) | byte;
|
||||
}
|
||||
@@ -138,40 +138,40 @@ namespace Widgets
|
||||
|
||||
QMargins FocusedRegionGroupItem::groupMargins(
|
||||
const HexViewerSharedState* hexViewerState,
|
||||
const int maximumWidth
|
||||
int maximumWidth
|
||||
) const {
|
||||
if (hexViewerState->settings.displayAnnotations) {
|
||||
constexpr auto averageSymbolWidth = 8;
|
||||
const auto nameLabelWidth = static_cast<int>(this->focusedMemoryRegion.name.size() * averageSymbolWidth);
|
||||
const auto valueLabelWidth = static_cast<int>(
|
||||
this->valueLabel.has_value() ? this->valueLabel->size() * averageSymbolWidth : 0
|
||||
);
|
||||
|
||||
const auto minimumWidth = std::min(std::max(nameLabelWidth, valueLabelWidth), maximumWidth);
|
||||
|
||||
const auto byteItemSize = (this->focusedMemoryRegion.addressRange.endAddress
|
||||
- this->focusedMemoryRegion.addressRange.startAddress + 1);
|
||||
const auto estimatedWidth = static_cast<int>(
|
||||
byteItemSize * (ByteItem::WIDTH + ByteItem::RIGHT_MARGIN) - ByteItem::RIGHT_MARGIN
|
||||
);
|
||||
|
||||
const auto annotationMargin = std::min(
|
||||
static_cast<int>(
|
||||
estimatedWidth < minimumWidth ? minimumWidth - estimatedWidth : 0
|
||||
),
|
||||
std::max(maximumWidth - estimatedWidth, 0)
|
||||
);
|
||||
|
||||
return QMargins(
|
||||
annotationMargin / 2,
|
||||
this->focusedMemoryRegion.dataType != MemoryRegionDataType::UNKNOWN
|
||||
? FocusedRegionGroupItem::ANNOTATION_HEIGHT
|
||||
: 0,
|
||||
annotationMargin / 2,
|
||||
FocusedRegionGroupItem::ANNOTATION_HEIGHT
|
||||
);
|
||||
if (!hexViewerState->settings.displayAnnotations) {
|
||||
return QMargins{0, 0, 0, 0};
|
||||
}
|
||||
|
||||
return QMargins(0, 0, 0, 0);
|
||||
constexpr auto averageSymbolWidth = 8;
|
||||
const auto nameLabelWidth = static_cast<int>(this->focusedMemoryRegion.name.size() * averageSymbolWidth);
|
||||
const auto valueLabelWidth = static_cast<int>(
|
||||
this->valueLabel.has_value() ? this->valueLabel->size() * averageSymbolWidth : 0
|
||||
);
|
||||
|
||||
const auto minimumWidth = std::min(std::max(nameLabelWidth, valueLabelWidth), maximumWidth);
|
||||
|
||||
const auto byteItemSize = (this->focusedMemoryRegion.addressRange.endAddress
|
||||
- this->focusedMemoryRegion.addressRange.startAddress + 1);
|
||||
const auto estimatedWidth = static_cast<int>(
|
||||
byteItemSize * (ByteItem::WIDTH + ByteItem::RIGHT_MARGIN) - ByteItem::RIGHT_MARGIN
|
||||
);
|
||||
|
||||
const auto annotationMargin = std::min(
|
||||
static_cast<int>(
|
||||
estimatedWidth < minimumWidth ? minimumWidth - estimatedWidth : 0
|
||||
),
|
||||
std::max(maximumWidth - estimatedWidth, 0)
|
||||
);
|
||||
|
||||
return QMargins{
|
||||
annotationMargin / 2,
|
||||
this->focusedMemoryRegion.dataType != MemoryRegionDataType::UNKNOWN
|
||||
? FocusedRegionGroupItem::ANNOTATION_HEIGHT
|
||||
: 0,
|
||||
annotationMargin / 2,
|
||||
FocusedRegionGroupItem::ANNOTATION_HEIGHT
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,6 @@ namespace Widgets
|
||||
void refreshValue(const HexViewerSharedState& hexViewerState);
|
||||
|
||||
protected:
|
||||
QMargins groupMargins(const HexViewerSharedState* hexViewerState, const int maximumWidth) const override;
|
||||
QMargins groupMargins(const HexViewerSharedState* hexViewerState, int maximumWidth) const override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,16 +8,16 @@ namespace Widgets
|
||||
}
|
||||
}
|
||||
|
||||
void GroupItem::adjustItemPositions(const int maximumWidth, const HexViewerSharedState* hexViewerState) {
|
||||
void GroupItem::adjustItemPositions(int maximumWidth, const HexViewerSharedState* hexViewerState) {
|
||||
const auto margins = this->groupMargins(hexViewerState, maximumWidth);
|
||||
|
||||
int width = margins.left();
|
||||
int height = margins.top();
|
||||
|
||||
this->multiLine = false;
|
||||
auto position = QPoint(margins.left(), margins.top());
|
||||
auto position = QPoint{margins.left(), margins.top()};
|
||||
|
||||
auto currentLineItems = std::vector<HexViewerItem*>();
|
||||
auto currentLineItems = std::vector<HexViewerItem*>{};
|
||||
const ByteItem* lastByteItem = nullptr;
|
||||
|
||||
for (const auto& item : this->items) {
|
||||
@@ -69,11 +69,11 @@ namespace Widgets
|
||||
lastByteItem = byteItem;
|
||||
}
|
||||
|
||||
this->groupSize = QSize(width + margins.right(), height + margins.bottom());
|
||||
this->groupSize = QSize{width + margins.right(), height + margins.bottom()};
|
||||
}
|
||||
|
||||
std::vector<HexViewerItem*> GroupItem::flattenedItems() const {
|
||||
auto flattenedItems = std::vector<HexViewerItem*>();
|
||||
auto flattenedItems = std::vector<HexViewerItem*>{};
|
||||
|
||||
for (const auto& item : this->items) {
|
||||
flattenedItems.push_back(item);
|
||||
@@ -88,10 +88,7 @@ namespace Widgets
|
||||
return flattenedItems;
|
||||
}
|
||||
|
||||
GroupItem::GroupItem(
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
HexViewerItem* parent
|
||||
)
|
||||
GroupItem::GroupItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent)
|
||||
: HexViewerItem(startAddress, parent)
|
||||
{}
|
||||
|
||||
|
||||
@@ -22,29 +22,29 @@ namespace Widgets
|
||||
|
||||
~GroupItem();
|
||||
|
||||
QSize size() const override {
|
||||
[[nodiscard]] QSize size() const override {
|
||||
return this->groupSize;
|
||||
}
|
||||
|
||||
virtual void adjustItemPositions(const int maximumWidth, const HexViewerSharedState* hexViewerState);
|
||||
virtual void adjustItemPositions(int maximumWidth, const HexViewerSharedState* hexViewerState);
|
||||
|
||||
[[nodiscard]] std::vector<HexViewerItem*> flattenedItems() const;
|
||||
|
||||
protected:
|
||||
GroupItem(
|
||||
explicit GroupItem(
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
HexViewerItem* parent = nullptr
|
||||
);
|
||||
|
||||
virtual QMargins groupMargins(const HexViewerSharedState* hexViewerState, const int maximumWidth) const {
|
||||
return QMargins(0, 0, 0, 0);
|
||||
virtual QMargins groupMargins(const HexViewerSharedState* hexViewerState, int maximumWidth) const {
|
||||
return {0, 0, 0, 0};
|
||||
}
|
||||
|
||||
virtual bool positionOnNewLine(const int maximumWidth) {
|
||||
return this->multiLine;
|
||||
}
|
||||
|
||||
ByteItem* firstByteItem() const;
|
||||
[[nodiscard]] ByteItem* firstByteItem() const;
|
||||
|
||||
void sortItems();
|
||||
};
|
||||
|
||||
@@ -18,15 +18,15 @@ namespace Widgets
|
||||
static constexpr int RIGHT_MARGIN = 5;
|
||||
static constexpr int BOTTOM_MARGIN = 5;
|
||||
|
||||
const Targets::TargetMemoryAddress startAddress = 0;
|
||||
const Targets::TargetMemoryAddress startAddress;
|
||||
|
||||
HexViewerItem* parent = nullptr;
|
||||
|
||||
QPoint relativePosition = {};
|
||||
|
||||
HexViewerItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent = nullptr);
|
||||
QPoint position() const;
|
||||
virtual QSize size() const = 0;
|
||||
explicit HexViewerItem(Targets::TargetMemoryAddress startAddress, HexViewerItem* parent = nullptr);
|
||||
[[nodiscard]] QPoint position() const;
|
||||
[[nodiscard]] virtual QSize size() const = 0;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Widgets
|
||||
);
|
||||
|
||||
if (startGridPointIndex >= gridPointCount) {
|
||||
return HexViewerItemIndex::ItemRangeType();
|
||||
return HexViewerItemIndex::ItemRangeType{};
|
||||
}
|
||||
|
||||
const auto endGridPointIndex = static_cast<decltype(this->byteItemGrid)::size_type>(std::min(
|
||||
@@ -44,12 +44,12 @@ namespace Widgets
|
||||
gridPointCount - 1
|
||||
));
|
||||
|
||||
return HexViewerItemIndex::ItemRangeType(
|
||||
return HexViewerItemIndex::ItemRangeType{
|
||||
this->byteItemGrid[startGridPointIndex],
|
||||
endGridPointIndex == gridPointCount - 1
|
||||
? this->flattenedItems.end()
|
||||
: this->byteItemGrid[endGridPointIndex]
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
ByteItem* HexViewerItemIndex::byteItemAt(const QPointF& position) const {
|
||||
@@ -115,11 +115,11 @@ namespace Widgets
|
||||
// Sanity check
|
||||
assert(gridPointCount > gridPointIndex);
|
||||
|
||||
return static_cast<ByteItem*>(*(this->byteItemGrid[gridPointIndex]));
|
||||
return dynamic_cast<ByteItem*>(*(this->byteItemGrid[gridPointIndex]));
|
||||
}
|
||||
|
||||
std::vector<ByteItem*> HexViewerItemIndex::intersectingByteItems(const QRectF& rect) const {
|
||||
auto output = std::vector<ByteItem*>();
|
||||
auto output = std::vector<ByteItem*>{};
|
||||
|
||||
const auto yStart = static_cast<int>(std::max(rect.y(), static_cast<qreal>(0)));
|
||||
const auto yEnd = static_cast<int>(std::max(rect.y() + rect.height(), static_cast<qreal>(0)));
|
||||
@@ -127,7 +127,7 @@ namespace Widgets
|
||||
const auto items = this->items(yStart, yEnd);
|
||||
|
||||
for (auto& item : items) {
|
||||
const auto itemRect = QRectF(item->position(), item->size());
|
||||
const auto itemRect = QRectF{item->position(), item->size()};
|
||||
|
||||
if (itemRect.y() > yEnd) {
|
||||
break;
|
||||
@@ -252,7 +252,7 @@ namespace Widgets
|
||||
|
||||
if (itemYEndPosition >= currentByteItemGridPoint) {
|
||||
// This byte item is the first to exceed or intersect with the currentByteItemGridPoint
|
||||
this->byteItemGrid.push_back(itemIt);
|
||||
this->byteItemGrid.emplace_back(itemIt);
|
||||
currentByteItemGridPoint += HexViewerItemIndex::GRID_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Widgets
|
||||
this->hexViewerState.hoveredByteItem != nullptr
|
||||
&& this->hexViewerState.settings.highlightHoveredRowAndCol
|
||||
) {
|
||||
static const auto hoverRectBackgroundColor = QColor(0x8E, 0x8B, 0x83, 45);
|
||||
static const auto hoverRectBackgroundColor = QColor{0x8E, 0x8B, 0x83, 45};
|
||||
|
||||
painter->setBrush(hoverRectBackgroundColor);
|
||||
painter->setPen(Qt::NoPen);
|
||||
@@ -108,7 +108,7 @@ namespace Widgets
|
||||
|
||||
void HexViewerItemRenderer::paintByteItem(const ByteItem* item, QPainter* painter) {
|
||||
const auto position = item->position();
|
||||
const auto boundingRect = QRect(position.x(), position.y(), ByteItem::WIDTH, ByteItem::HEIGHT);
|
||||
const auto boundingRect = QRect{position.x(), position.y(), ByteItem::WIDTH, ByteItem::HEIGHT};
|
||||
|
||||
painter->setOpacity(
|
||||
!this->isEnabled()
|
||||
@@ -133,7 +133,8 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
const auto byteIndex = item->startAddress - this->hexViewerState.memoryDescriptor.addressRange.startAddress;
|
||||
const auto byteIndex = item->startAddress
|
||||
- this->hexViewerState.memorySegmentDescriptor.addressRange.startAddress;
|
||||
const auto value = (*(this->hexViewerState.data))[byteIndex];
|
||||
|
||||
const auto hoveredPrimary = this->hexViewerState.hoveredByteItem == item;
|
||||
@@ -257,7 +258,7 @@ namespace Widgets
|
||||
const auto endItemPos = endItem->position();
|
||||
const auto endItemSize = endItem->size();
|
||||
|
||||
auto painterPath = QPainterPath();
|
||||
auto painterPath = QPainterPath{};
|
||||
|
||||
if (startItemPos.y() != endItemPos.y()) {
|
||||
// The highlighted range spans more than one line - draw the border around all lines containing the range
|
||||
@@ -288,7 +289,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
painter->setRenderHints(QPainter::RenderHint::Antialiasing | QPainter::RenderHint::SmoothPixmapTransform, true);
|
||||
painter->setPen(QPen(QColor(0x58, 0x58, 0x58), 2));
|
||||
painter->setPen(QPen{QColor{0x58, 0x58, 0x58}, 2});
|
||||
painter->setBrush(Qt::BrushStyle::NoBrush);
|
||||
painter->drawPath(painterPath);
|
||||
}
|
||||
@@ -304,10 +305,10 @@ namespace Widgets
|
||||
{
|
||||
auto labelText = item->focusedMemoryRegion.name;
|
||||
|
||||
static constexpr auto lineColor = QColor(0x4F, 0x4F, 0x4F);
|
||||
static constexpr auto labelFontColor = QColor(0x68, 0x68, 0x68);
|
||||
static constexpr auto lineColor = QColor{0x4F, 0x4F, 0x4F};
|
||||
static constexpr auto labelFontColor = QColor{0x68, 0x68, 0x68};
|
||||
|
||||
static auto labelFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto labelFont = QFont{"'Ubuntu', sans-serif"};
|
||||
labelFont.setPixelSize(12);
|
||||
|
||||
painter->setFont(labelFont);
|
||||
@@ -329,51 +330,50 @@ namespace Widgets
|
||||
const auto verticalLineYStart = position.y() + static_cast<int>(heightOffset);
|
||||
const auto verticalLineYEnd = position.y() + static_cast<int>(heightOffset + 5);
|
||||
|
||||
const auto labelRect = QRect(
|
||||
const auto labelRect = QRect{
|
||||
position.x() + (groupWidth - labelSize.width()) / 2,
|
||||
verticalLineYEnd + 10,
|
||||
labelSize.width(),
|
||||
labelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->setPen(lineColor);
|
||||
|
||||
if (item->focusedMemoryRegion.addressRange.startAddress !=
|
||||
item->focusedMemoryRegion.addressRange.endAddress) {
|
||||
if (item->focusedMemoryRegion.addressRange.startAddress != item->focusedMemoryRegion.addressRange.endAddress) {
|
||||
const auto lineStartX =
|
||||
position.x() + item->items.front()->relativePosition.x() + (ByteItem::WIDTH / 2);
|
||||
const auto lineEndX = item->multiLine
|
||||
? position.x() + groupWidth - (ByteItem::WIDTH / 2)
|
||||
: position.x() + item->items.back()->relativePosition.x() + (ByteItem::WIDTH / 2);
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYStart,
|
||||
lineStartX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineEndX,
|
||||
verticalLineYStart,
|
||||
lineEndX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYEnd,
|
||||
lineEndX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYEnd,
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYEnd + 4
|
||||
));
|
||||
});
|
||||
|
||||
painter->setPen(labelFontColor);
|
||||
painter->drawText(labelRect, Qt::AlignCenter, labelText);
|
||||
@@ -385,10 +385,10 @@ namespace Widgets
|
||||
|
||||
auto labelText = item->valueLabel.value_or("??");
|
||||
|
||||
static const auto lineColor = QColor(0x4F, 0x4F, 0x4F);
|
||||
static const auto labelFontColor = QColor(0x94, 0x6F, 0x30);
|
||||
static const auto lineColor = QColor{0x4F, 0x4F, 0x4F};
|
||||
static const auto labelFontColor = QColor{0x94, 0x6F, 0x30};
|
||||
|
||||
static auto labelFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto labelFont = QFont{"'Ubuntu', sans-serif"};
|
||||
labelFont.setPixelSize(12);
|
||||
labelFont.setItalic(true);
|
||||
|
||||
@@ -399,11 +399,7 @@ namespace Widgets
|
||||
auto labelSize = fontMetrics.size(Qt::TextSingleLine, labelText);
|
||||
if (labelSize.width() > groupWidth) {
|
||||
labelSize.setWidth(groupWidth);
|
||||
labelText = fontMetrics.elidedText(
|
||||
labelText,
|
||||
Qt::TextElideMode::ElideRight,
|
||||
groupWidth
|
||||
);
|
||||
labelText = fontMetrics.elidedText(labelText, Qt::TextElideMode::ElideRight, groupWidth);
|
||||
}
|
||||
|
||||
const auto heightOffset = FocusedRegionGroupItem::ANNOTATION_HEIGHT - 4;
|
||||
@@ -411,12 +407,12 @@ namespace Widgets
|
||||
const auto verticalLineYStart = position.y() + static_cast<int>(heightOffset - 5);
|
||||
const auto verticalLineYEnd = position.y() + static_cast<int>(heightOffset);
|
||||
|
||||
const auto labelRect = QRect(
|
||||
const auto labelRect = QRect{
|
||||
position.x() + (groupWidth - labelSize.width()) / 2,
|
||||
verticalLineYStart - 10 - labelSize.height(),
|
||||
labelSize.width(),
|
||||
labelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->setPen(lineColor);
|
||||
|
||||
@@ -426,26 +422,26 @@ namespace Widgets
|
||||
? position.x() + groupWidth - + (ByteItem::WIDTH / 2)
|
||||
: position.x() + item->items.back()->relativePosition.x() + (ByteItem::WIDTH / 2);
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYStart,
|
||||
lineStartX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineEndX,
|
||||
verticalLineYStart,
|
||||
lineEndX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYStart,
|
||||
lineEndX,
|
||||
verticalLineYStart
|
||||
));
|
||||
});
|
||||
|
||||
/*
|
||||
* Draw a circle just above the first byte item of the region, to indicate the first byte used to generate
|
||||
@@ -455,23 +451,23 @@ namespace Widgets
|
||||
|
||||
constexpr auto radius = 2;
|
||||
painter->drawEllipse(
|
||||
QPoint(
|
||||
QPoint{
|
||||
item->focusedMemoryRegion.endianness == TargetMemoryEndianness::BIG ? lineStartX : lineEndX,
|
||||
!item->multiLine || item->focusedMemoryRegion.endianness == TargetMemoryEndianness::BIG
|
||||
? verticalLineYStart
|
||||
: position.y() + item->groupSize.height() - FocusedRegionGroupItem::ANNOTATION_HEIGHT + 4 + 5
|
||||
),
|
||||
},
|
||||
radius,
|
||||
radius
|
||||
);
|
||||
}
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYStart - 4,
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYStart
|
||||
));
|
||||
});
|
||||
|
||||
painter->setPen(labelFontColor);
|
||||
painter->drawText(labelRect, Qt::AlignCenter, labelText);
|
||||
@@ -481,30 +477,31 @@ namespace Widgets
|
||||
void HexViewerItemRenderer::paintStackMemoryGroupItem(const StackMemoryGroupItem* item, QPainter* painter) {
|
||||
const auto position = item->position();
|
||||
|
||||
const auto headingText = QString("Stack Memory");
|
||||
const auto headingText = QString{"Stack Memory"};
|
||||
|
||||
const auto stackSize = this->hexViewerState.memoryDescriptor.addressRange.endAddress - item->startAddress + 1;
|
||||
const auto& memoryCapacity = this->hexViewerState.memoryDescriptor.size();
|
||||
const auto stackSize = this->hexViewerState.memorySegmentDescriptor.addressRange.endAddress
|
||||
- item->startAddress + 1;
|
||||
const auto& memoryCapacity = this->hexViewerState.memorySegmentDescriptor.size();
|
||||
|
||||
const auto stackSizeHeadingText = QString("Stack size:");
|
||||
const auto stackSizeHeadingText = QString{"Stack size:"};
|
||||
const auto stackSizeValueText = QString::number(stackSize) + " byte(s) ("
|
||||
+ QString::number(static_cast<float>(stackSize) / static_cast<float>(memoryCapacity / 100), 'f' , 1)
|
||||
+ "% of memory capacity)";
|
||||
|
||||
const auto stackPointerHeadingText = QString("Stack pointer:");
|
||||
const auto stackPointerHeadingText = QString{"Stack pointer:"};
|
||||
const auto stackPointerValueText = "0x" + QString::number(
|
||||
item->stackPointer,
|
||||
16
|
||||
).rightJustified(8, '0').toUpper();
|
||||
|
||||
static constexpr auto lineColor = QColor(0x4F, 0x4F, 0x4F);
|
||||
static constexpr auto headingLabelFontColor = QColor(0x6F, 0x6F, 0x6F);
|
||||
static constexpr auto valueLabelFontColor = QColor(0x94, 0x6F, 0x30, 230);
|
||||
static constexpr auto lineColor = QColor{0x4F, 0x4F, 0x4F};
|
||||
static constexpr auto headingLabelFontColor = QColor{0x6F, 0x6F, 0x6F};
|
||||
static constexpr auto valueLabelFontColor = QColor{0x94, 0x6F, 0x30, 230};
|
||||
|
||||
static auto headingLabelFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto headingLabelFont = QFont{"'Ubuntu', sans-serif"};
|
||||
headingLabelFont.setPixelSize(13);
|
||||
|
||||
static auto valueFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto valueFont = QFont{"'Ubuntu', sans-serif"};
|
||||
valueFont.setPixelSize(13);
|
||||
valueFont.setItalic(true);
|
||||
|
||||
@@ -534,75 +531,75 @@ namespace Widgets
|
||||
const auto lineStartX = position.x() + ByteItem::WIDTH / 2;
|
||||
const auto lineEndX = position.x() + groupWidth - (ByteItem::WIDTH / 2);
|
||||
|
||||
const auto labelRect = QRect(
|
||||
const auto labelRect = QRect{
|
||||
position.x() + (groupWidth - headingLabelSize.width()) / 2,
|
||||
verticalLineYStart - stackPointerHeadingLabelSize.height() - stackSizeHeadingLabelSize.height()
|
||||
- headingLabelSize.height() - labelLineHeight - (labelBottomMargin * 2) - 3,
|
||||
headingLabelSize.width(),
|
||||
headingLabelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
const auto stackPointerHeadingLabelRect = QRect(
|
||||
const auto stackPointerHeadingLabelRect = QRect{
|
||||
labelRect.left() + (labelRect.width() / 2) - (
|
||||
(stackPointerHeadingLabelSize.width() + stackPointerLabelSize.width()) / 2
|
||||
),
|
||||
labelRect.bottom() + labelBottomMargin,
|
||||
stackPointerHeadingLabelSize.width(),
|
||||
stackPointerHeadingLabelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
const auto stackPointerValueLabelRect = QRect(
|
||||
const auto stackPointerValueLabelRect = QRect{
|
||||
stackPointerHeadingLabelRect.right() + labelRightMargin,
|
||||
labelRect.bottom() + labelBottomMargin,
|
||||
stackPointerLabelSize.width(),
|
||||
stackPointerLabelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
const auto stackSizeHeadingLabelRect = QRect(
|
||||
const auto stackSizeHeadingLabelRect = QRect{
|
||||
labelRect.left() + (labelRect.width() / 2) - (
|
||||
(stackSizeHeadingLabelSize.width() + stackSizeLabelSize.width()) / 2
|
||||
),
|
||||
stackPointerHeadingLabelRect.bottom() + labelBottomMargin,
|
||||
stackSizeHeadingLabelSize.width(),
|
||||
stackSizeHeadingLabelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
const auto stackSizeValueLabelRect = QRect(
|
||||
const auto stackSizeValueLabelRect = QRect{
|
||||
stackSizeHeadingLabelRect.right() + labelRightMargin,
|
||||
stackPointerHeadingLabelRect.bottom() + labelBottomMargin,
|
||||
stackSizeLabelSize.width(),
|
||||
stackSizeLabelSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->setPen(lineColor);
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYStart,
|
||||
lineStartX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineEndX,
|
||||
verticalLineYStart,
|
||||
lineEndX,
|
||||
verticalLineYEnd
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
lineStartX,
|
||||
verticalLineYStart,
|
||||
lineEndX,
|
||||
verticalLineYStart
|
||||
));
|
||||
});
|
||||
|
||||
painter->drawLine(QLine(
|
||||
painter->drawLine(QLine{
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYStart - labelLineHeight,
|
||||
position.x() + groupWidth / 2,
|
||||
verticalLineYStart
|
||||
));
|
||||
});
|
||||
|
||||
painter->setPen(headingLabelFontColor);
|
||||
|
||||
@@ -623,77 +620,77 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
static constexpr auto standardBackgroundColor = QColor(0x32, 0x33, 0x30, 0);
|
||||
static constexpr auto selectedBackgroundColor = QColor(0x3C, 0x59, 0x5C, 255);
|
||||
static constexpr auto primaryHighlightedBackgroundColor = QColor(0x3B, 0x59, 0x37, 255);
|
||||
static constexpr auto groupedBackgroundColor = QColor(0x44, 0x44, 0x41, 255);
|
||||
static constexpr auto stackMemoryBackgroundColor = QColor(0x44, 0x44, 0x41, 200);
|
||||
static constexpr auto stackMemoryBarColor = QColor(0x67, 0x57, 0x20, 255);
|
||||
static constexpr auto changedMemoryBackgroundColor = QColor(0x5C, 0x49, 0x5D, 200);
|
||||
static constexpr auto changedMemoryFadedBackgroundColor = QColor(0x5C, 0x49, 0x5D, 125);
|
||||
static constexpr auto standardBackgroundColor = QColor{0x32, 0x33, 0x30, 0};
|
||||
static constexpr auto selectedBackgroundColor = QColor{0x3C, 0x59, 0x5C, 255};
|
||||
static constexpr auto primaryHighlightedBackgroundColor = QColor{0x3B, 0x59, 0x37, 255};
|
||||
static constexpr auto groupedBackgroundColor = QColor{0x44, 0x44, 0x41, 255};
|
||||
static constexpr auto stackMemoryBackgroundColor = QColor{0x44, 0x44, 0x41, 200};
|
||||
static constexpr auto stackMemoryBarColor = QColor{0x67, 0x57, 0x20, 255};
|
||||
static constexpr auto changedMemoryBackgroundColor = QColor{0x5C, 0x49, 0x5D, 200};
|
||||
static constexpr auto changedMemoryFadedBackgroundColor = QColor{0x5C, 0x49, 0x5D, 125};
|
||||
|
||||
static const auto hoveredStackMemoryBackgroundColor = QColor(
|
||||
static const auto hoveredStackMemoryBackgroundColor = QColor{
|
||||
stackMemoryBackgroundColor.red(),
|
||||
stackMemoryBackgroundColor.green(),
|
||||
stackMemoryBackgroundColor.blue(),
|
||||
255
|
||||
);
|
||||
};
|
||||
|
||||
static constexpr auto hoveredBackgroundColor = QColor(0x8E, 0x8B, 0x83, 70);
|
||||
static constexpr auto hoveredBackgroundColor = QColor{0x8E, 0x8B, 0x83, 70};
|
||||
|
||||
static constexpr auto standardFontColor = QColor(0xAF, 0xB1, 0xB3);
|
||||
static constexpr auto fadedFontColor = QColor(0xAF, 0xB1, 0xB3, 100);
|
||||
static constexpr auto asciiFontColor = QColor(0xA7, 0x77, 0x26);
|
||||
static constexpr auto changedMemoryAsciiFontColor = QColor(0xB7, 0x7F, 0x21);
|
||||
static constexpr auto standardFontColor = QColor{0xAF, 0xB1, 0xB3};
|
||||
static constexpr auto fadedFontColor = QColor{0xAF, 0xB1, 0xB3, 100};
|
||||
static constexpr auto asciiFontColor = QColor{0xA7, 0x77, 0x26};
|
||||
static constexpr auto changedMemoryAsciiFontColor = QColor{0xB7, 0x7F, 0x21};
|
||||
|
||||
const auto byteItemRect = QRect(0, 0, ByteItem::WIDTH, ByteItem::HEIGHT);
|
||||
const auto byteItemRect = QRect{0, 0, ByteItem::WIDTH, ByteItem::HEIGHT};
|
||||
const auto byteItemSize = byteItemRect.size();
|
||||
|
||||
auto standardTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto standardTemplatePixmap = QPixmap{byteItemSize};
|
||||
standardTemplatePixmap.fill(standardBackgroundColor);
|
||||
|
||||
auto primaryHighlightedTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto primaryHighlightedTemplatePixmap = QPixmap{byteItemSize};
|
||||
primaryHighlightedTemplatePixmap.fill(primaryHighlightedBackgroundColor);
|
||||
|
||||
auto selectedTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto selectedTemplatePixmap = QPixmap{byteItemSize};
|
||||
selectedTemplatePixmap.fill(selectedBackgroundColor);
|
||||
|
||||
auto groupedTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto groupedTemplatePixmap = QPixmap{byteItemSize};
|
||||
groupedTemplatePixmap.fill(groupedBackgroundColor);
|
||||
|
||||
auto stackMemoryTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto stackMemoryTemplatePixmap = QPixmap{byteItemSize};
|
||||
stackMemoryTemplatePixmap.fill(stackMemoryBackgroundColor);
|
||||
|
||||
{
|
||||
auto painter = QPainter(&stackMemoryTemplatePixmap);
|
||||
auto painter = QPainter{&stackMemoryTemplatePixmap};
|
||||
painter.setBrush(stackMemoryBarColor);
|
||||
painter.setPen(Qt::PenStyle::NoPen);
|
||||
painter.drawRect(0, byteItemSize.height() - 3, byteItemSize.width(), 3);
|
||||
}
|
||||
|
||||
auto changedMemoryTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto changedMemoryTemplatePixmap = QPixmap{byteItemSize};
|
||||
changedMemoryTemplatePixmap.fill(changedMemoryBackgroundColor);
|
||||
|
||||
auto changedMemoryFadedTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto changedMemoryFadedTemplatePixmap = QPixmap{byteItemSize};
|
||||
changedMemoryFadedTemplatePixmap.fill(changedMemoryFadedBackgroundColor);
|
||||
|
||||
auto hoveredStackMemoryTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto hoveredStackMemoryTemplatePixmap = QPixmap{byteItemSize};
|
||||
hoveredStackMemoryTemplatePixmap.fill(hoveredStackMemoryBackgroundColor);
|
||||
|
||||
auto hoveredPrimaryTemplatePixmap = QPixmap(byteItemSize);
|
||||
auto hoveredPrimaryTemplatePixmap = QPixmap{byteItemSize};
|
||||
hoveredPrimaryTemplatePixmap.fill(hoveredBackgroundColor);
|
||||
|
||||
static auto font = QFont("'Ubuntu', sans-serif", 8);
|
||||
static auto font = QFont{"'Ubuntu', sans-serif", 8};
|
||||
|
||||
for (std::uint16_t value = 0x00; value <= 0xFF; ++value) {
|
||||
for (auto value = std::uint16_t{0}; value <= 0xFF; ++value) {
|
||||
const auto hexValue = QString::number(value, 16).rightJustified(2, '0').toUpper();
|
||||
const auto asciiValue = value >= 32 && value <= 126
|
||||
? std::optional("'" + QString(QChar(value)) + "'")
|
||||
? std::optional{"'" + QString{QChar{value}} + "'"}
|
||||
: std::nullopt;
|
||||
|
||||
{
|
||||
auto standardPixmap = standardTemplatePixmap;
|
||||
auto painter = QPainter(&standardPixmap);
|
||||
auto painter = QPainter{&standardPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -703,7 +700,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto selectedPixmap = selectedTemplatePixmap;
|
||||
auto painter = QPainter(&selectedPixmap);
|
||||
auto painter = QPainter{&selectedPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -713,7 +710,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto primaryHighlightedPixmap = primaryHighlightedTemplatePixmap;
|
||||
auto painter = QPainter(&primaryHighlightedPixmap);
|
||||
auto painter = QPainter{&primaryHighlightedPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -723,7 +720,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto groupedPixmap = groupedTemplatePixmap;
|
||||
auto painter = QPainter(&groupedPixmap);
|
||||
auto painter = QPainter{&groupedPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -733,7 +730,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto stackMemoryPixmap = stackMemoryTemplatePixmap;
|
||||
auto painter = QPainter(&stackMemoryPixmap);
|
||||
auto painter = QPainter{&stackMemoryPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -743,7 +740,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto changedMemoryPixmap = changedMemoryTemplatePixmap;
|
||||
auto painter = QPainter(&changedMemoryPixmap);
|
||||
auto painter = QPainter{&changedMemoryPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -753,7 +750,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto hoveredPrimaryPixmap = hoveredPrimaryTemplatePixmap;
|
||||
auto painter = QPainter(&hoveredPrimaryPixmap);
|
||||
auto painter = QPainter{&hoveredPrimaryPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, hexValue);
|
||||
@@ -763,7 +760,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto standardAsciiPixmap = standardTemplatePixmap;
|
||||
auto painter = QPainter(&standardAsciiPixmap);
|
||||
auto painter = QPainter{&standardAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -773,7 +770,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto selectedAsciiPixmap = selectedTemplatePixmap;
|
||||
auto painter = QPainter(&selectedAsciiPixmap);
|
||||
auto painter = QPainter{&selectedAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -783,7 +780,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto primaryHighlightedAsciiPixmap = primaryHighlightedTemplatePixmap;
|
||||
auto painter = QPainter(&primaryHighlightedAsciiPixmap);
|
||||
auto painter = QPainter{&primaryHighlightedAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -795,7 +792,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto groupedAsciiPixmap = groupedTemplatePixmap;
|
||||
auto painter = QPainter(&groupedAsciiPixmap);
|
||||
auto painter = QPainter{&groupedAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -805,7 +802,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto stackMemoryAsciiPixmap = stackMemoryTemplatePixmap;
|
||||
auto painter = QPainter(&stackMemoryAsciiPixmap);
|
||||
auto painter = QPainter{&stackMemoryAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -818,7 +815,7 @@ namespace Widgets
|
||||
? changedMemoryTemplatePixmap
|
||||
: changedMemoryFadedTemplatePixmap;
|
||||
|
||||
auto painter = QPainter(&changedMemoryAsciiPixmap);
|
||||
auto painter = QPainter{&changedMemoryAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? changedMemoryAsciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -828,7 +825,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
auto hoveredPrimaryAsciiPixmap = hoveredPrimaryTemplatePixmap;
|
||||
auto painter = QPainter(&hoveredPrimaryAsciiPixmap);
|
||||
auto painter = QPainter{&hoveredPrimaryAsciiPixmap};
|
||||
painter.setFont(font);
|
||||
painter.setPen(asciiValue.has_value() ? asciiFontColor : fadedFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, asciiValue.value_or(hexValue));
|
||||
@@ -839,7 +836,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
HexViewerItemRenderer::missingDataPixmap = standardTemplatePixmap;
|
||||
auto painter = QPainter(&HexViewerItemRenderer::missingDataPixmap.value());
|
||||
auto painter = QPainter{&HexViewerItemRenderer::missingDataPixmap.value()};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, "??");
|
||||
@@ -847,7 +844,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
HexViewerItemRenderer::selectedMissingDataPixmap = selectedTemplatePixmap;
|
||||
auto painter = QPainter(&HexViewerItemRenderer::selectedMissingDataPixmap.value());
|
||||
auto painter = QPainter{&HexViewerItemRenderer::selectedMissingDataPixmap.value()};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, "??");
|
||||
@@ -855,7 +852,7 @@ namespace Widgets
|
||||
|
||||
{
|
||||
HexViewerItemRenderer::primaryHighlightedMissingDataPixmap = primaryHighlightedTemplatePixmap;
|
||||
auto painter = QPainter(&HexViewerItemRenderer::primaryHighlightedMissingDataPixmap.value());
|
||||
auto painter = QPainter{&HexViewerItemRenderer::primaryHighlightedMissingDataPixmap.value()};
|
||||
painter.setFont(font);
|
||||
painter.setPen(standardFontColor);
|
||||
painter.drawText(byteItemRect, Qt::AlignCenter, "??");
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Widgets
|
||||
);
|
||||
|
||||
[[nodiscard]] QRectF boundingRect() const override {
|
||||
return QRectF(0, 0, this->size.width(), this->size.height());
|
||||
return QRectF{0, 0, static_cast<qreal>(this->size.width()), static_cast<qreal>(this->size.height())};
|
||||
}
|
||||
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
#include <optional>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
|
||||
#include "HexViewerWidgetSettings.hpp"
|
||||
|
||||
namespace Widgets
|
||||
@@ -12,7 +15,9 @@ namespace Widgets
|
||||
struct HexViewerSharedState
|
||||
{
|
||||
public:
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data;
|
||||
|
||||
HexViewerWidgetSettings& settings;
|
||||
@@ -23,11 +28,13 @@ namespace Widgets
|
||||
std::set<Targets::TargetMemoryAddressRange> highlightedPrimaryAddressRanges;
|
||||
|
||||
HexViewerSharedState(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
HexViewerWidgetSettings& settings
|
||||
)
|
||||
: memoryDescriptor(memoryDescriptor)
|
||||
: addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, data(data)
|
||||
, settings(settings)
|
||||
{}
|
||||
|
||||
@@ -14,10 +14,14 @@ namespace Widgets
|
||||
{
|
||||
using namespace Exceptions;
|
||||
|
||||
using Targets::TargetMemoryDescriptor;
|
||||
using Targets::TargetAddressSpaceDescriptor;
|
||||
using Targets::TargetMemorySegmentDescriptor;
|
||||
using Targets::TargetState;
|
||||
|
||||
HexViewerWidget::HexViewerWidget(
|
||||
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
HexViewerWidgetSettings& settings,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
@@ -25,7 +29,9 @@ namespace Widgets
|
||||
QWidget* parent
|
||||
)
|
||||
: QWidget(parent)
|
||||
, targetMemoryDescriptor(targetMemoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, targetState(targetState)
|
||||
, data(data)
|
||||
, settings(settings)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
@@ -34,29 +40,29 @@ namespace Widgets
|
||||
this->setObjectName("hex-viewer-widget");
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
auto widgetUiFile = QFile(
|
||||
auto widgetUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget"
|
||||
+ "/UiFiles/HexViewerWidget.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto stylesheetFile = QFile(
|
||||
auto stylesheetFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget"
|
||||
+ "/Stylesheets/HexViewerWidget.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!widgetUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open HexViewerWidget UI file");
|
||||
throw Exception{"Failed to open HexViewerWidget UI file"};
|
||||
}
|
||||
|
||||
if (!stylesheetFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open HexViewerWidget stylesheet file");
|
||||
throw Exception{"Failed to open HexViewerWidget stylesheet file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&widgetUiFile, this);
|
||||
this->setStyleSheet(stylesheetFile.readAll());
|
||||
this->container->setFixedSize(this->size());
|
||||
@@ -95,7 +101,7 @@ namespace Widgets
|
||||
this->setAnnotationsEnabled(this->settings.displayAnnotations);
|
||||
this->setDisplayAsciiEnabled(this->settings.displayAsciiValues);
|
||||
|
||||
if (this->targetMemoryDescriptor.type == Targets::TargetMemoryType::RAM) {
|
||||
if (this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::RAM) {
|
||||
this->groupStackMemoryButton->show();
|
||||
this->setStackMemoryGroupingEnabled(this->settings.groupStackMemory);
|
||||
|
||||
@@ -163,25 +169,20 @@ namespace Widgets
|
||||
&HexViewerWidget::onGoToAddressInputChanged
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
InsightSignals::instance(),
|
||||
&InsightSignals::targetStateUpdated,
|
||||
this,
|
||||
&HexViewerWidget::onTargetStateChanged
|
||||
);
|
||||
|
||||
this->show();
|
||||
}
|
||||
|
||||
void HexViewerWidget::init() {
|
||||
this->byteItemGraphicsView = new ItemGraphicsView(
|
||||
this->targetMemoryDescriptor,
|
||||
this->byteItemGraphicsView = new ItemGraphicsView{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this->data,
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->settings,
|
||||
this->container
|
||||
);
|
||||
};
|
||||
|
||||
this->byteItemGraphicsView->hide();
|
||||
|
||||
@@ -271,11 +272,6 @@ namespace Widgets
|
||||
QWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void HexViewerWidget::onTargetStateChanged(Targets::TargetState newState) {
|
||||
using Targets::TargetState;
|
||||
this->targetState = newState;
|
||||
}
|
||||
|
||||
void HexViewerWidget::setStackMemoryGroupingEnabled(bool enabled) {
|
||||
this->groupStackMemoryButton->setChecked(enabled);
|
||||
this->settings.groupStackMemory = enabled;
|
||||
@@ -336,12 +332,14 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
auto addressConversionOk = false;
|
||||
const auto address = this->goToAddressInput->text().toUInt(&addressConversionOk, 16);
|
||||
auto conversionStatus = false;
|
||||
const auto address = this->goToAddressInput->text().toUInt(&conversionStatus, 16);
|
||||
|
||||
const auto& memoryAddressRange = this->targetMemoryDescriptor.addressRange;
|
||||
|
||||
if (addressConversionOk && memoryAddressRange.contains(address) && this->goToAddressInput->hasFocus()) {
|
||||
if (
|
||||
conversionStatus
|
||||
&& this->memorySegmentDescriptor.addressRange.contains(address)
|
||||
&& this->goToAddressInput->hasFocus()
|
||||
) {
|
||||
this->byteItemGraphicsScene->selectByteItems({address});
|
||||
this->byteItemGraphicsView->scrollToByteItemAtAddress(address);
|
||||
return;
|
||||
@@ -361,7 +359,7 @@ namespace Widgets
|
||||
16
|
||||
).rightJustified(8, '0').toUpper();
|
||||
|
||||
const auto relativeAddress = *address - this->targetMemoryDescriptor.addressRange.startAddress;
|
||||
const auto relativeAddress = *address - this->memorySegmentDescriptor.addressRange.startAddress;
|
||||
const auto relativeAddressHex = "0x" + QString::number(
|
||||
relativeAddress,
|
||||
16
|
||||
@@ -383,7 +381,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
this->selectionCountLabel->setText(
|
||||
QLocale(QLocale::English).toString(selectionCount) + " " + QString(selectionCount == 1 ? "byte" : "bytes")
|
||||
QLocale{QLocale::English}.toString(selectionCount) + " " + QString(selectionCount == 1 ? "byte" : "bytes")
|
||||
+ " selected"
|
||||
);
|
||||
this->selectionCountLabel->show();
|
||||
@@ -392,7 +390,7 @@ namespace Widgets
|
||||
std::set<Targets::TargetMemoryAddress> HexViewerWidget::addressRangesToAddresses(
|
||||
const std::set<Targets::TargetMemoryAddressRange>& addressRanges
|
||||
) {
|
||||
auto addresses = std::set<Targets::TargetMemoryAddress>();
|
||||
auto addresses = std::set<Targets::TargetMemoryAddress>{};
|
||||
auto addressesIt = addresses.end();
|
||||
|
||||
for (const auto& range : addressRanges) {
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <optional>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
||||
@@ -29,7 +31,9 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
HexViewerWidget(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
HexViewerWidgetSettings& settings,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
@@ -52,7 +56,9 @@ namespace Widgets
|
||||
void settingsChanged(const HexViewerWidgetSettings& settings);
|
||||
|
||||
protected:
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
const Targets::TargetState& targetState;
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data;
|
||||
|
||||
HexViewerWidgetSettings& settings;
|
||||
@@ -78,8 +84,6 @@ namespace Widgets
|
||||
|
||||
TextInput* goToAddressInput = nullptr;
|
||||
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
void onTargetStateChanged(Targets::TargetState newState);
|
||||
|
||||
@@ -11,14 +11,14 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "src/Insight/InsightWorker/InsightWorker.hpp"
|
||||
#include "src/Insight/InsightSignals.hpp"
|
||||
|
||||
#include "src/Insight/InsightWorker/Tasks/ConstructHexViewerTopLevelGroupItem.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
ItemGraphicsScene::ItemGraphicsScene(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
@@ -27,19 +27,21 @@ namespace Widgets
|
||||
)
|
||||
: QGraphicsScene(parent)
|
||||
, state(
|
||||
HexViewerSharedState(
|
||||
targetMemoryDescriptor,
|
||||
HexViewerSharedState{
|
||||
addressSpaceDescriptor,
|
||||
memorySegmentDescriptor,
|
||||
data,
|
||||
settings
|
||||
)
|
||||
}
|
||||
)
|
||||
, targetState(targetState)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
, parent(parent)
|
||||
{
|
||||
this->setObjectName("byte-widget-container");
|
||||
|
||||
this->byteAddressContainer = new ByteAddressContainer(this->state);
|
||||
this->byteAddressContainer = new ByteAddressContainer{this->state};
|
||||
this->addItem(this->byteAddressContainer);
|
||||
|
||||
this->displayRelativeAddressAction->setCheckable(true);
|
||||
@@ -48,13 +50,6 @@ namespace Widgets
|
||||
this->setAddressType(this->state.settings.addressLabelType);
|
||||
this->setItemIndexMethod(QGraphicsScene::ItemIndexMethod::NoIndex);
|
||||
|
||||
QObject::connect(
|
||||
InsightSignals::instance(),
|
||||
&InsightSignals::targetStateUpdated,
|
||||
this,
|
||||
&ItemGraphicsScene::onTargetStateChanged
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
this->displayRelativeAddressAction,
|
||||
&QAction::triggered,
|
||||
@@ -168,14 +163,14 @@ namespace Widgets
|
||||
void ItemGraphicsScene::init() {
|
||||
this->byteAddressContainer->setPos(this->addressContainerPosition());
|
||||
|
||||
const auto constructHexViewerTopLevelGroupItem = QSharedPointer<ConstructHexViewerTopLevelGroupItem>(
|
||||
new ConstructHexViewerTopLevelGroupItem(
|
||||
const auto constructHexViewerTopLevelGroupItem = QSharedPointer<ConstructHexViewerTopLevelGroupItem>{
|
||||
new ConstructHexViewerTopLevelGroupItem{
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->state
|
||||
),
|
||||
},
|
||||
&QObject::deleteLater
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
constructHexViewerTopLevelGroupItem.get(),
|
||||
@@ -186,7 +181,7 @@ namespace Widgets
|
||||
|
||||
this->topLevelGroup.reset(item);
|
||||
this->topLevelGroup->setPosition(
|
||||
QPoint(ByteAddressContainer::WIDTH + margins.left(), margins.top())
|
||||
QPoint{ByteAddressContainer::WIDTH + margins.left(), margins.top()}
|
||||
);
|
||||
|
||||
this->itemIndex = std::make_unique<HexViewerItemIndex>(this->topLevelGroup.get(), this);
|
||||
@@ -267,14 +262,13 @@ namespace Widgets
|
||||
this->topLevelGroup->adjustItemPositions(availableWidth);
|
||||
this->itemIndex->refreshIndex();
|
||||
|
||||
const auto sceneSize = QSize(
|
||||
const auto sceneSize = QSize{
|
||||
width,
|
||||
std::max(
|
||||
static_cast<int>(this->topLevelGroup->size().height())
|
||||
+ margins.top() + margins.bottom(),
|
||||
static_cast<int>(this->topLevelGroup->size().height()) + margins.top() + margins.bottom(),
|
||||
this->parent->height()
|
||||
)
|
||||
);
|
||||
};
|
||||
this->setSceneRect(
|
||||
0,
|
||||
0,
|
||||
@@ -317,7 +311,7 @@ namespace Widgets
|
||||
return byteItemIt->second.position();
|
||||
}
|
||||
|
||||
return QPointF();
|
||||
return QPointF{};
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::addExternalContextMenuAction(ContextMenuAction* action) {
|
||||
@@ -329,22 +323,22 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::initRenderer() {
|
||||
this->renderer = new HexViewerItemRenderer(
|
||||
this->renderer = new HexViewerItemRenderer{
|
||||
this->state,
|
||||
*(this->topLevelGroup.get()),
|
||||
*(this->itemIndex.get()),
|
||||
this->views().first()
|
||||
);
|
||||
};
|
||||
this->renderer->setPos(0, 0);
|
||||
this->addItem(this->renderer);
|
||||
}
|
||||
|
||||
QMargins ItemGraphicsScene::margins() {
|
||||
return QMargins(10, 10, 10, 10);
|
||||
return QMargins{10, 10, 10, 10};
|
||||
}
|
||||
|
||||
QPointF ItemGraphicsScene::addressContainerPosition() {
|
||||
return QPointF(0, 0);
|
||||
return QPointF{0, 0};
|
||||
}
|
||||
|
||||
bool ItemGraphicsScene::event(QEvent* event) {
|
||||
@@ -360,8 +354,8 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent* mouseEvent) {
|
||||
static const auto rubberBandRectBackgroundColor = QColor(0x3C, 0x59, 0x5C, 0x82);
|
||||
static const auto rubberBandRectBorderColor = QColor(0x3C, 0x59, 0x5C, 255);
|
||||
static const auto rubberBandRectBackgroundColor = QColor{0x3C, 0x59, 0x5C, 0x82};
|
||||
static const auto rubberBandRectBorderColor = QColor{0x3C, 0x59, 0x5C, 255};
|
||||
|
||||
const auto button = mouseEvent->button();
|
||||
const auto mousePosition = mouseEvent->buttonDownScenePos(button);
|
||||
@@ -377,7 +371,7 @@ namespace Widgets
|
||||
this->update();
|
||||
|
||||
if (button == Qt::MouseButton::RightButton) {
|
||||
ByteItem* clickedByteItem = this->itemIndex->byteItemAt(mousePosition);
|
||||
auto* clickedByteItem = this->itemIndex->byteItemAt(mousePosition);
|
||||
|
||||
if (clickedByteItem == nullptr || clickedByteItem->selected) {
|
||||
return;
|
||||
@@ -389,12 +383,12 @@ namespace Widgets
|
||||
this->clearSelectionRectItem();
|
||||
|
||||
this->rubberBandInitPoint = std::move(mousePosition);
|
||||
this->rubberBandRectItem = new QGraphicsRectItem(
|
||||
this->rubberBandRectItem = new QGraphicsRectItem{
|
||||
this->rubberBandInitPoint->x(),
|
||||
this->rubberBandInitPoint->y(),
|
||||
1,
|
||||
1
|
||||
);
|
||||
};
|
||||
this->rubberBandRectItem->setBrush(rubberBandRectBackgroundColor);
|
||||
this->rubberBandRectItem->setPen(rubberBandRectBorderColor);
|
||||
this->addItem(this->rubberBandRectItem);
|
||||
@@ -409,7 +403,7 @@ namespace Widgets
|
||||
if ((modifiers & Qt::ShiftModifier) != 0) {
|
||||
for (
|
||||
auto i = static_cast<std::int64_t>(clickedByteItem->startAddress);
|
||||
i >= this->state.memoryDescriptor.addressRange.startAddress;
|
||||
i >= this->state.memorySegmentDescriptor.addressRange.startAddress;
|
||||
--i
|
||||
) {
|
||||
auto& byteItem = this->topLevelGroup->byteItemsByAddress.at(
|
||||
@@ -500,11 +494,11 @@ namespace Widgets
|
||||
|
||||
void ItemGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) {
|
||||
if (event->scenePos().x() <= ByteAddressContainer::WIDTH) {
|
||||
auto* menu = new QMenu(this->parent);
|
||||
auto* menu = new QMenu{this->parent};
|
||||
menu->setLayoutDirection(Qt::LayoutDirection::LeftToRight);
|
||||
menu->setObjectName("byte-item-address-container-context-menu");
|
||||
|
||||
auto* addressTypeMenu = new QMenu("Address Type", menu);
|
||||
auto* addressTypeMenu = new QMenu{"Address Type", menu};
|
||||
addressTypeMenu->addAction(this->displayAbsoluteAddressAction);
|
||||
addressTypeMenu->addAction(this->displayRelativeAddressAction);
|
||||
menu->addMenu(addressTypeMenu);
|
||||
@@ -515,13 +509,13 @@ namespace Widgets
|
||||
|
||||
const auto itemsSelected = !this->selectedByteItemAddresses.empty();
|
||||
|
||||
auto* menu = new QMenu(this->parent);
|
||||
auto* menu = new QMenu{this->parent};
|
||||
menu->setLayoutDirection(Qt::LayoutDirection::LeftToRight);
|
||||
menu->addAction(this->selectAllByteItemsAction);
|
||||
menu->addAction(this->deselectByteItemsAction);
|
||||
menu->addSeparator();
|
||||
|
||||
auto* copyMenu = new QMenu("Copy Selection", menu);
|
||||
auto* copyMenu = new QMenu{"Copy Selection", menu};
|
||||
copyMenu->addAction(this->copyAbsoluteAddressAction);
|
||||
copyMenu->addAction(this->copyRelativeAddressAction);
|
||||
copyMenu->addSeparator();
|
||||
@@ -561,10 +555,6 @@ namespace Widgets
|
||||
return this->views().first()->verticalScrollBar()->value();
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::onTargetStateChanged(Targets::TargetState newState) {
|
||||
this->targetState = newState;
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::onByteItemEnter(ByteItem& byteItem) {
|
||||
if (this->state.hoveredByteItem != nullptr) {
|
||||
if (this->state.hoveredByteItem == &byteItem) {
|
||||
@@ -646,7 +636,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
std::set<Targets::TargetMemoryAddress> ItemGraphicsScene::excludedAddresses() {
|
||||
auto output = std::set<Targets::TargetMemoryAddress>();
|
||||
auto output = std::set<Targets::TargetMemoryAddress>{};
|
||||
|
||||
for (const auto& excludedRegion : this->excludedMemoryRegions) {
|
||||
const auto regionAddresses = excludedRegion.addressRange.addresses();
|
||||
@@ -661,8 +651,8 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
auto data = QString();
|
||||
const auto memoryStartAddress = this->state.memoryDescriptor.addressRange.startAddress;
|
||||
auto data = QString{};
|
||||
const auto memoryStartAddress = this->state.memorySegmentDescriptor.addressRange.startAddress;
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
data.append(
|
||||
@@ -684,12 +674,12 @@ namespace Widgets
|
||||
}
|
||||
|
||||
const auto excludedAddresses = this->excludedAddresses();
|
||||
auto data = QString();
|
||||
auto data = QString{};
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
const unsigned char byteValue = excludedAddresses.contains(address)
|
||||
? 0x00
|
||||
: (*this->state.data)[address - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
: (*this->state.data)[address - this->state.memorySegmentDescriptor.addressRange.startAddress];
|
||||
|
||||
data.append(
|
||||
withDelimiters
|
||||
@@ -707,12 +697,12 @@ namespace Widgets
|
||||
}
|
||||
|
||||
const auto excludedAddresses = this->excludedAddresses();
|
||||
auto data = QString();
|
||||
auto data = QString{};
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
const unsigned char byteValue = excludedAddresses.contains(address)
|
||||
? 0x00
|
||||
: (*this->state.data)[address - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
: (*this->state.data)[address - this->state.memorySegmentDescriptor.addressRange.startAddress];
|
||||
data.append(QString::number(byteValue, 10) + "\n");
|
||||
}
|
||||
|
||||
@@ -725,12 +715,12 @@ namespace Widgets
|
||||
}
|
||||
|
||||
const auto excludedAddresses = this->excludedAddresses();
|
||||
auto data = QString();
|
||||
auto data = QString{};
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
const unsigned char byteValue = excludedAddresses.contains(address)
|
||||
? 0x00
|
||||
: (*this->state.data)[address - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
: (*this->state.data)[address - this->state.memorySegmentDescriptor.addressRange.startAddress];
|
||||
|
||||
data.append(
|
||||
withDelimiters
|
||||
@@ -748,12 +738,12 @@ namespace Widgets
|
||||
}
|
||||
|
||||
const auto excludedAddresses = this->excludedAddresses();
|
||||
auto data = QJsonObject();
|
||||
auto data = QJsonObject{};
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
const unsigned char byteValue = excludedAddresses.contains(address)
|
||||
? 0x00
|
||||
: (*this->state.data)[address - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
: (*this->state.data)[address - this->state.memorySegmentDescriptor.addressRange.startAddress];
|
||||
|
||||
data.insert(
|
||||
"0x" + QString::number(address, 16).rightJustified(8, '0').toUpper(),
|
||||
@@ -761,7 +751,7 @@ namespace Widgets
|
||||
);
|
||||
}
|
||||
|
||||
QApplication::clipboard()->setText(QJsonDocument(data).toJson(QJsonDocument::JsonFormat::Indented));
|
||||
QApplication::clipboard()->setText(QJsonDocument{data}.toJson(QJsonDocument::JsonFormat::Indented));
|
||||
}
|
||||
|
||||
void ItemGraphicsScene::copyAsciiValueToClipboard() {
|
||||
@@ -770,17 +760,17 @@ namespace Widgets
|
||||
}
|
||||
|
||||
const auto excludedAddresses = this->excludedAddresses();
|
||||
auto data = QString();
|
||||
auto data = QString{};
|
||||
|
||||
for (const auto& address : this->selectedByteItemAddresses) {
|
||||
const unsigned char byteValue =
|
||||
(*this->state.data)[address - this->state.memoryDescriptor.addressRange.startAddress];
|
||||
(*this->state.data)[address - this->state.memorySegmentDescriptor.addressRange.startAddress];
|
||||
|
||||
if (excludedAddresses.contains(address) || byteValue < 32 || byteValue > 126) {
|
||||
continue;
|
||||
}
|
||||
|
||||
data.append(QChar(byteValue));
|
||||
data.append(QChar{byteValue});
|
||||
}
|
||||
|
||||
QApplication::clipboard()->setText(std::move(data));
|
||||
@@ -789,7 +779,7 @@ namespace Widgets
|
||||
std::set<Targets::TargetMemoryAddress> ItemGraphicsScene::addressRangesToAddresses(
|
||||
const std::set<Targets::TargetMemoryAddressRange>& addressRanges
|
||||
) {
|
||||
auto addresses = std::set<Targets::TargetMemoryAddress>();
|
||||
auto addresses = std::set<Targets::TargetMemoryAddress>{};
|
||||
|
||||
for (const auto& range : addressRanges) {
|
||||
const auto rangeAddresses = range.addresses();
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
||||
@@ -45,7 +47,9 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
ItemGraphicsScene(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
@@ -76,6 +80,7 @@ namespace Widgets
|
||||
bool enabled = true;
|
||||
|
||||
HexViewerSharedState state;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
@@ -85,8 +90,6 @@ namespace Widgets
|
||||
|
||||
HexViewerItemRenderer* renderer = nullptr;
|
||||
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
QGraphicsView* parent = nullptr;
|
||||
|
||||
ByteAddressContainer* byteAddressContainer = nullptr;
|
||||
@@ -143,7 +146,6 @@ namespace Widgets
|
||||
void keyPressEvent(QKeyEvent* keyEvent) override;
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override;
|
||||
int getScrollbarValue();
|
||||
void onTargetStateChanged(Targets::TargetState newState);
|
||||
void onByteItemEnter(ByteItem& byteItem);
|
||||
void onByteItemLeave();
|
||||
void clearSelectionRectItem();
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
using Targets::TargetMemoryDescriptor;
|
||||
using Targets::TargetMemorySegmentDescriptor;
|
||||
|
||||
ItemGraphicsView::ItemGraphicsView(
|
||||
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
@@ -17,7 +19,9 @@ namespace Widgets
|
||||
QWidget* parent
|
||||
)
|
||||
: QGraphicsView(parent)
|
||||
, targetMemoryDescriptor(targetMemoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, targetState(targetState)
|
||||
, data(data)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
@@ -40,14 +44,16 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void ItemGraphicsView::initScene() {
|
||||
this->scene = new ItemGraphicsScene(
|
||||
this->targetMemoryDescriptor,
|
||||
this->scene = new ItemGraphicsScene{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this->data,
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->settings,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
this->setScene(this->scene);
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
#include "ItemGraphicsScene.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
||||
|
||||
namespace Widgets
|
||||
@@ -18,7 +22,9 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
ItemGraphicsView(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
@@ -38,7 +44,10 @@ namespace Widgets
|
||||
void sceneReady();
|
||||
|
||||
protected:
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data;
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Widgets
|
||||
, hexViewerState(hexViewerState)
|
||||
{
|
||||
const auto startAddress = this->startAddress;
|
||||
const auto endAddress = this->hexViewerState.memoryDescriptor.addressRange.endAddress;
|
||||
const auto endAddress = this->hexViewerState.memorySegmentDescriptor.addressRange.endAddress;
|
||||
|
||||
// Sanity check
|
||||
assert(byteItemsByAddress.contains(startAddress) && byteItemsByAddress.contains(endAddress));
|
||||
@@ -74,10 +74,7 @@ namespace Widgets
|
||||
updateChildItems(this->items, updateChildItems);
|
||||
}
|
||||
|
||||
void StackMemoryGroupItem::adjustItemPositions(
|
||||
const int maximumWidth,
|
||||
const HexViewerSharedState* hexViewerState
|
||||
) {
|
||||
void StackMemoryGroupItem::adjustItemPositions(int maximumWidth, const HexViewerSharedState* hexViewerState) {
|
||||
GroupItem::adjustItemPositions(maximumWidth, hexViewerState);
|
||||
this->groupSize.setWidth(maximumWidth);
|
||||
}
|
||||
@@ -88,10 +85,7 @@ namespace Widgets
|
||||
}
|
||||
}
|
||||
|
||||
QMargins StackMemoryGroupItem::groupMargins(
|
||||
const HexViewerSharedState* hexViewerState,
|
||||
const int maximumWidth
|
||||
) const {
|
||||
return QMargins(0, 100, 0, 20);
|
||||
QMargins StackMemoryGroupItem::groupMargins(const HexViewerSharedState* hexViewerState, int maximumWidth) const {
|
||||
return {0, 100, 0, 20};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ namespace Widgets
|
||||
|
||||
~StackMemoryGroupItem();
|
||||
|
||||
void adjustItemPositions(const int maximumWidth, const HexViewerSharedState* hexViewerState) override;
|
||||
void adjustItemPositions(int maximumWidth, const HexViewerSharedState* hexViewerState) override;
|
||||
|
||||
void refreshValues();
|
||||
|
||||
protected:
|
||||
QMargins groupMargins(const HexViewerSharedState* hexViewerState, const int maximumWidth) const override;
|
||||
QMargins groupMargins(const HexViewerSharedState* hexViewerState, int maximumWidth) const override;
|
||||
|
||||
bool positionOnNewLine(const int maximumWidth) override {
|
||||
return true;
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace Widgets
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
, hexViewerState(hexViewerState)
|
||||
{
|
||||
const auto memorySize = this->hexViewerState.memoryDescriptor.size();
|
||||
const auto startAddress = this->hexViewerState.memoryDescriptor.addressRange.startAddress;
|
||||
const auto memorySize = this->hexViewerState.memorySegmentDescriptor.size();
|
||||
const auto startAddress = this->hexViewerState.memorySegmentDescriptor.addressRange.startAddress;
|
||||
|
||||
for (Targets::TargetMemorySize i = 0; i < memorySize; i++) {
|
||||
const auto address = startAddress + i;
|
||||
@@ -29,8 +29,8 @@ namespace Widgets
|
||||
const auto& currentStackPointer = this->hexViewerState.currentStackPointer;
|
||||
const auto stackGroupingRequired = currentStackPointer.has_value()
|
||||
&& this->hexViewerState.settings.groupStackMemory
|
||||
&& *currentStackPointer >= this->hexViewerState.memoryDescriptor.addressRange.startAddress
|
||||
&& (*currentStackPointer + 1) <= this->hexViewerState.memoryDescriptor.addressRange.endAddress;
|
||||
&& *currentStackPointer >= this->hexViewerState.memorySegmentDescriptor.addressRange.startAddress
|
||||
&& (*currentStackPointer + 1) <= this->hexViewerState.memorySegmentDescriptor.addressRange.endAddress;
|
||||
|
||||
for (const auto& focusedRegion : this->focusedMemoryRegions) {
|
||||
if (
|
||||
@@ -48,7 +48,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
this->focusedRegionGroupItems.emplace_back(focusedRegion, this->byteItemsByAddress, this);
|
||||
items.emplace_back(&(this->focusedRegionGroupItems.back()));
|
||||
this->items.emplace_back(&(this->focusedRegionGroupItems.back()));
|
||||
}
|
||||
|
||||
if (stackGroupingRequired) {
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Widgets
|
||||
|
||||
void refreshValues();
|
||||
|
||||
void adjustItemPositions(const int maximumWidth) {
|
||||
void adjustItemPositions(int maximumWidth) {
|
||||
GroupItem::adjustItemPositions(maximumWidth, &(this->hexViewerState));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="20"
|
||||
width="14"
|
||||
height="16"
|
||||
viewBox="0 0 5.2916667 4.2333333"
|
||||
viewBox="0 0 3.7041667 4.2333333"
|
||||
version="1.1"
|
||||
id="svg974"
|
||||
sodipodi:docname="memory-inspection-icon.svg"
|
||||
inkscape:version="1.0.1 (1.0.1+r75)">
|
||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:cc="http://creativecommons.org/ns#">
|
||||
<defs
|
||||
id="defs968" />
|
||||
<sodipodi:namedview
|
||||
@@ -24,33 +23,29 @@
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="44.8"
|
||||
inkscape:cx="19.284495"
|
||||
inkscape:cy="7.1191996"
|
||||
inkscape:cx="19.0625"
|
||||
inkscape:cy="7.1205357"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer2"
|
||||
inkscape:document-rotation="0"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:snap-page="true"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-width="3440"
|
||||
inkscape:window-height="1353"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-x="2560"
|
||||
inkscape:window-y="34"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:snap-smooth-nodes="true"
|
||||
inkscape:snap-bbox="true"
|
||||
inkscape:snap-bbox-midpoints="true"
|
||||
inkscape:snap-bbox-edge-midpoints="true" />
|
||||
inkscape:snap-bbox-edge-midpoints="true"
|
||||
inkscape:pagecheckerboard="0" />
|
||||
<metadata
|
||||
id="metadata971">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
rdf:about="" />
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
@@ -66,105 +61,105 @@
|
||||
id="rect1537-3"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="1.5874999"
|
||||
x="0.79374993"
|
||||
y="1.058333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-6"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="0.79374987"
|
||||
x="-1.4002266e-07"
|
||||
y="1.058333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-7"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="2.3812499"
|
||||
x="1.5875"
|
||||
y="1.058333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="1.5875001"
|
||||
x="0.79375017"
|
||||
y="1.8520831" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-6"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="2.3812501"
|
||||
x="1.5875002"
|
||||
y="1.8520831" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-2"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="0.79374987"
|
||||
x="-1.4002266e-07"
|
||||
y="1.8520831" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-9"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="1.5875003"
|
||||
x="0.79375041"
|
||||
y="2.6458333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-6-1"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="2.3812501"
|
||||
x="1.5875002"
|
||||
y="2.6458333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-2-2"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="0.79374987"
|
||||
x="-1.4002266e-07"
|
||||
y="2.6458333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-70"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.175"
|
||||
x="2.3812499"
|
||||
y="1.058333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-7-9"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.9687502"
|
||||
x="3.1750002"
|
||||
y="1.058333" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-3"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.1750002"
|
||||
x="2.3812501"
|
||||
y="1.8520831" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-6-6"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.9687502"
|
||||
x="3.1750002"
|
||||
y="1.8520831" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-9-0"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.1750004"
|
||||
x="2.3812504"
|
||||
y="2.6458335" />
|
||||
<rect
|
||||
style="fill:#7f7f7e;fill-opacity:1;stroke-width:0.0368284"
|
||||
id="rect1537-3-5-6-1-6"
|
||||
width="0.52916664"
|
||||
height="0.5291667"
|
||||
x="3.9687502"
|
||||
x="3.1750002"
|
||||
y="2.6458335" />
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.6 KiB |
@@ -5,12 +5,10 @@
|
||||
|
||||
MemoryRegion::MemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
MemoryRegionType type,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
)
|
||||
: name(name)
|
||||
, memoryType(memoryType)
|
||||
, type(type)
|
||||
, addressRange(addressRange)
|
||||
{}
|
||||
@@ -20,45 +18,38 @@ MemoryRegion::MemoryRegion(const QJsonObject& jsonObject) {
|
||||
|
||||
if (
|
||||
!jsonObject.contains("name")
|
||||
|| !jsonObject.contains("memoryType")
|
||||
|| !jsonObject.contains("type")
|
||||
|| !jsonObject.contains("createdTimestamp")
|
||||
|| !jsonObject.contains("addressInputType")
|
||||
|| !jsonObject.contains("addressRange")
|
||||
) {
|
||||
throw Exception("Missing data");
|
||||
throw Exception{"Missing data"};
|
||||
}
|
||||
|
||||
const auto addressRangeObj = jsonObject.find("addressRange")->toObject();
|
||||
if (
|
||||
!addressRangeObj.contains("startAddress")
|
||||
|| !addressRangeObj.contains("endAddress")
|
||||
) {
|
||||
throw Exception("Missing address range data");
|
||||
if (!addressRangeObj.contains("startAddress") || !addressRangeObj.contains("endAddress")) {
|
||||
throw Exception{"Missing address range data"};
|
||||
}
|
||||
|
||||
this->name = jsonObject.find("name")->toString();
|
||||
this->memoryType = EnumToStringMappings::targetMemoryTypes.at(jsonObject.find("memoryType")->toString());
|
||||
this->type = MemoryRegion::memoryRegionTypesByName.at(jsonObject.find("type")->toString());
|
||||
this->createdDate.setSecsSinceEpoch(jsonObject.find("createdTimestamp")->toInteger());
|
||||
this->addressRangeInputType = MemoryRegion::addressTypesByName.at(jsonObject.find("addressInputType")->toString());
|
||||
|
||||
this->addressRange = {
|
||||
static_cast<std::uint32_t>(addressRangeObj.find("startAddress")->toInteger()),
|
||||
static_cast<std::uint32_t>(addressRangeObj.find("endAddress")->toInteger()),
|
||||
static_cast<Targets::TargetMemoryAddress>(addressRangeObj.find("startAddress")->toInteger()),
|
||||
static_cast<Targets::TargetMemoryAddress>(addressRangeObj.find("endAddress")->toInteger()),
|
||||
};
|
||||
}
|
||||
|
||||
QJsonObject MemoryRegion::toJson() const {
|
||||
return QJsonObject({
|
||||
return {
|
||||
{"name", this->name},
|
||||
{"memoryType", EnumToStringMappings::targetMemoryTypes.at(this->memoryType)},
|
||||
{"type", MemoryRegion::memoryRegionTypesByName.at(this->type)},
|
||||
{"createdTimestamp", this->createdDate.toSecsSinceEpoch()},
|
||||
{"addressInputType", MemoryRegion::addressTypesByName.at(this->addressRangeInputType)},
|
||||
{"addressRange", QJsonObject({
|
||||
{"addressRange", QJsonObject{
|
||||
{"startAddress", static_cast<qint64>(this->addressRange.startAddress)},
|
||||
{"endAddress", static_cast<qint64>(this->addressRange.endAddress)},
|
||||
})},
|
||||
});
|
||||
}},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ class MemoryRegion
|
||||
public:
|
||||
QString name;
|
||||
QDateTime createdDate = Services::DateTimeService::currentDateTime();
|
||||
Targets::TargetMemoryType memoryType;
|
||||
MemoryRegionType type;
|
||||
|
||||
/**
|
||||
@@ -54,12 +53,11 @@ public:
|
||||
|
||||
MemoryRegion(
|
||||
const QString& name,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
MemoryRegionType type,
|
||||
const Targets::TargetMemoryAddressRange& addressRange
|
||||
);
|
||||
|
||||
MemoryRegion(const QJsonObject& jsonObject);
|
||||
explicit MemoryRegion(const QJsonObject& jsonObject);
|
||||
|
||||
virtual QJsonObject toJson() const;
|
||||
|
||||
|
||||
@@ -10,41 +10,39 @@ namespace Widgets
|
||||
{
|
||||
ExcludedRegionItem::ExcludedRegionItem(
|
||||
const ExcludedMemoryRegion& region,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
QWidget* parent
|
||||
)
|
||||
: RegionItem(region, memoryDescriptor, parent)
|
||||
: RegionItem(region, memorySegmentDescriptor, parent)
|
||||
, memoryRegion(region)
|
||||
{
|
||||
auto formUiFile = QFile(
|
||||
auto formUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/MemoryRegionManager/UiFiles/ExcludedMemoryRegionForm.ui"
|
||||
+ "/MemoryRegionManager/UiFiles/ExcludedMemoryRegionForm.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!formUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exceptions::Exception("Failed to open excluded region item form UI file");
|
||||
throw Exceptions::Exception{"Failed to open excluded region item form UI file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->formWidget = uiLoader.load(&formUiFile, this);
|
||||
|
||||
this->initFormInputs();
|
||||
}
|
||||
|
||||
void ExcludedRegionItem::applyChanges() {
|
||||
using Targets::TargetMemoryAddressRange;
|
||||
|
||||
this->memoryRegion.name = this->nameInput->text();
|
||||
|
||||
const auto inputAddressRange = TargetMemoryAddressRange(
|
||||
const auto inputAddressRange = Targets::TargetMemoryAddressRange{
|
||||
this->startAddressInput->text().toUInt(nullptr, 16),
|
||||
this->endAddressInput->text().toUInt(nullptr, 16)
|
||||
);
|
||||
};
|
||||
this->memoryRegion.addressRangeInputType = this->getSelectedAddressInputType();
|
||||
this->memoryRegion.addressRange =
|
||||
this->memoryRegion.addressRangeInputType == AddressType::RELATIVE ?
|
||||
this->convertRelativeToAbsoluteAddressRange(inputAddressRange) : inputAddressRange;
|
||||
this->memoryRegion.addressRange = this->memoryRegion.addressRangeInputType == AddressType::RELATIVE
|
||||
? this->convertRelativeToAbsoluteAddressRange(inputAddressRange)
|
||||
: inputAddressRange;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Widgets
|
||||
public:
|
||||
ExcludedRegionItem(
|
||||
const ExcludedMemoryRegion& region,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
QWidget *parent
|
||||
);
|
||||
|
||||
|
||||
@@ -12,24 +12,24 @@ namespace Widgets
|
||||
|
||||
FocusedRegionItem::FocusedRegionItem(
|
||||
const FocusedMemoryRegion& region,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
QWidget* parent
|
||||
)
|
||||
: RegionItem(region, memoryDescriptor, parent)
|
||||
: RegionItem(region, memorySegmentDescriptor, parent)
|
||||
, memoryRegion(region)
|
||||
{
|
||||
auto formUiFile = QFile(
|
||||
auto formUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/MemoryRegionManager/UiFiles/FocusedMemoryRegionForm.ui"
|
||||
+ "/MemoryRegionManager/UiFiles/FocusedMemoryRegionForm.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!formUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exceptions::Exception("Failed to open focused region item form UI file");
|
||||
throw Exceptions::Exception{"Failed to open focused region item form UI file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->formWidget = uiLoader.load(&formUiFile, this);
|
||||
|
||||
this->initFormInputs();
|
||||
@@ -38,10 +38,10 @@ namespace Widgets
|
||||
void FocusedRegionItem::applyChanges() {
|
||||
this->memoryRegion.name = this->nameInput->text();
|
||||
|
||||
const auto inputAddressRange = TargetMemoryAddressRange(
|
||||
const auto inputAddressRange = Targets::TargetMemoryAddressRange{
|
||||
this->startAddressInput->text().toUInt(nullptr, 16),
|
||||
this->endAddressInput->text().toUInt(nullptr, 16)
|
||||
);
|
||||
};
|
||||
this->memoryRegion.addressRangeInputType = this->getSelectedAddressInputType();
|
||||
this->memoryRegion.addressRange = this->memoryRegion.addressRangeInputType == AddressType::RELATIVE
|
||||
? this->convertRelativeToAbsoluteAddressRange(inputAddressRange)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Widgets
|
||||
public:
|
||||
FocusedRegionItem(
|
||||
const FocusedMemoryRegion& region,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
QWidget *parent
|
||||
);
|
||||
|
||||
@@ -52,20 +52,16 @@ namespace Widgets
|
||||
QComboBox* dataTypeInput = nullptr;
|
||||
QComboBox* endiannessInput = nullptr;
|
||||
|
||||
static const inline std::map<QString, DataTypeOption> dataTypeOptionsByName = std::map<
|
||||
QString, DataTypeOption
|
||||
>({
|
||||
{"other", DataTypeOption("Other", MemoryRegionDataType::UNKNOWN)},
|
||||
{"unsigned_integer", DataTypeOption("Unsigned Integer", MemoryRegionDataType::UNSIGNED_INTEGER)},
|
||||
{"signed_integer", DataTypeOption("Signed Integer", MemoryRegionDataType::SIGNED_INTEGER)},
|
||||
{"ascii", DataTypeOption("ASCII String", MemoryRegionDataType::ASCII_STRING)},
|
||||
});
|
||||
static const inline std::map<QString, DataTypeOption> dataTypeOptionsByName = {
|
||||
{"other", DataTypeOption{"Other", MemoryRegionDataType::UNKNOWN}},
|
||||
{"unsigned_integer", DataTypeOption{"Unsigned Integer", MemoryRegionDataType::UNSIGNED_INTEGER}},
|
||||
{"signed_integer", DataTypeOption{"Signed Integer", MemoryRegionDataType::SIGNED_INTEGER}},
|
||||
{"ascii", DataTypeOption{"ASCII String", MemoryRegionDataType::ASCII_STRING}},
|
||||
};
|
||||
|
||||
static const inline std::map<QString, EndiannessOption> endiannessOptionsByName = std::map<
|
||||
QString, EndiannessOption
|
||||
>({
|
||||
{"little", EndiannessOption("Little-endian", Targets::TargetMemoryEndianness::LITTLE)},
|
||||
{"big", EndiannessOption("Big-endian", Targets::TargetMemoryEndianness::BIG)},
|
||||
});
|
||||
static const inline std::map<QString, EndiannessOption> endiannessOptionsByName = {
|
||||
{"little", EndiannessOption{"Little-endian", Targets::TargetMemoryEndianness::LITTLE}},
|
||||
{"big", EndiannessOption{"Big-endian", Targets::TargetMemoryEndianness::BIG}},
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -16,48 +16,50 @@ namespace Widgets
|
||||
using Exceptions::Exception;
|
||||
|
||||
MemoryRegionManagerWindow::MemoryRegionManagerWindow(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
QWidget* parent
|
||||
)
|
||||
: QWidget(parent)
|
||||
, memoryDescriptor(memoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
, excludedMemoryRegions(excludedMemoryRegions)
|
||||
{
|
||||
this->setWindowFlag(Qt::Window);
|
||||
this->setObjectName("memory-region-manager-window");
|
||||
this->setWindowTitle(
|
||||
"Memory Regions - " + EnumToStringMappings::targetMemoryTypes.at(this->memoryDescriptor.type).toUpper()
|
||||
"Memory Regions - " + QString::fromStdString(this->memorySegmentDescriptor.name)
|
||||
);
|
||||
|
||||
auto windowUiFile = QFile(
|
||||
auto windowUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/MemoryRegionManager/UiFiles/MemoryRegionManagerWindow.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto windowStylesheet = QFile(
|
||||
auto windowStylesheet = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/MemoryRegionManager/Stylesheets/MemoryRegionManagerWindow.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!windowUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open MemoryRegionManagerWindow UI file");
|
||||
throw Exception{"Failed to open MemoryRegionManagerWindow UI file"};
|
||||
}
|
||||
|
||||
if (!windowStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open MemoryRegionManagerWindow stylesheet file");
|
||||
throw Exception{"Failed to open MemoryRegionManagerWindow stylesheet file"};
|
||||
}
|
||||
|
||||
this->setStyleSheet(windowStylesheet.readAll());
|
||||
this->setFixedSize(QSize(970, 540));
|
||||
this->setFixedSize(QSize{970, 540});
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&windowUiFile, this);
|
||||
|
||||
this->container->setFixedSize(this->size());
|
||||
@@ -210,11 +212,11 @@ namespace Widgets
|
||||
}
|
||||
|
||||
FocusedRegionItem* MemoryRegionManagerWindow::addFocusedRegion(const FocusedMemoryRegion& region) {
|
||||
auto* focusedRegionItem = new FocusedRegionItem(
|
||||
auto* focusedRegionItem = new FocusedRegionItem{
|
||||
region,
|
||||
this->memoryDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->regionItemScrollAreaViewport
|
||||
);
|
||||
};
|
||||
this->focusedRegionItems.insert(focusedRegionItem);
|
||||
|
||||
this->regionItemScrollAreaViewportLayout->addWidget(focusedRegionItem);
|
||||
@@ -231,11 +233,11 @@ namespace Widgets
|
||||
}
|
||||
|
||||
ExcludedRegionItem* MemoryRegionManagerWindow::addExcludedRegion(const ExcludedMemoryRegion& region) {
|
||||
auto* excludedRegionItem = new ExcludedRegionItem(
|
||||
auto* excludedRegionItem = new ExcludedRegionItem{
|
||||
region,
|
||||
this->memoryDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->regionItemScrollAreaViewport
|
||||
);
|
||||
};
|
||||
this->excludedRegionItems.insert(excludedRegionItem);
|
||||
|
||||
this->regionItemScrollAreaViewportLayout->addWidget(excludedRegionItem);
|
||||
@@ -263,14 +265,15 @@ namespace Widgets
|
||||
void MemoryRegionManagerWindow::onNewFocusedRegionTrigger() {
|
||||
using Targets::TargetMemoryAddressRange;
|
||||
|
||||
auto* region = this->addFocusedRegion(FocusedMemoryRegion(
|
||||
"Untitled Region",
|
||||
this->memoryDescriptor.type,
|
||||
TargetMemoryAddressRange(
|
||||
this->memoryDescriptor.addressRange.startAddress,
|
||||
this->memoryDescriptor.addressRange.startAddress + 10
|
||||
)
|
||||
));
|
||||
auto* region = this->addFocusedRegion(
|
||||
FocusedMemoryRegion{
|
||||
"Untitled Region",
|
||||
TargetMemoryAddressRange{
|
||||
this->memorySegmentDescriptor.addressRange.startAddress,
|
||||
this->memorySegmentDescriptor.addressRange.startAddress + 10
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
region->setSelected(true);
|
||||
}
|
||||
@@ -278,14 +281,15 @@ namespace Widgets
|
||||
void MemoryRegionManagerWindow::onNewExcludedRegionTrigger() {
|
||||
using Targets::TargetMemoryAddressRange;
|
||||
|
||||
auto* region = this->addExcludedRegion(ExcludedMemoryRegion(
|
||||
"Untitled Region",
|
||||
this->memoryDescriptor.type,
|
||||
TargetMemoryAddressRange(
|
||||
this->memoryDescriptor.addressRange.startAddress,
|
||||
this->memoryDescriptor.addressRange.startAddress + 10
|
||||
)
|
||||
));
|
||||
auto* region = this->addExcludedRegion(
|
||||
ExcludedMemoryRegion{
|
||||
"Untitled Region",
|
||||
TargetMemoryAddressRange{
|
||||
this->memorySegmentDescriptor.addressRange.startAddress,
|
||||
this->memorySegmentDescriptor.addressRange.startAddress + 10
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
region->setSelected(true);
|
||||
}
|
||||
@@ -331,19 +335,19 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void MemoryRegionManagerWindow::applyChanges() {
|
||||
auto processedFocusedMemoryRegions = std::vector<FocusedMemoryRegion>();
|
||||
auto processedExcludedMemoryRegions = std::vector<ExcludedMemoryRegion>();
|
||||
auto processedFocusedMemoryRegions = std::vector<FocusedMemoryRegion>{};
|
||||
auto processedExcludedMemoryRegions = std::vector<ExcludedMemoryRegion>{};
|
||||
|
||||
for (auto* focusedRegionItem : this->focusedRegionItems) {
|
||||
const auto validationFailures = focusedRegionItem->getValidationFailures();
|
||||
|
||||
if (!validationFailures.empty()) {
|
||||
auto* errorDialogue = new ErrorDialogue(
|
||||
auto* errorDialogue = new ErrorDialogue{
|
||||
"Invalid Memory Region",
|
||||
"Invalid memory region \"" + focusedRegionItem->getRegionNameInputValue() + "\""
|
||||
+ "\n\n- " + validationFailures.join("\n- "),
|
||||
this
|
||||
);
|
||||
};
|
||||
errorDialogue->show();
|
||||
return;
|
||||
}
|
||||
@@ -352,13 +356,13 @@ namespace Widgets
|
||||
const auto& focusedRegion = focusedRegionItem->getMemoryRegion();
|
||||
for (const auto& processedFocusedRegion : processedFocusedMemoryRegions) {
|
||||
if (processedFocusedRegion.intersectsWith(focusedRegion)) {
|
||||
auto* errorDialogue = new ErrorDialogue(
|
||||
auto* errorDialogue = new ErrorDialogue{
|
||||
"Intersecting Region Found",
|
||||
"Region \"" + focusedRegionItem->getRegionNameInputValue()
|
||||
+ "\" intersects with region \"" + processedFocusedRegion.name + "\". "
|
||||
+ "Regions cannot intersect. Please review the relevant address ranges.",
|
||||
this
|
||||
);
|
||||
};
|
||||
errorDialogue->show();
|
||||
return;
|
||||
}
|
||||
@@ -371,12 +375,12 @@ namespace Widgets
|
||||
const auto validationFailures = excludedRegionItem->getValidationFailures();
|
||||
|
||||
if (!validationFailures.empty()) {
|
||||
auto* errorDialogue = new ErrorDialogue(
|
||||
auto* errorDialogue = new ErrorDialogue{
|
||||
"Invalid Memory Region",
|
||||
"Invalid memory region \"" + excludedRegionItem->getRegionNameInputValue() + "\""
|
||||
+ "<br/><br/>- " + validationFailures.join("<br/>- "),
|
||||
this
|
||||
);
|
||||
};
|
||||
errorDialogue->show();
|
||||
return;
|
||||
}
|
||||
@@ -385,13 +389,13 @@ namespace Widgets
|
||||
auto excludedRegion = excludedRegionItem->getMemoryRegion();
|
||||
for (const auto& processedFocusedRegion : processedFocusedMemoryRegions) {
|
||||
if (processedFocusedRegion.intersectsWith(excludedRegion)) {
|
||||
auto* errorDialogue = new ErrorDialogue(
|
||||
auto* errorDialogue = new ErrorDialogue{
|
||||
"Intersecting Region Found",
|
||||
"Region \"" + excludedRegionItem->getRegionNameInputValue()
|
||||
+ "\" intersects with region \"" + processedFocusedRegion.name + "\". "
|
||||
+ "Regions cannot intersect. Please review the relevant address ranges.",
|
||||
this
|
||||
);
|
||||
};
|
||||
errorDialogue->show();
|
||||
return;
|
||||
}
|
||||
@@ -399,13 +403,13 @@ namespace Widgets
|
||||
|
||||
for (const auto& processedExcludedRegion : processedExcludedMemoryRegions) {
|
||||
if (processedExcludedRegion.intersectsWith(excludedRegion)) {
|
||||
auto* errorDialogue = new ErrorDialogue(
|
||||
auto* errorDialogue = new ErrorDialogue{
|
||||
"Intersecting Region Found",
|
||||
"Region \"" + excludedRegionItem->getRegionNameInputValue()
|
||||
+ "\" intersects with region \"" + processedExcludedRegion.name + "\". "
|
||||
+ "Regions cannot intersect. Please review the relevant address ranges.",
|
||||
this
|
||||
);
|
||||
};
|
||||
errorDialogue->show();
|
||||
return;
|
||||
}
|
||||
@@ -422,7 +426,7 @@ namespace Widgets
|
||||
|
||||
void MemoryRegionManagerWindow::openHelpPage() {
|
||||
QDesktopServices::openUrl(
|
||||
QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/docs/manage-memory-regions"))
|
||||
QUrl{QString::fromStdString(Services::PathService::homeDomainName() + "/docs/manage-memory-regions")}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include <QAction>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
|
||||
@@ -30,7 +32,8 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
explicit MemoryRegionManagerWindow(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
QWidget* parent = nullptr
|
||||
@@ -46,7 +49,8 @@ namespace Widgets
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
|
||||
private:
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||
std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@ namespace Widgets
|
||||
|
||||
RegionItem::RegionItem(
|
||||
const MemoryRegion& region,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
QWidget* parent
|
||||
)
|
||||
: ClickableWidget(parent)
|
||||
, memoryDescriptor(memoryDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
{
|
||||
this->setObjectName("region-item");
|
||||
this->setFixedHeight(50);
|
||||
@@ -36,14 +36,14 @@ namespace Widgets
|
||||
);
|
||||
this->addressRangeLabel->setObjectName("address-label");
|
||||
|
||||
auto* topLabelLayout = new QHBoxLayout();
|
||||
auto* topLabelLayout = new QHBoxLayout{};
|
||||
topLabelLayout->setSpacing(0);
|
||||
topLabelLayout->setContentsMargins(0, 0, 0, 0);
|
||||
topLabelLayout->addWidget(this->nameLabel, 0, Qt::AlignmentFlag::AlignLeft);
|
||||
topLabelLayout->addStretch(1);
|
||||
topLabelLayout->addWidget(this->typeLabel, 0, Qt::AlignmentFlag::AlignRight);
|
||||
|
||||
auto* bottomLabelLayout = new QHBoxLayout();
|
||||
auto* bottomLabelLayout = new QHBoxLayout{};
|
||||
bottomLabelLayout->setSpacing(0);
|
||||
bottomLabelLayout->setContentsMargins(0, 0, 0, 0);
|
||||
bottomLabelLayout->addWidget(this->addressRangeLabel, 0, Qt::AlignmentFlag::AlignLeft);
|
||||
@@ -77,7 +77,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
QStringList RegionItem::getValidationFailures() const {
|
||||
auto validationFailures = QStringList();
|
||||
auto validationFailures = QStringList{};
|
||||
|
||||
if (this->nameInput->text().isEmpty()) {
|
||||
validationFailures.emplace_back("Missing region name.");
|
||||
@@ -85,12 +85,12 @@ namespace Widgets
|
||||
|
||||
bool conversionOk = false;
|
||||
|
||||
std::uint32_t startAddress = this->startAddressInput->text().toUInt(&conversionOk, 16);
|
||||
const auto startAddress = this->startAddressInput->text().toUInt(&conversionOk, 16);
|
||||
if (!conversionOk) {
|
||||
validationFailures.emplace_back("Invalid start address.");
|
||||
}
|
||||
|
||||
std::uint32_t endAddress = this->endAddressInput->text().toUInt(&conversionOk, 16);
|
||||
const auto endAddress = this->endAddressInput->text().toUInt(&conversionOk, 16);
|
||||
if (!conversionOk) {
|
||||
validationFailures.emplace_back("Invalid end address.");
|
||||
}
|
||||
@@ -100,16 +100,16 @@ namespace Widgets
|
||||
}
|
||||
|
||||
auto addressType = this->getSelectedAddressInputType();
|
||||
const auto memoryAddressRange = this->memoryDescriptor.addressRange;
|
||||
const auto memoryAddressRange = this->memorySegmentDescriptor.addressRange;
|
||||
|
||||
const auto memoryAddressRangeStr = QString(
|
||||
const auto memoryAddressRangeStr = QString{
|
||||
"0x" + QString::number(memoryAddressRange.startAddress, 16).toUpper() + QString(" -> ")
|
||||
+ "0x" + QString::number(memoryAddressRange.endAddress, 16).toUpper()
|
||||
);
|
||||
};
|
||||
|
||||
const auto absoluteAddressRange = addressType == AddressType::RELATIVE
|
||||
? this->convertRelativeToAbsoluteAddressRange(TargetMemoryAddressRange(startAddress, endAddress))
|
||||
: TargetMemoryAddressRange(startAddress, endAddress);
|
||||
? this->convertRelativeToAbsoluteAddressRange(TargetMemoryAddressRange{startAddress, endAddress})
|
||||
: TargetMemoryAddressRange{startAddress, endAddress};
|
||||
|
||||
if (absoluteAddressRange.startAddress < memoryAddressRange.startAddress
|
||||
|| absoluteAddressRange.startAddress > memoryAddressRange.endAddress
|
||||
@@ -191,26 +191,26 @@ namespace Widgets
|
||||
TargetMemoryAddressRange RegionItem::convertAbsoluteToRelativeAddressRange(
|
||||
const TargetMemoryAddressRange& absoluteAddressRange
|
||||
) const {
|
||||
return TargetMemoryAddressRange(
|
||||
absoluteAddressRange.startAddress - this->memoryDescriptor.addressRange.startAddress,
|
||||
absoluteAddressRange.endAddress - this->memoryDescriptor.addressRange.startAddress
|
||||
);
|
||||
return TargetMemoryAddressRange{
|
||||
absoluteAddressRange.startAddress - this->memorySegmentDescriptor.addressRange.startAddress,
|
||||
absoluteAddressRange.endAddress - this->memorySegmentDescriptor.addressRange.startAddress
|
||||
};
|
||||
}
|
||||
|
||||
TargetMemoryAddressRange RegionItem::convertRelativeToAbsoluteAddressRange(
|
||||
const TargetMemoryAddressRange& relativeAddressRange
|
||||
) const {
|
||||
return TargetMemoryAddressRange(
|
||||
relativeAddressRange.startAddress + this->memoryDescriptor.addressRange.startAddress,
|
||||
relativeAddressRange.endAddress + this->memoryDescriptor.addressRange.startAddress
|
||||
);
|
||||
return TargetMemoryAddressRange{
|
||||
relativeAddressRange.startAddress + this->memorySegmentDescriptor.addressRange.startAddress,
|
||||
relativeAddressRange.endAddress + this->memorySegmentDescriptor.addressRange.startAddress
|
||||
};
|
||||
}
|
||||
|
||||
void RegionItem::onAddressRangeInputChange() {
|
||||
bool startAddressConversionOk = false;
|
||||
bool endAddressConversionOk = false;
|
||||
std::uint32_t startAddress = this->startAddressInput->text().toUInt(&startAddressConversionOk, 16);
|
||||
std::uint32_t endAddress = this->endAddressInput->text().toUInt(&endAddressConversionOk, 16);
|
||||
auto startAddressConversionOk = false;
|
||||
auto endAddressConversionOk = false;
|
||||
const auto startAddress = this->startAddressInput->text().toUInt(&startAddressConversionOk, 16);
|
||||
const auto endAddress = this->endAddressInput->text().toUInt(&endAddressConversionOk, 16);
|
||||
|
||||
if (startAddressConversionOk && endAddressConversionOk && startAddress <= endAddress) {
|
||||
this->sizeInput->setText(QString::number((endAddress - startAddress) + 1));
|
||||
@@ -218,10 +218,10 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void RegionItem::onSizeInputChange() {
|
||||
bool startAddressConversionOk = false;
|
||||
bool sizeConversionOk = false;
|
||||
std::uint32_t startAddress = this->startAddressInput->text().toUInt(&startAddressConversionOk, 16);
|
||||
std::uint32_t size = this->sizeInput->text().toUInt(&sizeConversionOk, 10);
|
||||
auto startAddressConversionOk = false;
|
||||
auto sizeConversionOk = false;
|
||||
const auto startAddress = this->startAddressInput->text().toUInt(&startAddressConversionOk, 16);
|
||||
const auto size = this->sizeInput->text().toUInt(&sizeConversionOk, 10);
|
||||
|
||||
if (startAddressConversionOk && sizeConversionOk && size > 0) {
|
||||
this->endAddressInput->setText("0x" + QString::number((startAddress + size) - 1, 16).toUpper());
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
@@ -34,7 +36,7 @@ namespace Widgets
|
||||
public:
|
||||
RegionItem(
|
||||
const MemoryRegion& region,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
QWidget *parent
|
||||
);
|
||||
void setSelected(bool selected);
|
||||
@@ -56,7 +58,7 @@ namespace Widgets
|
||||
protected:
|
||||
static constexpr int NAME_LABEL_MAX_LENGTH = 34;
|
||||
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
|
||||
QWidget* formWidget = nullptr;
|
||||
TextInput* nameInput = nullptr;
|
||||
@@ -86,8 +88,8 @@ namespace Widgets
|
||||
static const inline std::map<QString, AddressRangeTypeOption> addressRangeTypeOptionsByName = std::map<
|
||||
QString, AddressRangeTypeOption
|
||||
>({
|
||||
{"absolute", AddressRangeTypeOption("Absolute", AddressType::ABSOLUTE)},
|
||||
{"relative", AddressRangeTypeOption("Relative", AddressType::RELATIVE)},
|
||||
{"absolute", AddressRangeTypeOption{"Absolute", AddressType::ABSOLUTE}},
|
||||
{"relative", AddressRangeTypeOption{"Relative", AddressType::RELATIVE}},
|
||||
});
|
||||
|
||||
void onAddressRangeInputChange();
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
#include <QByteArray>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "src/Helpers/EnumToStringMappings.hpp"
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
MemorySnapshot::MemorySnapshot(
|
||||
const QString& name,
|
||||
const QString& description,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const QString& addressSpaceKey,
|
||||
const QString& memorySegmentKey,
|
||||
const Targets::TargetMemoryBuffer& data,
|
||||
Targets::TargetMemoryAddress programCounter,
|
||||
Targets::TargetStackPointer stackPointer,
|
||||
@@ -20,7 +20,8 @@ MemorySnapshot::MemorySnapshot(
|
||||
: id(QUuid::createUuid().toString(QUuid::StringFormat::WithoutBraces))
|
||||
, name(name)
|
||||
, description(description)
|
||||
, memoryType(memoryType)
|
||||
, addressSpaceKey(addressSpaceKey)
|
||||
, memorySegmentKey(memorySegmentKey)
|
||||
, data(data)
|
||||
, programCounter(programCounter)
|
||||
, stackPointer(stackPointer)
|
||||
@@ -28,14 +29,17 @@ MemorySnapshot::MemorySnapshot(
|
||||
, excludedRegions(excludedRegions)
|
||||
{}
|
||||
|
||||
MemorySnapshot::MemorySnapshot(const QJsonObject& jsonObject) {
|
||||
MemorySnapshot::MemorySnapshot(const QJsonObject& jsonObject, const Targets::TargetDescriptor& targetDescriptor) {
|
||||
using Exceptions::Exception;
|
||||
|
||||
if (
|
||||
!jsonObject.contains("id")
|
||||
|| !jsonObject.contains("name")
|
||||
|| !jsonObject.contains("description")
|
||||
|| !jsonObject.contains("memoryType")
|
||||
|| (
|
||||
!jsonObject.contains("memoryType")
|
||||
&& (!jsonObject.contains("addressSpaceKey") || !jsonObject.contains("memorySegmentKey"))
|
||||
)
|
||||
|| !jsonObject.contains("hexData")
|
||||
|| !jsonObject.contains("programCounter")
|
||||
|| !jsonObject.contains("stackPointer")
|
||||
@@ -43,27 +47,62 @@ MemorySnapshot::MemorySnapshot(const QJsonObject& jsonObject) {
|
||||
|| !jsonObject.contains("focusedRegions")
|
||||
|| !jsonObject.contains("excludedRegions")
|
||||
) {
|
||||
throw Exception("Missing data");
|
||||
throw Exception{"Missing data"};
|
||||
}
|
||||
|
||||
this->id = jsonObject.find("id")->toString();
|
||||
this->name = jsonObject.find("name")->toString();
|
||||
this->description = jsonObject.find("description")->toString();
|
||||
this->memoryType = EnumToStringMappings::targetMemoryTypes.at(jsonObject.find("memoryType")->toString());
|
||||
|
||||
if (!jsonObject.contains("addressSpaceKey") || !jsonObject.contains("memorySegmentKey")) {
|
||||
/*
|
||||
* Temporary fallback for backwards compatability with snapshot files that were created by a version prior
|
||||
* to v2.0.0. Those files will contain a 'memoryType' field, which we map to AVR address spaces and memory
|
||||
* segments here.
|
||||
*
|
||||
* Bloom only supported AVR targets before v2.0.0, which is why we only need to be concerned with AVR address
|
||||
* spaces and memory segments, here.
|
||||
*
|
||||
* @TODO: Bin this after a few versions from v2.0.0.
|
||||
*/
|
||||
|
||||
const auto memoryType = jsonObject.find("memoryType")->toString();
|
||||
|
||||
if (memoryType == "ram") {
|
||||
this->addressSpaceKey = "data";
|
||||
this->memorySegmentKey = "internal_ram";
|
||||
|
||||
} else if (memoryType == "eeprom") {
|
||||
// Some AVR targets have a separate address space for EEPROM, others use the `data` address space.
|
||||
this->addressSpaceKey = targetDescriptor.tryGetAddressSpaceDescriptor("eeprom").has_value()
|
||||
? "eeprom"
|
||||
: "data";
|
||||
this->memorySegmentKey = "internal_eeprom";
|
||||
|
||||
} else if (memoryType == "flash") {
|
||||
this->addressSpaceKey = "prog";
|
||||
this->memorySegmentKey = "internal_program_memory";
|
||||
}
|
||||
|
||||
} else {
|
||||
this->addressSpaceKey = jsonObject.find("addressSpaceKey")->toString();
|
||||
this->memorySegmentKey = jsonObject.find("memorySegmentKey")->toString();
|
||||
}
|
||||
|
||||
this->programCounter = static_cast<Targets::TargetMemoryAddress>(jsonObject.find("programCounter")->toInteger());
|
||||
this->stackPointer = static_cast<Targets::TargetStackPointer>(jsonObject.find("stackPointer")->toInteger());
|
||||
this->createdDate.setSecsSinceEpoch(jsonObject.find("createdTimestamp")->toInteger());
|
||||
|
||||
const auto hexData = QByteArray::fromHex(jsonObject.find("hexData")->toString().toUtf8());
|
||||
this->data = Targets::TargetMemoryBuffer(hexData.begin(), hexData.end());
|
||||
this->data = Targets::TargetMemoryBuffer{hexData.begin(), hexData.end()};
|
||||
|
||||
if (jsonObject.contains("focusedRegions")) {
|
||||
for (const auto& regionValue : jsonObject.find("focusedRegions")->toArray()) {
|
||||
try {
|
||||
this->focusedRegions.emplace_back(regionValue.toObject());
|
||||
|
||||
} catch (Exception exception) {
|
||||
throw Exception("Invalid focused memory region");
|
||||
} catch (const Exception& exception) {
|
||||
throw Exception{"Invalid focused memory region"};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,65 +112,57 @@ MemorySnapshot::MemorySnapshot(const QJsonObject& jsonObject) {
|
||||
try {
|
||||
this->excludedRegions.emplace_back(regionValue.toObject());
|
||||
|
||||
} catch (Exception exception) {
|
||||
throw Exception("Invalid excluded memory region");
|
||||
} catch (const Exception& exception) {
|
||||
throw Exception{"Invalid excluded memory region"};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject MemorySnapshot::toJson() const {
|
||||
auto focusedRegions = QJsonArray();
|
||||
auto focusedRegions = QJsonArray{};
|
||||
for (const auto& focusedRegion : this->focusedRegions) {
|
||||
focusedRegions.push_back(focusedRegion.toJson());
|
||||
}
|
||||
|
||||
auto excludedRegions = QJsonArray();
|
||||
auto excludedRegions = QJsonArray{};
|
||||
for (const auto& excludedRegion : this->excludedRegions) {
|
||||
excludedRegions.push_back(excludedRegion.toJson());
|
||||
}
|
||||
|
||||
return QJsonObject({
|
||||
return QJsonObject{
|
||||
{"id", this->id},
|
||||
{"name", this->name},
|
||||
{"description", this->description},
|
||||
{"memoryType", EnumToStringMappings::targetMemoryTypes.at(this->memoryType)},
|
||||
{"hexData", QString(QByteArray(
|
||||
reinterpret_cast<const char*>(this->data.data()),
|
||||
static_cast<qsizetype>(this->data.size())
|
||||
).toHex())},
|
||||
{"addressSpaceKey", this->addressSpaceKey},
|
||||
{"memorySegmentKey", this->memorySegmentKey},
|
||||
{"hexData", QString{
|
||||
QByteArray{
|
||||
reinterpret_cast<const char*>(this->data.data()),
|
||||
static_cast<qsizetype>(this->data.size())
|
||||
}.toHex()
|
||||
}},
|
||||
{"programCounter", static_cast<qint64>(this->programCounter)},
|
||||
{"stackPointer", static_cast<qint64>(this->stackPointer)},
|
||||
{"createdTimestamp", this->createdDate.toSecsSinceEpoch()},
|
||||
{"focusedRegions", focusedRegions},
|
||||
{"excludedRegions", excludedRegions},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
bool MemorySnapshot::isCompatible(const Targets::TargetMemoryDescriptor& memoryDescriptor) const {
|
||||
if (this->memoryType != memoryDescriptor.type) {
|
||||
bool MemorySnapshot::isCompatible(const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor) const {
|
||||
if (this->data.size() != memorySegmentDescriptor.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->data.size() != memoryDescriptor.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto& memoryAddressRange = memoryDescriptor.addressRange;
|
||||
for (const auto& focusedRegion : this->focusedRegions) {
|
||||
if (
|
||||
focusedRegion.addressRange.startAddress < memoryAddressRange.startAddress
|
||||
|| focusedRegion.addressRange.endAddress > memoryAddressRange.endAddress
|
||||
) {
|
||||
if (!memorySegmentDescriptor.addressRange.contains(focusedRegion.addressRange)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& excludedRegion : this->excludedRegions) {
|
||||
if (
|
||||
excludedRegion.addressRange.startAddress < memoryAddressRange.startAddress
|
||||
|| excludedRegion.addressRange.endAddress > memoryAddressRange.endAddress
|
||||
) {
|
||||
if (!memorySegmentDescriptor.addressRange.contains(excludedRegion.addressRange)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -140,7 +171,7 @@ bool MemorySnapshot::isCompatible(const Targets::TargetMemoryDescriptor& memoryD
|
||||
}
|
||||
|
||||
std::set<Targets::TargetMemoryAddress> MemorySnapshot::excludedAddresses() const {
|
||||
auto output = std::set<Targets::TargetMemoryAddress>();
|
||||
auto output = std::set<Targets::TargetMemoryAddress>{};
|
||||
|
||||
for (const auto& excludedRegion : this->excludedRegions) {
|
||||
const auto regionAddresses = excludedRegion.addressRange.addresses();
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Services/DateTimeService.hpp"
|
||||
|
||||
#include "FocusedMemoryRegion.hpp"
|
||||
@@ -18,7 +20,8 @@ public:
|
||||
QString id;
|
||||
QString name;
|
||||
QString description;
|
||||
Targets::TargetMemoryType memoryType;
|
||||
QString addressSpaceKey;
|
||||
QString memorySegmentKey;
|
||||
Targets::TargetMemoryBuffer data;
|
||||
Targets::TargetMemoryAddress programCounter;
|
||||
Targets::TargetStackPointer stackPointer;
|
||||
@@ -30,7 +33,8 @@ public:
|
||||
MemorySnapshot(
|
||||
const QString& name,
|
||||
const QString& description,
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const QString& addressSpaceKey,
|
||||
const QString& memorySegmentKey,
|
||||
const Targets::TargetMemoryBuffer& data,
|
||||
Targets::TargetMemoryAddress programCounter,
|
||||
Targets::TargetStackPointer stackPointer,
|
||||
@@ -38,11 +42,11 @@ public:
|
||||
const std::vector<ExcludedMemoryRegion>& excludedRegions
|
||||
);
|
||||
|
||||
MemorySnapshot(const QJsonObject& jsonObject);
|
||||
MemorySnapshot(const QJsonObject& jsonObject, const Targets::TargetDescriptor& targetDescriptor);
|
||||
|
||||
QJsonObject toJson() const;
|
||||
|
||||
bool isCompatible(const Targets::TargetMemoryDescriptor& memoryDescriptor) const;
|
||||
bool isCompatible(const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor) const;
|
||||
std::set<Targets::TargetMemoryAddress> excludedAddresses() const;
|
||||
|
||||
virtual ~MemorySnapshot() = default;
|
||||
|
||||
@@ -17,35 +17,40 @@ namespace Widgets
|
||||
using Exceptions::Exception;
|
||||
|
||||
CreateSnapshotWindow::CreateSnapshotWindow(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const bool& staleData,
|
||||
QWidget* parent
|
||||
)
|
||||
: QWidget(parent)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, targetState(targetState)
|
||||
, data(data)
|
||||
, staleData(staleData)
|
||||
{
|
||||
this->setWindowFlag(Qt::Window);
|
||||
this->setObjectName("create-snapshot-window");
|
||||
this->setWindowTitle(
|
||||
"New Snapshot - " + EnumToStringMappings::targetMemoryTypes.at(memoryType).toUpper()
|
||||
"New Snapshot - " + QString::fromStdString(this->memorySegmentDescriptor.name)
|
||||
);
|
||||
|
||||
auto windowUiFile = QFile(
|
||||
auto windowUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/SnapshotManager/CreateSnapshotWindow/UiFiles/CreateSnapshotWindow.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!windowUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open CreateSnapshotWindow UI file");
|
||||
throw Exception{"Failed to open CreateSnapshotWindow UI file"};
|
||||
}
|
||||
|
||||
this->setFixedSize(QSize(500, 300));
|
||||
this->setFixedSize(QSize{500, 300});
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&windowUiFile, this);
|
||||
|
||||
this->container->setFixedSize(this->size());
|
||||
@@ -74,14 +79,11 @@ namespace Widgets
|
||||
QObject::connect(this->captureButton, &QPushButton::clicked, this, &CreateSnapshotWindow::issueCaptureRequest);
|
||||
QObject::connect(this->closeButton, &QPushButton::clicked, this, &QWidget::close);
|
||||
|
||||
auto* insightSignals = InsightSignals::instance();
|
||||
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
InsightSignals::instance(),
|
||||
&InsightSignals::targetStateUpdated,
|
||||
this,
|
||||
[this] (Targets::TargetState newState) {
|
||||
this->targetState = newState;
|
||||
[this] () {
|
||||
this->refreshForm();
|
||||
}
|
||||
);
|
||||
@@ -119,7 +121,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
bool CreateSnapshotWindow::captureEnabled() {
|
||||
if (this->targetState != Targets::TargetState::STOPPED) {
|
||||
if (this->targetState.executionState != Targets::TargetExecutionState::STOPPED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/PushButton.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
namespace Widgets
|
||||
@@ -21,7 +23,9 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
explicit CreateSnapshotWindow(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const bool& staleData,
|
||||
QWidget* parent = nullptr
|
||||
@@ -42,6 +46,10 @@ namespace Widgets
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
|
||||
private:
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
QWidget* container = nullptr;
|
||||
TextInput* nameInput = nullptr;
|
||||
QPlainTextEdit* descriptionInput = nullptr;
|
||||
@@ -56,7 +64,6 @@ namespace Widgets
|
||||
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data;
|
||||
const bool& staleData;
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
bool captureEnabled();
|
||||
void resetForm();
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Widgets
|
||||
MemorySnapshotItem::MemorySnapshotItem(const MemorySnapshot& memorySnapshot)
|
||||
: memorySnapshot(memorySnapshot)
|
||||
{
|
||||
this->size = QSize(0, MemorySnapshotItem::HEIGHT);
|
||||
this->size = QSize{0, MemorySnapshotItem::HEIGHT};
|
||||
|
||||
this->nameText = memorySnapshot.name;
|
||||
this->programCounterText = "0x" + QString::number(this->memorySnapshot.programCounter, 16).toUpper();
|
||||
@@ -19,22 +19,22 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void MemorySnapshotItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||
static constexpr auto margins = QMargins(5, 5, 5, 0);
|
||||
static constexpr auto margins = QMargins{5, 5, 5, 0};
|
||||
|
||||
static auto font = QFont("'Ubuntu', sans-serif");
|
||||
static auto font = QFont{"'Ubuntu', sans-serif"};
|
||||
font.setPixelSize(14);
|
||||
static auto secondaryFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto secondaryFont = QFont{"'Ubuntu', sans-serif"};
|
||||
secondaryFont.setPixelSize(13);
|
||||
|
||||
static constexpr auto fontColor = QColor(0xAF, 0xB1, 0xB3);
|
||||
static constexpr auto secondaryFontColor = QColor(0x8A, 0x8A, 0x8D);
|
||||
static constexpr auto fontColor = QColor{0xAF, 0xB1, 0xB3};
|
||||
static constexpr auto secondaryFontColor = QColor{0x8A, 0x8A, 0x8D};
|
||||
|
||||
if (this->selected) {
|
||||
static constexpr auto selectedBackgroundColor = QColor(0x3C, 0x59, 0x5C);
|
||||
static constexpr auto selectedBackgroundColor = QColor{0x3C, 0x59, 0x5C};
|
||||
|
||||
painter->setBrush(selectedBackgroundColor);
|
||||
painter->setPen(Qt::PenStyle::NoPen);
|
||||
painter->drawRect(QRect(QPoint(0, 0), this->size));
|
||||
painter->drawRect(QRect{QPoint{0, 0}, this->size});
|
||||
}
|
||||
|
||||
painter->setFont(font);
|
||||
@@ -56,41 +56,39 @@ namespace Widgets
|
||||
);
|
||||
|
||||
const auto nameTextSize = fontMetrics.size(Qt::TextSingleLine, nameText);
|
||||
const auto nameTextRect = QRect(
|
||||
const auto nameTextRect = QRect{
|
||||
margins.left(),
|
||||
margins.top(),
|
||||
nameTextSize.width(),
|
||||
nameTextSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->drawText(nameTextRect, Qt::AlignLeft, nameText);
|
||||
|
||||
painter->setFont(secondaryFont);
|
||||
|
||||
if (!this->selected) {
|
||||
painter->setPen(secondaryFontColor);
|
||||
}
|
||||
|
||||
const auto programCounterTextRect = QRect(
|
||||
const auto programCounterTextRect = QRect{
|
||||
this->size.width() - margins.right() - programCounterTextSize.width(),
|
||||
margins.top(),
|
||||
programCounterTextSize.width(),
|
||||
programCounterTextSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->drawText(programCounterTextRect, Qt::AlignLeft, this->programCounterText);
|
||||
|
||||
const auto createdDateTextRect = QRect(
|
||||
const auto createdDateTextRect = QRect{
|
||||
margins.left(),
|
||||
nameTextRect.bottom() + 5,
|
||||
createdDateTextSize.width(),
|
||||
createdDateTextSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->drawText(createdDateTextRect, Qt::AlignLeft, this->createdDateText);
|
||||
|
||||
static constexpr auto borderColor = QColor(0x2E, 0x2E, 0x2E);
|
||||
|
||||
static constexpr auto borderColor = QColor{0x2E, 0x2E, 0x2E};
|
||||
painter->setPen(borderColor);
|
||||
painter->drawLine(0, this->size.height() - 1, this->size.width(), this->size.height() - 1);
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
#include <QString>
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListItem.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp"
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
@@ -17,8 +15,8 @@ namespace Widgets
|
||||
MemorySnapshotItem(const MemorySnapshot& memorySnapshot);
|
||||
|
||||
bool operator < (const ListItem& rhs) const override {
|
||||
const auto& rhsSnapshotItem = dynamic_cast<const MemorySnapshotItem&>(rhs);
|
||||
return this->memorySnapshot.createdDate > rhsSnapshotItem.memorySnapshot.createdDate;
|
||||
return this->memorySnapshot.createdDate >
|
||||
dynamic_cast<const MemorySnapshotItem&>(rhs).memorySnapshot.createdDate;
|
||||
}
|
||||
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
|
||||
|
||||
@@ -8,26 +8,26 @@ namespace Widgets
|
||||
ChangeListItem::ChangeListItem(const Targets::TargetMemoryAddressRange& addressRange)
|
||||
: addressRange(addressRange)
|
||||
{
|
||||
this->size = QSize(0, ChangeListItem::HEIGHT);
|
||||
this->size = QSize{0, ChangeListItem::HEIGHT};
|
||||
}
|
||||
|
||||
void ChangeListItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||
static constexpr auto margins = QMargins(7, 5, 7, 0);
|
||||
static constexpr auto margins = QMargins{7, 5, 7, 0};
|
||||
|
||||
static auto font = QFont("'Ubuntu', sans-serif");
|
||||
static auto font = QFont{"'Ubuntu', sans-serif"};
|
||||
font.setPixelSize(14);
|
||||
static auto secondaryFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto secondaryFont = QFont{"'Ubuntu', sans-serif"};
|
||||
secondaryFont.setPixelSize(13);
|
||||
|
||||
static constexpr auto fontColor = QColor(0xAF, 0xB1, 0xB3);
|
||||
static constexpr auto secondaryFontColor = QColor(0x8A, 0x8A, 0x8D);
|
||||
static constexpr auto fontColor = QColor{0xAF, 0xB1, 0xB3};
|
||||
static constexpr auto secondaryFontColor = QColor{0x8A, 0x8A, 0x8D};
|
||||
|
||||
if (this->selected) {
|
||||
static constexpr auto selectedBackgroundColor = QColor(0x3C, 0x59, 0x5C);
|
||||
static constexpr auto selectedBackgroundColor = QColor{0x3C, 0x59, 0x5C};
|
||||
|
||||
painter->setBrush(selectedBackgroundColor);
|
||||
painter->setPen(Qt::PenStyle::NoPen);
|
||||
painter->drawRect(QRect(QPoint(0, 0), this->size));
|
||||
painter->drawRect(QRect{QPoint{0, 0}, this->size});
|
||||
}
|
||||
|
||||
painter->setFont(font);
|
||||
@@ -36,16 +36,16 @@ namespace Widgets
|
||||
auto fontMetrics = painter->fontMetrics();
|
||||
|
||||
const auto byteCount = this->addressRange.endAddress - this->addressRange.startAddress + 1;
|
||||
const auto byteCountText = QLocale(QLocale::English).toString(byteCount)
|
||||
const auto byteCountText = QLocale{QLocale::English}.toString(byteCount)
|
||||
+ (byteCount == 1 ? " byte" : " bytes");
|
||||
const auto byteCountTextSize = fontMetrics.size(Qt::TextSingleLine, byteCountText);
|
||||
|
||||
const auto byteCountTextRect = QRect(
|
||||
const auto byteCountTextRect = QRect{
|
||||
margins.left(),
|
||||
margins.top(),
|
||||
byteCountTextSize.width(),
|
||||
byteCountTextSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->drawText(byteCountTextRect, Qt::AlignLeft, byteCountText);
|
||||
|
||||
@@ -77,16 +77,16 @@ namespace Widgets
|
||||
);
|
||||
|
||||
const auto addressRangeTextSize = fontMetrics.size(Qt::TextSingleLine, addressRangeText);
|
||||
const auto addressRangeTextRect = QRect(
|
||||
const auto addressRangeTextRect = QRect{
|
||||
margins.left(),
|
||||
byteCountTextRect.bottom() + 5,
|
||||
addressRangeTextSize.width(),
|
||||
addressRangeTextSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->drawText(addressRangeTextRect, Qt::AlignLeft, addressRangeText);
|
||||
|
||||
static constexpr auto borderColor = QColor(0x41, 0x42, 0x3F);
|
||||
static constexpr auto borderColor = QColor{0x41, 0x42, 0x3F};
|
||||
|
||||
painter->setPen(borderColor);
|
||||
painter->drawLine(0, this->size.height() - 1, this->size.width(), this->size.height() - 1);
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Widgets
|
||||
public:
|
||||
Targets::TargetMemoryAddressRange addressRange;
|
||||
|
||||
ChangeListItem(const Targets::TargetMemoryAddressRange& addressRange);
|
||||
explicit ChangeListItem(const Targets::TargetMemoryAddressRange& addressRange);
|
||||
|
||||
bool operator < (const ListItem& rhs) const override {
|
||||
const auto& rhsSnapshotItem = dynamic_cast<const ChangeListItem&>(rhs);
|
||||
|
||||
@@ -27,18 +27,18 @@ namespace Widgets
|
||||
this->setObjectName("change-list-pane");
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
auto widgetUiFile = QFile(
|
||||
auto widgetUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager"
|
||||
+ "/SnapshotDiff/ChangeListPane/UiFiles/ChangeListPane.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!widgetUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open ChangeListPane UI file");
|
||||
throw Exception{"Failed to open ChangeListPane UI file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&widgetUiFile, this);
|
||||
|
||||
this->container->setFixedSize(this->size());
|
||||
@@ -48,7 +48,7 @@ namespace Widgets
|
||||
|
||||
auto* containerLayout = this->container->findChild<QVBoxLayout*>();
|
||||
|
||||
this->changeListView = new ListView({}, this);
|
||||
this->changeListView = new ListView{{}, this};
|
||||
this->changeListView->viewport()->installEventFilter(parent);
|
||||
this->changeListView->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Widgets
|
||||
this->changeListScene->clearListItems();
|
||||
|
||||
for (const auto& diffRange : diffRanges) {
|
||||
this->changeListScene->addListItem(new ChangeListItem(diffRange));
|
||||
this->changeListScene->addListItem(new ChangeListItem{diffRange});
|
||||
}
|
||||
|
||||
this->changeListScene->refreshGeometry();
|
||||
@@ -167,7 +167,7 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
auto* menu = new QMenu(this);
|
||||
auto* menu = new QMenu{this};
|
||||
|
||||
menu->addAction(this->selectBytesAction);
|
||||
menu->addSeparator();
|
||||
|
||||
@@ -50,8 +50,8 @@ namespace Widgets
|
||||
|
||||
const ChangeListItem* selectedChangeListItem = nullptr;
|
||||
|
||||
QAction* selectBytesAction = new QAction("Select", this);
|
||||
QAction* restoreBytesAction = new QAction("Restore", this);
|
||||
QAction* selectBytesAction = new QAction{"Select", this};
|
||||
QAction* restoreBytesAction = new QAction{"Restore", this};
|
||||
|
||||
bool restoreEnabled = false;
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
struct DifferentialHexViewerSharedState
|
||||
|
||||
@@ -9,7 +9,9 @@ namespace Widgets
|
||||
DifferentialHexViewerWidgetType type,
|
||||
DifferentialHexViewerSharedState& state,
|
||||
const SnapshotDiffSettings& snapshotDiffSettings,
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
HexViewerWidgetSettings& settings,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
@@ -17,7 +19,9 @@ namespace Widgets
|
||||
QWidget* parent
|
||||
)
|
||||
: HexViewerWidget(
|
||||
targetMemoryDescriptor,
|
||||
addressSpaceDescriptor,
|
||||
memorySegmentDescriptor,
|
||||
targetState,
|
||||
data,
|
||||
settings,
|
||||
focusedMemoryRegions,
|
||||
@@ -30,17 +34,19 @@ namespace Widgets
|
||||
{}
|
||||
|
||||
void DifferentialHexViewerWidget::init() {
|
||||
this->differentialView = new DifferentialItemGraphicsView(
|
||||
this->differentialView = new DifferentialItemGraphicsView{
|
||||
this->type,
|
||||
this->state,
|
||||
this->snapshotDiffSettings,
|
||||
this->targetMemoryDescriptor,
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this->data,
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->settings,
|
||||
this->container
|
||||
);
|
||||
};
|
||||
|
||||
if (this->type == DifferentialHexViewerWidgetType::PRIMARY) {
|
||||
this->differentialView->setLayoutDirection(Qt::LayoutDirection::RightToLeft);
|
||||
|
||||
@@ -19,7 +19,9 @@ namespace Widgets
|
||||
DifferentialHexViewerWidgetType type,
|
||||
DifferentialHexViewerSharedState& state,
|
||||
const SnapshotDiffSettings& snapshotDiffSettings,
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
HexViewerWidgetSettings& settings,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
|
||||
@@ -8,7 +8,9 @@ namespace Widgets
|
||||
DifferentialHexViewerWidgetType differentialHexViewerWidgetType,
|
||||
DifferentialHexViewerSharedState& state,
|
||||
const SnapshotDiffSettings& snapshotDiffSettings,
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
@@ -16,7 +18,9 @@ namespace Widgets
|
||||
QGraphicsView* parent
|
||||
)
|
||||
: ItemGraphicsScene(
|
||||
targetMemoryDescriptor,
|
||||
addressSpaceDescriptor,
|
||||
memorySegmentDescriptor,
|
||||
targetState,
|
||||
data,
|
||||
focusedMemoryRegions,
|
||||
excludedMemoryRegions,
|
||||
|
||||
@@ -18,7 +18,9 @@ namespace Widgets
|
||||
DifferentialHexViewerWidgetType differentialHexViewerWidgetType,
|
||||
DifferentialHexViewerSharedState& state,
|
||||
const SnapshotDiffSettings& snapshotDiffSettings,
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
|
||||
@@ -6,7 +6,9 @@ namespace Widgets
|
||||
DifferentialHexViewerWidgetType differentialHexViewerWidgetType,
|
||||
DifferentialHexViewerSharedState& state,
|
||||
const SnapshotDiffSettings& snapshotDiffSettings,
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
@@ -14,7 +16,9 @@ namespace Widgets
|
||||
QWidget* parent
|
||||
)
|
||||
: ItemGraphicsView(
|
||||
targetMemoryDescriptor,
|
||||
addressSpaceDescriptor,
|
||||
memorySegmentDescriptor,
|
||||
targetState,
|
||||
data,
|
||||
focusedMemoryRegions,
|
||||
excludedMemoryRegions,
|
||||
@@ -27,17 +31,19 @@ namespace Widgets
|
||||
{}
|
||||
|
||||
void DifferentialItemGraphicsView::initScene() {
|
||||
this->differentialScene = new DifferentialItemGraphicsScene(
|
||||
this->differentialScene = new DifferentialItemGraphicsScene{
|
||||
this->differentialHexViewerWidgetType,
|
||||
this->state,
|
||||
this->snapshotDiffSettings,
|
||||
this->targetMemoryDescriptor,
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this->data,
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->settings,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
this->scene = this->differentialScene;
|
||||
this->setScene(this->scene);
|
||||
@@ -47,7 +53,7 @@ namespace Widgets
|
||||
&ItemGraphicsScene::ready,
|
||||
this,
|
||||
[this] {
|
||||
this->differentialScene->updateByteItemChangedStates();
|
||||
this->differentialScene->updateByteItemChangedStates();
|
||||
this->scene->setEnabled(this->isEnabled());
|
||||
emit this->sceneReady();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ namespace Widgets
|
||||
DifferentialHexViewerWidgetType differentialHexViewerWidgetType,
|
||||
DifferentialHexViewerSharedState& state,
|
||||
const SnapshotDiffSettings& snapshotDiffSettings,
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||
|
||||
@@ -26,12 +26,15 @@ namespace Widgets
|
||||
SnapshotDiff::SnapshotDiff(
|
||||
MemorySnapshot& snapshotA,
|
||||
MemorySnapshot& snapshotB,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
Targets::TargetState currentTargetState,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
QWidget* parent
|
||||
)
|
||||
: QWidget(parent)
|
||||
, memoryDescriptor(memoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, targetState(targetState)
|
||||
, hexViewerDataA(snapshotA.data)
|
||||
, focusedRegionsA(snapshotA.focusedRegions)
|
||||
, excludedRegionsA(snapshotA.excludedRegions)
|
||||
@@ -43,11 +46,9 @@ namespace Widgets
|
||||
, comparingWithCurrent(false)
|
||||
{
|
||||
this->init();
|
||||
this->onTargetStateChanged(currentTargetState);
|
||||
this->onTargetStateChanged();
|
||||
|
||||
this->setWindowTitle(
|
||||
"Comparing snapshot \"" + snapshotA.name + "\" with snapshot \"" + snapshotB.name + "\""
|
||||
);
|
||||
this->setWindowTitle("Comparing snapshot \"" + snapshotA.name + "\" with snapshot \"" + snapshotB.name + "\"");
|
||||
|
||||
this->dataAPrimaryLabel->setText(snapshotA.name);
|
||||
this->dataBPrimaryLabel->setText(snapshotB.name);
|
||||
@@ -61,12 +62,15 @@ namespace Widgets
|
||||
std::vector<FocusedMemoryRegion> focusedRegionsB,
|
||||
std::vector<ExcludedMemoryRegion> excludedRegionsB,
|
||||
Targets::TargetStackPointer stackPointerB,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
Targets::TargetState currentTargetState,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
QWidget* parent
|
||||
)
|
||||
: QWidget(parent)
|
||||
, memoryDescriptor(memoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, targetState(targetState)
|
||||
, hexViewerDataA(snapshotA.data)
|
||||
, focusedRegionsA(snapshotA.focusedRegions)
|
||||
, excludedRegionsA(snapshotA.excludedRegions)
|
||||
@@ -78,26 +82,24 @@ namespace Widgets
|
||||
, comparingWithCurrent(true)
|
||||
{
|
||||
this->init();
|
||||
this->onTargetStateChanged(currentTargetState);
|
||||
this->onTargetStateChanged();
|
||||
|
||||
this->setWindowTitle(
|
||||
"Comparing snapshot \"" + snapshotA.name + "\" with current memory"
|
||||
);
|
||||
this->setWindowTitle("Comparing snapshot \"" + snapshotA.name + "\" with current memory");
|
||||
|
||||
this->dataAPrimaryLabel->setText(snapshotA.name);
|
||||
this->dataBPrimaryLabel->setText("Current");
|
||||
this->dataASecondaryLabel->setText(snapshotA.createdDate.toString("dd/MM/yyyy hh:mm"));
|
||||
this->dataBSecondaryLabel->setVisible(false);
|
||||
|
||||
this->restoreBytesAction = new ContextMenuAction(
|
||||
this->restoreBytesAction = new ContextMenuAction{
|
||||
"Restore Selection",
|
||||
[this] (const std::set<Targets::TargetMemoryAddress>&) {
|
||||
return
|
||||
this->memoryDescriptor.access.writeableDuringDebugSession
|
||||
&& this->targetState == Targets::TargetState::STOPPED;
|
||||
this->memorySegmentDescriptor.debugModeAccess.writeable
|
||||
&& this->targetState.executionState == Targets::TargetExecutionState::STOPPED;
|
||||
},
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
this->restoreBytesAction,
|
||||
@@ -129,7 +131,7 @@ namespace Widgets
|
||||
this->excludedRegionsB = excludedRegions;
|
||||
this->stackPointerB = stackPointer;
|
||||
|
||||
if (this->memoryDescriptor.type == Targets::TargetMemoryType::RAM) {
|
||||
if (this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::RAM) {
|
||||
this->hexViewerWidgetB->setStackPointer(this->stackPointerB);
|
||||
}
|
||||
|
||||
@@ -170,26 +172,26 @@ namespace Widgets
|
||||
this->setWindowFlag(Qt::Window);
|
||||
this->setObjectName("snapshot-diff");
|
||||
|
||||
auto windowUiFile = QFile(
|
||||
auto windowUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/SnapshotManager/SnapshotDiff/UiFiles/SnapshotDiff.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto stylesheetFile = QFile(
|
||||
auto stylesheetFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/SnapshotManager/SnapshotDiff/Stylesheets/SnapshotDiff.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!windowUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open SnapshotDiff UI file");
|
||||
throw Exception{"Failed to open SnapshotDiff UI file"};
|
||||
}
|
||||
|
||||
if (!stylesheetFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open SnapshotDiff stylesheet file");
|
||||
throw Exception{"Failed to open SnapshotDiff stylesheet file"};
|
||||
}
|
||||
|
||||
// Set ideal window size
|
||||
@@ -197,7 +199,7 @@ namespace Widgets
|
||||
this->setMinimumSize(800, 600);
|
||||
this->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
const auto styleSheet = stylesheetFile.readAll();
|
||||
this->container = uiLoader.load(&windowUiFile, this);
|
||||
this->container->setStyleSheet(styleSheet);
|
||||
@@ -216,7 +218,7 @@ namespace Widgets
|
||||
"sub-container"
|
||||
)->findChild<QHBoxLayout*>("sub-layout");
|
||||
|
||||
this->leftPanel = new PanelWidget(PanelWidgetType::LEFT, this->leftPanelState, this);
|
||||
this->leftPanel = new PanelWidget{PanelWidgetType::LEFT, this->leftPanelState, this};
|
||||
this->leftPanel->setObjectName("left-panel");
|
||||
this->leftPanel->setMinimumResize(200);
|
||||
this->leftPanel->setHandleSize(6);
|
||||
@@ -233,29 +235,33 @@ namespace Widgets
|
||||
auto snapshotAContainerLayout = this->dataAContainer->findChild<QVBoxLayout*>();
|
||||
auto snapshotBContainerLayout = this->dataBContainer->findChild<QVBoxLayout*>();
|
||||
|
||||
this->hexViewerWidgetA = new DifferentialHexViewerWidget(
|
||||
this->hexViewerWidgetA = new DifferentialHexViewerWidget{
|
||||
DifferentialHexViewerWidgetType::PRIMARY,
|
||||
this->differentialHexViewerSharedState,
|
||||
this->settings,
|
||||
this->memoryDescriptor,
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this->hexViewerDataA,
|
||||
this->hexViewerWidgetSettingsA,
|
||||
this->focusedRegionsA,
|
||||
this->excludedRegionsA,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
this->hexViewerWidgetB = new DifferentialHexViewerWidget(
|
||||
this->hexViewerWidgetB = new DifferentialHexViewerWidget{
|
||||
DifferentialHexViewerWidgetType::SECONDARY,
|
||||
this->differentialHexViewerSharedState,
|
||||
this->settings,
|
||||
this->memoryDescriptor,
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this->hexViewerDataB,
|
||||
this->hexViewerWidgetSettingsB,
|
||||
this->focusedRegionsB,
|
||||
this->excludedRegionsB,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
this->hexViewerWidgetA->setObjectName("differential-hex-viewer-widget-a");
|
||||
this->hexViewerWidgetB->setObjectName("differential-hex-viewer-widget-b");
|
||||
@@ -266,17 +272,17 @@ namespace Widgets
|
||||
snapshotAContainerLayout->addWidget(this->hexViewerWidgetA);
|
||||
snapshotBContainerLayout->addWidget(this->hexViewerWidgetB);
|
||||
|
||||
this->changeListPane = new ChangeListPane(
|
||||
this->changeListPane = new ChangeListPane{
|
||||
this->hexViewerWidgetA,
|
||||
this->hexViewerWidgetB,
|
||||
this->changeListPaneState,
|
||||
this->leftPanel
|
||||
);
|
||||
};
|
||||
|
||||
this->changeListPane->setRestoreEnabled(
|
||||
this->comparingWithCurrent
|
||||
&& this->memoryDescriptor.access.writeableDuringDebugSession
|
||||
&& this->targetState == Targets::TargetState::STOPPED
|
||||
&& this->memorySegmentDescriptor.debugModeAccess.writeable
|
||||
&& this->targetState.executionState == Targets::TargetExecutionState::STOPPED
|
||||
);
|
||||
|
||||
this->leftPanel->layout()->addWidget(this->changeListPane);
|
||||
@@ -286,15 +292,13 @@ namespace Widgets
|
||||
this->bottomBarLayout = this->bottomBar->findChild<QHBoxLayout*>();
|
||||
|
||||
this->memoryCapacityLabel = this->bottomBar->findChild<Label*>("memory-capacity-label");
|
||||
this->memoryTypeLabel = this->bottomBar->findChild<Label*>("memory-type-label");
|
||||
this->memorySegmentNameLabel = this->bottomBar->findChild<Label*>("memory-segment-name-label");
|
||||
this->diffCountLabel = this->bottomBar->findChild<Label*>("diff-count-label");
|
||||
|
||||
this->memoryCapacityLabel->setText(QLocale(QLocale::English).toString(this->hexViewerDataA->size()) + " bytes");
|
||||
this->memoryTypeLabel->setText(EnumToStringMappings::targetMemoryTypes.at(
|
||||
this->memoryDescriptor.type).toUpper()
|
||||
);
|
||||
this->memoryCapacityLabel->setText(QLocale{QLocale::English}.toString(this->hexViewerDataA->size()) + " bytes");
|
||||
this->memorySegmentNameLabel->setText(QString::fromStdString(this->memorySegmentDescriptor.name));
|
||||
|
||||
this->taskProgressIndicator = new TaskProgressIndicator(this);
|
||||
this->taskProgressIndicator = new TaskProgressIndicator{this};
|
||||
this->bottomBarLayout->insertWidget(7, this->taskProgressIndicator);
|
||||
|
||||
this->setSyncHexViewerSettingsEnabled(this->settings.syncHexViewerSettings);
|
||||
@@ -345,10 +349,8 @@ namespace Widgets
|
||||
}
|
||||
);
|
||||
|
||||
auto* insightSignals = InsightSignals::instance();
|
||||
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
InsightSignals::instance(),
|
||||
&InsightSignals::targetStateUpdated,
|
||||
this,
|
||||
&SnapshotDiff::onTargetStateChanged
|
||||
@@ -372,7 +374,7 @@ namespace Widgets
|
||||
this->hexViewerWidgetA->addExternalContextMenuAction(this->restoreBytesAction);
|
||||
}
|
||||
|
||||
if (this->memoryDescriptor.type == Targets::TargetMemoryType::RAM) {
|
||||
if (this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::RAM) {
|
||||
this->hexViewerWidgetA->setStackPointer(this->stackPointerA);
|
||||
}
|
||||
}
|
||||
@@ -380,7 +382,7 @@ namespace Widgets
|
||||
void SnapshotDiff::onHexViewerBReady() {
|
||||
this->hexViewerWidgetA->setOther(this->hexViewerWidgetB);
|
||||
|
||||
if (this->memoryDescriptor.type == Targets::TargetMemoryType::RAM) {
|
||||
if (this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::RAM) {
|
||||
this->hexViewerWidgetB->setStackPointer(this->stackPointerB);
|
||||
}
|
||||
}
|
||||
@@ -392,7 +394,7 @@ namespace Widgets
|
||||
assert(this->hexViewerDataB.has_value());
|
||||
|
||||
this->differentialHexViewerSharedState.differences.clear();
|
||||
auto diffRanges = std::vector<TargetMemoryAddressRange>();
|
||||
auto diffRanges = std::vector<TargetMemoryAddressRange>{};
|
||||
|
||||
const auto& dataA = *(this->hexViewerDataA);
|
||||
const auto& dataB = *(this->hexViewerDataB);
|
||||
@@ -413,10 +415,10 @@ namespace Widgets
|
||||
return false;
|
||||
};
|
||||
|
||||
const auto& memoryStartAddress = this->memoryDescriptor.addressRange.startAddress;
|
||||
auto lastDiffRange = std::optional<TargetMemoryAddressRange>();
|
||||
const auto& memoryStartAddress = this->memorySegmentDescriptor.addressRange.startAddress;
|
||||
auto lastDiffRange = std::optional<TargetMemoryAddressRange>{};
|
||||
|
||||
for (Targets::TargetMemoryBuffer::size_type i = 0; i < dataA.size(); ++i) {
|
||||
for (auto i = Targets::TargetMemoryBuffer::size_type{0}; i < dataA.size(); ++i) {
|
||||
const auto address = memoryStartAddress + static_cast<Targets::TargetMemoryAddress>(i);
|
||||
|
||||
if (dataA[i] != dataB[i] && !isAddressExcluded(address)) {
|
||||
@@ -430,7 +432,7 @@ namespace Widgets
|
||||
diffRanges.push_back(*lastDiffRange);
|
||||
}
|
||||
|
||||
lastDiffRange = TargetMemoryAddressRange(address, address);
|
||||
lastDiffRange = TargetMemoryAddressRange{address, address};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -445,7 +447,7 @@ namespace Widgets
|
||||
this->diffCountLabel->setText(
|
||||
diffCount == 0
|
||||
? "Contents are identical"
|
||||
: QLocale(QLocale::English).toString(diffCount) + (diffCount == 1 ? " difference" : " differences")
|
||||
: QLocale{QLocale::English}.toString(diffCount) + (diffCount == 1 ? " difference" : " differences")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -484,7 +486,7 @@ namespace Widgets
|
||||
std::set<Targets::TargetMemoryAddress> addresses,
|
||||
bool confirmationPromptEnabled
|
||||
) {
|
||||
auto excludedAddresses = std::set<Targets::TargetMemoryAddress>();
|
||||
auto excludedAddresses = std::set<Targets::TargetMemoryAddress>{};
|
||||
for (const auto& excludedRegion : this->excludedRegionsA) {
|
||||
const auto regionAddresses = excludedRegion.addressRange.addresses();
|
||||
excludedAddresses.insert(regionAddresses.begin(), regionAddresses.end());
|
||||
@@ -500,15 +502,15 @@ namespace Widgets
|
||||
}
|
||||
|
||||
if (confirmationPromptEnabled) {
|
||||
auto* confirmationDialog = new ConfirmationDialog(
|
||||
auto* confirmationDialog = new ConfirmationDialog{
|
||||
"Restore selected bytes",
|
||||
"This operation will write " + QString::number(addresses.size()) + " byte(s) to the target's "
|
||||
+ EnumToStringMappings::targetMemoryTypes.at(this->memoryDescriptor.type).toUpper()
|
||||
+ ".<br/><br/>Are you sure you want to proceed?",
|
||||
"This operation will write " + QString::number(addresses.size()) + " byte(s) to the target's \""
|
||||
+ QString::fromStdString(this->memorySegmentDescriptor.name)
|
||||
+ "\" segment.<br/><br/>Are you sure you want to proceed?",
|
||||
"Proceed",
|
||||
std::nullopt,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
confirmationDialog,
|
||||
@@ -523,23 +525,23 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
auto writeBlocks = std::vector<WriteTargetMemory::Block>();
|
||||
auto writeBlocks = std::vector<WriteTargetMemory::Block>{};
|
||||
|
||||
Targets::TargetMemoryAddress blockStartAddress = *(addresses.begin());
|
||||
Targets::TargetMemoryAddress blockEndAddress = blockStartAddress;
|
||||
auto blockStartAddress = *(addresses.begin());
|
||||
auto blockEndAddress = blockStartAddress;
|
||||
|
||||
for (const auto& address : addresses) {
|
||||
if (address > (blockEndAddress + 1)) {
|
||||
// Commit the block
|
||||
const auto dataBeginOffset = blockStartAddress - this->memoryDescriptor.addressRange.startAddress;
|
||||
const auto dataEndOffset = blockEndAddress - this->memoryDescriptor.addressRange.startAddress + 1;
|
||||
const auto dataBeginOffset = blockStartAddress - this->memorySegmentDescriptor.addressRange.startAddress;
|
||||
const auto dataEndOffset = blockEndAddress - this->memorySegmentDescriptor.addressRange.startAddress + 1;
|
||||
|
||||
writeBlocks.emplace_back(
|
||||
blockStartAddress,
|
||||
Targets::TargetMemoryBuffer(
|
||||
Targets::TargetMemoryBuffer{
|
||||
this->hexViewerDataA->begin() + dataBeginOffset,
|
||||
this->hexViewerDataA->begin() + dataEndOffset
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
blockStartAddress = address;
|
||||
@@ -551,15 +553,16 @@ namespace Widgets
|
||||
}
|
||||
|
||||
{
|
||||
const auto dataBeginOffset = blockStartAddress - this->memoryDescriptor.addressRange.startAddress;
|
||||
const auto dataEndOffset = blockEndAddress - this->memoryDescriptor.addressRange.startAddress + 1;
|
||||
// Last block
|
||||
const auto dataBeginOffset = blockStartAddress - this->memorySegmentDescriptor.addressRange.startAddress;
|
||||
const auto dataEndOffset = blockEndAddress - this->memorySegmentDescriptor.addressRange.startAddress + 1;
|
||||
|
||||
writeBlocks.emplace_back(
|
||||
blockStartAddress,
|
||||
Targets::TargetMemoryBuffer(
|
||||
Targets::TargetMemoryBuffer{
|
||||
this->hexViewerDataA->begin() + dataBeginOffset,
|
||||
this->hexViewerDataA->begin() + dataEndOffset
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -571,7 +574,7 @@ namespace Widgets
|
||||
writeBlock.data.begin(),
|
||||
writeBlock.data.end(),
|
||||
hexViewerDataB.begin()
|
||||
+ (writeBlock.startAddress - this->memoryDescriptor.addressRange.startAddress)
|
||||
+ (writeBlock.startAddress - this->memorySegmentDescriptor.addressRange.startAddress)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -580,10 +583,14 @@ namespace Widgets
|
||||
this->hexViewerWidgetB->updateValues();
|
||||
};
|
||||
|
||||
const auto writeMemoryTask = QSharedPointer<WriteTargetMemory>(
|
||||
new WriteTargetMemory(this->memoryDescriptor, std::move(writeBlocks)),
|
||||
const auto writeMemoryTask = QSharedPointer<WriteTargetMemory>{
|
||||
new WriteTargetMemory{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
std::move(writeBlocks)
|
||||
},
|
||||
&QObject::deleteLater
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(writeMemoryTask.get(), &WriteTargetMemory::targetMemoryWritten, this, after);
|
||||
|
||||
@@ -591,13 +598,11 @@ namespace Widgets
|
||||
InsightWorker::queueTask(writeMemoryTask);
|
||||
}
|
||||
|
||||
void SnapshotDiff::onTargetStateChanged(Targets::TargetState newState) {
|
||||
this->targetState = newState;
|
||||
|
||||
void SnapshotDiff::onTargetStateChanged() {
|
||||
this->changeListPane->setRestoreEnabled(
|
||||
this->comparingWithCurrent
|
||||
&& this->memoryDescriptor.access.writeableDuringDebugSession
|
||||
&& this->targetState == Targets::TargetState::STOPPED
|
||||
&& this->memorySegmentDescriptor.debugModeAccess.writeable
|
||||
&& this->targetState.executionState == Targets::TargetExecutionState::STOPPED
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TaskProgressIndicator/TaskProgressIndicator.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp"
|
||||
#include "DifferentialHexViewerWidget/DifferentialHexViewerWidget.hpp"
|
||||
@@ -32,8 +35,9 @@ namespace Widgets
|
||||
SnapshotDiff(
|
||||
MemorySnapshot& snapshotA,
|
||||
MemorySnapshot& snapshotB,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
Targets::TargetState currentTargetState,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
QWidget* parent = nullptr
|
||||
);
|
||||
|
||||
@@ -43,8 +47,9 @@ namespace Widgets
|
||||
std::vector<FocusedMemoryRegion> focusedRegionsB,
|
||||
std::vector<ExcludedMemoryRegion> excludedRegionsB,
|
||||
Targets::TargetStackPointer stackPointerB,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
Targets::TargetState currentTargetState,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
QWidget* parent = nullptr
|
||||
);
|
||||
|
||||
@@ -63,8 +68,9 @@ namespace Widgets
|
||||
private:
|
||||
SnapshotDiffSettings settings;
|
||||
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
QWidget* container = nullptr;
|
||||
|
||||
@@ -76,7 +82,7 @@ namespace Widgets
|
||||
QToolButton* viewChangeListButton = nullptr;
|
||||
|
||||
PanelWidget* leftPanel = nullptr;
|
||||
PanelState leftPanelState = PanelState(300, true);
|
||||
PanelState leftPanelState = {300, true};
|
||||
|
||||
PaneState changeListPaneState = PaneState(true, true, std::nullopt);
|
||||
ChangeListPane* changeListPane = nullptr;
|
||||
@@ -113,7 +119,7 @@ namespace Widgets
|
||||
QWidget* bottomBar = nullptr;
|
||||
QHBoxLayout* bottomBarLayout = nullptr;
|
||||
Label* memoryCapacityLabel = nullptr;
|
||||
Label* memoryTypeLabel = nullptr;
|
||||
Label* memorySegmentNameLabel = nullptr;
|
||||
Label* diffCountLabel = nullptr;
|
||||
|
||||
TaskProgressIndicator* taskProgressIndicator = nullptr;
|
||||
@@ -137,6 +143,6 @@ namespace Widgets
|
||||
bool confirmationPromptEnabled
|
||||
);
|
||||
|
||||
void onTargetStateChanged(Targets::TargetState newState);
|
||||
void onTargetStateChanged();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -142,6 +142,7 @@
|
||||
|
||||
#snapshot-diff #memory-capacity-label,
|
||||
#snapshot-diff #memory-type-label,
|
||||
#snapshot-diff #memory-segment-name-label,
|
||||
#snapshot-diff #diff-count-label {
|
||||
padding: 1px 5px;
|
||||
color: #8a8a8d;
|
||||
|
||||
@@ -454,7 +454,7 @@
|
||||
<widget class="QFrame" name="separator"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Label" name="memory-type-label">
|
||||
<widget class="Label" name="memory-segment-name-label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"/>
|
||||
</property>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/UiLoader.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.hpp"
|
||||
|
||||
#include "src/Insight/InsightSignals.hpp"
|
||||
#include "src/Insight/InsightWorker/Tasks/RetrieveMemorySnapshots.hpp"
|
||||
#include "src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.hpp"
|
||||
#include "src/Insight/InsightWorker/Tasks/DeleteMemorySnapshot.hpp"
|
||||
@@ -23,7 +22,10 @@ namespace Widgets
|
||||
using Exceptions::Exception;
|
||||
|
||||
SnapshotManager::SnapshotManager(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const bool& staleData,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
@@ -33,7 +35,10 @@ namespace Widgets
|
||||
PanelWidget* parent
|
||||
)
|
||||
: PaneWidget(state, parent)
|
||||
, memoryDescriptor(memoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, targetDescriptor(targetDescriptor)
|
||||
, targetState(targetState)
|
||||
, data(data)
|
||||
, staleData(staleData)
|
||||
, focusedMemoryRegions(focusedMemoryRegions)
|
||||
@@ -43,18 +48,18 @@ namespace Widgets
|
||||
this->setObjectName("snapshot-manager");
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
auto widgetUiFile = QFile(
|
||||
auto widgetUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/SnapshotManager/UiFiles/SnapshotManager.ui"
|
||||
+ "/SnapshotManager/UiFiles/SnapshotManager.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!widgetUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open SnapshotManager UI file");
|
||||
throw Exception{"Failed to open SnapshotManager UI file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&widgetUiFile, this);
|
||||
|
||||
this->container->setFixedSize(this->size());
|
||||
@@ -66,7 +71,7 @@ namespace Widgets
|
||||
|
||||
auto* containerLayout = this->container->findChild<QVBoxLayout*>();
|
||||
|
||||
this->snapshotListView = new ListView({}, this);
|
||||
this->snapshotListView = new ListView{{}, this};
|
||||
this->snapshotListView->viewport()->installEventFilter(parent);
|
||||
this->snapshotListView->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
|
||||
|
||||
@@ -75,12 +80,14 @@ namespace Widgets
|
||||
|
||||
containerLayout->addWidget(this->snapshotListView);
|
||||
|
||||
this->createSnapshotWindow = new CreateSnapshotWindow(
|
||||
this->memoryDescriptor.type,
|
||||
this->createSnapshotWindow = new CreateSnapshotWindow{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this->data,
|
||||
this->staleData,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
this->createSnapshotWindow,
|
||||
@@ -200,19 +207,14 @@ namespace Widgets
|
||||
}
|
||||
);
|
||||
|
||||
auto* insightSignals = InsightSignals::instance();
|
||||
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
&InsightSignals::targetStateUpdated,
|
||||
this,
|
||||
&SnapshotManager::onTargetStateChanged
|
||||
);
|
||||
|
||||
const auto retrieveSnapshotsTask = QSharedPointer<RetrieveMemorySnapshots>(
|
||||
new RetrieveMemorySnapshots(this->memoryDescriptor.type),
|
||||
const auto retrieveSnapshotsTask = QSharedPointer<RetrieveMemorySnapshots>{
|
||||
new RetrieveMemorySnapshots{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetDescriptor
|
||||
},
|
||||
&QObject::deleteLater
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
retrieveSnapshotsTask.get(),
|
||||
@@ -220,7 +222,7 @@ namespace Widgets
|
||||
this,
|
||||
[this] (std::vector<MemorySnapshot> snapshots) {
|
||||
for (auto& snapshot : snapshots) {
|
||||
if (!snapshot.isCompatible(this->memoryDescriptor)) {
|
||||
if (!snapshot.isCompatible(this->memorySegmentDescriptor)) {
|
||||
Logger::warning(
|
||||
"Ignoring snapshot " + snapshot.id.toStdString()
|
||||
+ " - snapshot incompatible with current memory descriptor"
|
||||
@@ -275,17 +277,18 @@ namespace Widgets
|
||||
bool captureFocusedRegions,
|
||||
bool captureDirectlyFromTarget
|
||||
) {
|
||||
const auto captureTask = QSharedPointer<CaptureMemorySnapshot>(
|
||||
new CaptureMemorySnapshot(
|
||||
const auto captureTask = QSharedPointer<CaptureMemorySnapshot>{
|
||||
new CaptureMemorySnapshot{
|
||||
std::move(name),
|
||||
std::move(description),
|
||||
this->memoryDescriptor.type,
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
captureFocusedRegions ? this->focusedMemoryRegions : std::vector<FocusedMemoryRegion>(),
|
||||
this->excludedMemoryRegions,
|
||||
captureDirectlyFromTarget ? std::nullopt : this->data
|
||||
),
|
||||
},
|
||||
&QObject::deleteLater
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
captureTask.get(),
|
||||
@@ -298,7 +301,6 @@ namespace Widgets
|
||||
);
|
||||
|
||||
emit this->insightWorkerTaskCreated(captureTask);
|
||||
|
||||
InsightWorker::queueTask(captureTask);
|
||||
}
|
||||
|
||||
@@ -306,7 +308,7 @@ namespace Widgets
|
||||
const auto snapshotIt = this->snapshotsById.insert(snapshotTmp.id, std::move(snapshotTmp));
|
||||
const auto& snapshot = *snapshotIt;
|
||||
|
||||
const auto snapshotItemIt = this->snapshotItemsById.insert(snapshot.id, new MemorySnapshotItem(snapshot));
|
||||
const auto snapshotItemIt = this->snapshotItemsById.insert(snapshot.id, new MemorySnapshotItem{snapshot});
|
||||
auto& snapshotItem = *snapshotItemIt;
|
||||
|
||||
this->snapshotListScene->addListItem(snapshotItem);
|
||||
@@ -337,7 +339,13 @@ namespace Widgets
|
||||
|
||||
snapshotViewerIt = this->snapshotViewersById.insert(
|
||||
snapshotId,
|
||||
new SnapshotViewer(snapshotIt.value(), this->memoryDescriptor, this)
|
||||
new SnapshotViewer{
|
||||
snapshotIt.value(),
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -360,13 +368,14 @@ namespace Widgets
|
||||
|
||||
snapshotDiffIt = this->snapshotDiffs.insert(
|
||||
diffKey,
|
||||
new SnapshotDiff(
|
||||
new SnapshotDiff{
|
||||
snapshotItA.value(),
|
||||
snapshotItB.value(),
|
||||
this->memoryDescriptor,
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -405,16 +414,17 @@ namespace Widgets
|
||||
|
||||
snapshotDiffIt = this->snapshotCurrentDiffsBySnapshotAId.insert(
|
||||
snapshotIdA,
|
||||
new SnapshotDiff(
|
||||
new SnapshotDiff{
|
||||
snapshotItA.value(),
|
||||
*(this->data),
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->stackPointer.value_or(0),
|
||||
this->memoryDescriptor,
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
auto* snapshotDiff = snapshotDiffIt.value();
|
||||
@@ -432,13 +442,13 @@ namespace Widgets
|
||||
const auto& snapshot = snapshotIt.value();
|
||||
|
||||
if (confirmationPromptEnabled) {
|
||||
auto* confirmationDialog = new ConfirmationDialog(
|
||||
auto* confirmationDialog = new ConfirmationDialog{
|
||||
"Delete snapshot " + snapshot.id,
|
||||
"This operation will permanently delete the selected snapshot.<br/><br/>Are you sure you want to proceed?",
|
||||
"Proceed",
|
||||
std::nullopt,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
confirmationDialog,
|
||||
@@ -453,10 +463,10 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
const auto deleteSnapshotTask = QSharedPointer<DeleteMemorySnapshot>(
|
||||
new DeleteMemorySnapshot(snapshot.id, snapshot.memoryType),
|
||||
const auto deleteSnapshotTask = QSharedPointer<DeleteMemorySnapshot>{
|
||||
new DeleteMemorySnapshot{snapshot.id},
|
||||
&QObject::deleteLater
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
deleteSnapshotTask.get(),
|
||||
@@ -508,15 +518,15 @@ namespace Widgets
|
||||
const auto& snapshot = snapshotIt.value();
|
||||
|
||||
if (confirmationPromptEnabled) {
|
||||
auto* confirmationDialog = new ConfirmationDialog(
|
||||
auto* confirmationDialog = new ConfirmationDialog{
|
||||
"Restore snapshot",
|
||||
"This operation will overwrite the entire address range of the target's "
|
||||
+ EnumToStringMappings::targetMemoryTypes.at(this->memoryDescriptor.type).toUpper()
|
||||
+ " with the contents of the selected snapshot.<br/><br/>Are you sure you want to proceed?",
|
||||
"This operation will overwrite the entire address range of the target's \""
|
||||
+ QString::fromStdString(this->memorySegmentDescriptor.name)
|
||||
+ "\" segment, with the contents of the selected snapshot.<br/><br/>Are you sure you want to proceed?",
|
||||
"Proceed",
|
||||
std::nullopt,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
confirmationDialog,
|
||||
@@ -535,52 +545,58 @@ namespace Widgets
|
||||
* We don't restore any excluded regions from the snapshot, so we split the write operation into blocks of
|
||||
* contiguous data, leaving out any address range that is part of an excluded region.
|
||||
*/
|
||||
auto writeBlocks = std::vector<WriteTargetMemory::Block>();
|
||||
auto writeBlocks = std::vector<WriteTargetMemory::Block>{};
|
||||
|
||||
auto sortedExcludedRegions = std::map<Targets::TargetMemoryAddress, const ExcludedMemoryRegion*>();
|
||||
auto sortedExcludedRegions = std::map<Targets::TargetMemoryAddress, const ExcludedMemoryRegion*>{};
|
||||
std::transform(
|
||||
snapshot.excludedRegions.begin(),
|
||||
snapshot.excludedRegions.end(),
|
||||
std::inserter(sortedExcludedRegions, sortedExcludedRegions.end()),
|
||||
[] (const ExcludedMemoryRegion& excludedMemoryRegion) {
|
||||
return std::pair(excludedMemoryRegion.addressRange.startAddress, &excludedMemoryRegion);
|
||||
return std::pair{excludedMemoryRegion.addressRange.startAddress, &excludedMemoryRegion};
|
||||
}
|
||||
);
|
||||
|
||||
auto blockStartAddress = this->memoryDescriptor.addressRange.startAddress;
|
||||
auto blockStartAddress = this->memorySegmentDescriptor.addressRange.startAddress;
|
||||
|
||||
for (const auto& [excludedRegionStartAddress, excludedRegion] : sortedExcludedRegions) {
|
||||
assert(excludedRegionStartAddress >= this->memoryDescriptor.addressRange.startAddress);
|
||||
assert(excludedRegion->addressRange.endAddress <= this->memoryDescriptor.addressRange.endAddress);
|
||||
assert(excludedRegionStartAddress >= this->memorySegmentDescriptor.addressRange.startAddress);
|
||||
assert(excludedRegion->addressRange.endAddress <= this->memorySegmentDescriptor.addressRange.endAddress);
|
||||
|
||||
const auto dataBeginOffset = blockStartAddress - this->memoryDescriptor.addressRange.startAddress;
|
||||
const auto dataEndOffset = excludedRegionStartAddress - this->memoryDescriptor.addressRange.startAddress;
|
||||
const auto dataBeginOffset = blockStartAddress - this->memorySegmentDescriptor.addressRange.startAddress;
|
||||
const auto dataEndOffset = excludedRegionStartAddress
|
||||
- this->memorySegmentDescriptor.addressRange.startAddress;
|
||||
|
||||
writeBlocks.emplace_back(
|
||||
blockStartAddress,
|
||||
Targets::TargetMemoryBuffer(
|
||||
Targets::TargetMemoryBuffer{
|
||||
snapshot.data.begin() + dataBeginOffset,
|
||||
snapshot.data.begin() + dataEndOffset
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
blockStartAddress = excludedRegion->addressRange.endAddress + 1;
|
||||
}
|
||||
|
||||
if (blockStartAddress < this->memoryDescriptor.addressRange.endAddress) {
|
||||
if (blockStartAddress < this->memorySegmentDescriptor.addressRange.endAddress) {
|
||||
writeBlocks.emplace_back(
|
||||
blockStartAddress,
|
||||
Targets::TargetMemoryBuffer(
|
||||
snapshot.data.begin() + (blockStartAddress - this->memoryDescriptor.addressRange.startAddress),
|
||||
Targets::TargetMemoryBuffer{
|
||||
snapshot.data.begin()
|
||||
+ (blockStartAddress - this->memorySegmentDescriptor.addressRange.startAddress),
|
||||
snapshot.data.end()
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const auto writeMemoryTask = QSharedPointer<WriteTargetMemory>(
|
||||
new WriteTargetMemory(this->memoryDescriptor, std::move(writeBlocks)),
|
||||
const auto writeMemoryTask = QSharedPointer<WriteTargetMemory>{
|
||||
new WriteTargetMemory{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
std::move(writeBlocks)
|
||||
},
|
||||
&QObject::deleteLater
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
writeMemoryTask.get(),
|
||||
@@ -606,7 +622,7 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
auto* menu = new QMenu(this);
|
||||
auto* menu = new QMenu{this};
|
||||
|
||||
menu->addAction(this->openSnapshotViewerAction);
|
||||
menu->addAction(this->deleteSnapshotAction);
|
||||
@@ -627,15 +643,11 @@ namespace Widgets
|
||||
&& this->data.has_value()
|
||||
);
|
||||
this->restoreSnapshotAction->setEnabled(
|
||||
this->memoryDescriptor.access.writeableDuringDebugSession
|
||||
this->memorySegmentDescriptor.debugModeAccess.writeable
|
||||
&& this->selectedSnapshotItems.size() == 1
|
||||
&& this->targetState == Targets::TargetState::STOPPED
|
||||
&& this->targetState.executionState == Targets::TargetExecutionState::STOPPED
|
||||
);
|
||||
|
||||
menu->exec(sourcePosition);
|
||||
}
|
||||
|
||||
void SnapshotManager::onTargetStateChanged(Targets::TargetState newState) {
|
||||
this->targetState = newState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,12 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/ListView/ListView.hpp"
|
||||
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
#include "src/Targets/TargetDescriptor.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp"
|
||||
@@ -35,7 +39,10 @@ namespace Widgets
|
||||
CreateSnapshotWindow* createSnapshotWindow = nullptr;
|
||||
|
||||
explicit SnapshotManager(
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data,
|
||||
const bool& staleData,
|
||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||
@@ -56,7 +63,11 @@ namespace Widgets
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
private:
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
const Targets::TargetDescriptor& targetDescriptor;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
const std::optional<Targets::TargetMemoryBuffer>& data;
|
||||
const bool& staleData;
|
||||
|
||||
@@ -64,8 +75,6 @@ namespace Widgets
|
||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||
const std::optional<Targets::TargetStackPointer>& stackPointer;
|
||||
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
QMap<QString, MemorySnapshot> snapshotsById;
|
||||
QMap<QString, MemorySnapshotItem*> snapshotItemsById;
|
||||
QMap<QString, SnapshotViewer*> snapshotViewersById;
|
||||
@@ -83,11 +92,11 @@ namespace Widgets
|
||||
|
||||
std::list<MemorySnapshotItem*> selectedSnapshotItems;
|
||||
|
||||
QAction* openSnapshotViewerAction = new QAction("Open", this);
|
||||
QAction* openSnapshotDiffAction = new QAction("Compare Selection", this);
|
||||
QAction* openSnapshotCurrentDiffAction = new QAction("Compare with Current", this);
|
||||
QAction* deleteSnapshotAction = new QAction("Delete", this);
|
||||
QAction* restoreSnapshotAction = new QAction("Restore", this);
|
||||
QAction* openSnapshotViewerAction = new QAction{"Open", this};
|
||||
QAction* openSnapshotDiffAction = new QAction{"Compare Selection", this};
|
||||
QAction* openSnapshotCurrentDiffAction = new QAction{"Compare with Current", this};
|
||||
QAction* deleteSnapshotAction = new QAction{"Delete", this};
|
||||
QAction* restoreSnapshotAction = new QAction{"Restore", this};
|
||||
|
||||
void createSnapshot(
|
||||
const QString& name,
|
||||
@@ -105,6 +114,5 @@ namespace Widgets
|
||||
void restoreSnapshot(const QString& snapshotId, bool confirmationPromptEnabled);
|
||||
void onSnapshotItemDoubleClick(MemorySnapshotItem* item);
|
||||
void onSnapshotItemContextMenu(ListItem* item, QPoint sourcePosition);
|
||||
void onTargetStateChanged(Targets::TargetState newState);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ namespace Widgets
|
||||
MemoryRegionItem::MemoryRegionItem(const MemoryRegion& memoryRegion)
|
||||
: memoryRegion(memoryRegion)
|
||||
{
|
||||
this->size = QSize(0, MemoryRegionItem::HEIGHT);
|
||||
this->size = QSize{0, MemoryRegionItem::HEIGHT};
|
||||
|
||||
this->nameText = memoryRegion.name;
|
||||
this->addressRangeText = "0x" + QString::number(this->memoryRegion.addressRange.startAddress, 16).toUpper()
|
||||
+ QString(" -> ") + "0x" + QString::number(this->memoryRegion.addressRange.endAddress, 16).toUpper();
|
||||
+ QString{" -> "} + "0x" + QString::number(this->memoryRegion.addressRange.endAddress, 16).toUpper();
|
||||
this->regionTypeText = this->memoryRegion.type == MemoryRegionType::EXCLUDED ? "Excluded" : "Focused";
|
||||
this->createdDateText = memoryRegion.createdDate.toString(
|
||||
memoryRegion.createdDate.date() == Services::DateTimeService::currentDate()
|
||||
@@ -23,16 +23,16 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void MemoryRegionItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
|
||||
static constexpr auto margins = QMargins(10, 5, 10, 0);
|
||||
static constexpr auto margins = QMargins{10, 5, 10, 0};
|
||||
|
||||
painter->setOpacity(0.7);
|
||||
static auto font = QFont("'Ubuntu', sans-serif");
|
||||
static auto font = QFont{"'Ubuntu', sans-serif"};
|
||||
font.setPixelSize(14);
|
||||
static auto secondaryFont = QFont("'Ubuntu', sans-serif");
|
||||
static auto secondaryFont = QFont{"'Ubuntu', sans-serif"};
|
||||
secondaryFont.setPixelSize(13);
|
||||
|
||||
static constexpr auto fontColor = QColor(0xAF, 0xB1, 0xB3);
|
||||
static constexpr auto secondaryFontColor = QColor(0x8A, 0x8A, 0x8D);
|
||||
static constexpr auto fontColor = QColor{0xAF, 0xB1, 0xB3};
|
||||
static constexpr auto secondaryFontColor = QColor{0x8A, 0x8A, 0x8D};
|
||||
|
||||
painter->setFont(font);
|
||||
painter->setPen(fontColor);
|
||||
@@ -54,46 +54,46 @@ namespace Widgets
|
||||
);
|
||||
|
||||
const auto nameTextSize = fontMetrics.size(Qt::TextSingleLine, nameText);
|
||||
const auto nameTextRect = QRect(
|
||||
const auto nameTextRect = QRect{
|
||||
margins.left(),
|
||||
margins.top(),
|
||||
nameTextSize.width(),
|
||||
nameTextSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->drawText(nameTextRect, Qt::AlignLeft, nameText);
|
||||
|
||||
painter->setFont(secondaryFont);
|
||||
painter->setPen(secondaryFontColor);
|
||||
|
||||
const auto addressRangeTextRect = QRect(
|
||||
const auto addressRangeTextRect = QRect{
|
||||
margins.left(),
|
||||
nameTextRect.bottom() + 5,
|
||||
addressRangeTextSize.width(),
|
||||
addressRangeTextSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->drawText(addressRangeTextRect, Qt::AlignLeft, this->addressRangeText);
|
||||
|
||||
const auto regionTypeTextRect = QRect(
|
||||
const auto regionTypeTextRect = QRect{
|
||||
this->size.width() - margins.right() - regionTypeTextSize.width(),
|
||||
margins.top(),
|
||||
regionTypeTextSize.width(),
|
||||
regionTypeTextSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->drawText(regionTypeTextRect, Qt::AlignRight, this->regionTypeText);
|
||||
|
||||
const auto createdDateTextRect = QRect(
|
||||
const auto createdDateTextRect = QRect{
|
||||
this->size.width() - margins.right() - createdDateTextSize.width(),
|
||||
nameTextRect.bottom() + 5,
|
||||
createdDateTextSize.width(),
|
||||
createdDateTextSize.height()
|
||||
);
|
||||
};
|
||||
|
||||
painter->drawText(createdDateTextRect, Qt::AlignRight, this->createdDateText);
|
||||
|
||||
static constexpr auto borderColor = QColor(0x41, 0x42, 0x3F);
|
||||
static constexpr auto borderColor = QColor{0x41, 0x42, 0x3F};
|
||||
painter->setPen(borderColor);
|
||||
painter->drawLine(0, this->size.height() - 1, this->size.width(), this->size.height() - 1);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ namespace Widgets
|
||||
MemoryRegionItem(const MemoryRegion& memoryRegion);
|
||||
|
||||
bool operator < (const ListItem& rhs) const override {
|
||||
const auto& rhsRegionItem = dynamic_cast<const MemoryRegionItem&>(rhs);
|
||||
return this->memoryRegion.createdDate < rhsRegionItem.memoryRegion.createdDate;
|
||||
return this->memoryRegion.createdDate < dynamic_cast<const MemoryRegionItem&>(rhs).memoryRegion.createdDate;
|
||||
}
|
||||
|
||||
void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) override;
|
||||
|
||||
@@ -29,38 +29,41 @@ namespace Widgets
|
||||
|
||||
SnapshotViewer::SnapshotViewer(
|
||||
MemorySnapshot& snapshot,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
QWidget* parent
|
||||
)
|
||||
: QWidget(parent)
|
||||
, snapshot(snapshot)
|
||||
, memoryDescriptor(memoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, hexViewerData(snapshot.data)
|
||||
{
|
||||
this->setWindowFlag(Qt::Window);
|
||||
this->setObjectName("snapshot-viewer");
|
||||
this->setWindowTitle(this->snapshot.name + " (" + this->snapshot.id + ")");
|
||||
|
||||
auto windowUiFile = QFile(
|
||||
auto windowUiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/SnapshotManager/SnapshotViewer/UiFiles/SnapshotViewer.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto stylesheetFile = QFile(
|
||||
auto stylesheetFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||
+ "/SnapshotManager/SnapshotViewer/Stylesheets/SnapshotViewer.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!windowUiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open SnapshotViewer UI file");
|
||||
throw Exception{"Failed to open SnapshotViewer UI file"};
|
||||
}
|
||||
|
||||
if (!stylesheetFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open SnapshotViewer stylesheet file");
|
||||
throw Exception{"Failed to open SnapshotViewer stylesheet file"};
|
||||
}
|
||||
|
||||
// Set ideal window size
|
||||
@@ -68,7 +71,7 @@ namespace Widgets
|
||||
this->setMinimumSize(700, 600);
|
||||
this->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->setStyleSheet(stylesheetFile.readAll());
|
||||
this->container = uiLoader.load(&windowUiFile, this);
|
||||
|
||||
@@ -97,7 +100,7 @@ namespace Widgets
|
||||
this->snapshot.focusedRegions.end(),
|
||||
std::back_inserter(this->memoryRegionItems),
|
||||
[] (const MemoryRegion& focusedRegion) {
|
||||
return new MemoryRegionItem(focusedRegion);
|
||||
return new MemoryRegionItem{focusedRegion};
|
||||
}
|
||||
);
|
||||
|
||||
@@ -106,40 +109,42 @@ namespace Widgets
|
||||
this->snapshot.excludedRegions.end(),
|
||||
std::back_inserter(this->memoryRegionItems),
|
||||
[] (const MemoryRegion& excludedRegion) {
|
||||
return new MemoryRegionItem(excludedRegion);
|
||||
return new MemoryRegionItem{excludedRegion};
|
||||
}
|
||||
);
|
||||
|
||||
this->memoryRegionListView = new ListView(
|
||||
ListScene::ListItemSetType(this->memoryRegionItems.begin(), this->memoryRegionItems.end()),
|
||||
this->memoryRegionListView = new ListView{
|
||||
ListItem::ListItemSetType{this->memoryRegionItems.begin(), this->memoryRegionItems.end()},
|
||||
this
|
||||
);
|
||||
};
|
||||
this->memoryRegionListView->setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded);
|
||||
|
||||
this->memoryRegionListScene = this->memoryRegionListView->listScene();
|
||||
this->memoryRegionListScene->margins = QMargins(0, 5, 0, 5);
|
||||
this->memoryRegionListScene->margins = QMargins{0, 5, 0, 5};
|
||||
this->memoryRegionListScene->setSelectionLimit(2);
|
||||
|
||||
noMemoryRegionsLabel->hide();
|
||||
memoryRegionsLayout->insertWidget(0, this->memoryRegionListView);
|
||||
}
|
||||
|
||||
this->restoreBytesAction = new ContextMenuAction(
|
||||
this->restoreBytesAction = new ContextMenuAction{
|
||||
"Restore Selection",
|
||||
[this] (const std::set<Targets::TargetMemoryAddress>&) {
|
||||
return this->memoryDescriptor.access.writeableDuringDebugSession;
|
||||
return this->memorySegmentDescriptor.debugModeAccess.writeable;
|
||||
},
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
this->hexViewerWidget = new HexViewerWidget(
|
||||
this->memoryDescriptor,
|
||||
this->hexViewerWidget = new HexViewerWidget{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
targetState,
|
||||
this->hexViewerData,
|
||||
this->hexViewerWidgetSettings,
|
||||
this->snapshot.focusedRegions,
|
||||
this->snapshot.excludedRegions,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
containerLayout->insertWidget(1, this->hexViewerWidget);
|
||||
|
||||
@@ -151,7 +156,9 @@ namespace Widgets
|
||||
auto* programCounterLabel = this->bottomBar->findChild<Label*>("program-counter-label");
|
||||
auto* dateLabel = this->bottomBar->findChild<Label*>("date-label");
|
||||
|
||||
memoryCapacityLabel->setText(QLocale(QLocale::English).toString(this->memoryDescriptor.size()) + " bytes");
|
||||
memoryCapacityLabel->setText(
|
||||
QLocale{QLocale::English}.toString(this->memorySegmentDescriptor.size()) + " bytes"
|
||||
);
|
||||
snapshotIdLabel->setText(this->snapshot.id);
|
||||
programCounterLabel->setText(
|
||||
"0x" + QString::number(this->snapshot.programCounter, 16).rightJustified(8, '0').toUpper()
|
||||
@@ -161,11 +168,9 @@ namespace Widgets
|
||||
this->nameInput->setText(this->snapshot.name);
|
||||
this->descriptionInput->setPlainText(this->snapshot.description);
|
||||
|
||||
this->taskProgressIndicator = new TaskProgressIndicator(this);
|
||||
this->taskProgressIndicator = new TaskProgressIndicator{this};
|
||||
this->bottomBarLayout->insertWidget(2, this->taskProgressIndicator);
|
||||
|
||||
auto* insightSignals = InsightSignals::instance();
|
||||
|
||||
QObject::connect(
|
||||
this->restoreBytesAction,
|
||||
&ContextMenuAction::invoked,
|
||||
@@ -187,7 +192,6 @@ namespace Widgets
|
||||
|
||||
void SnapshotViewer::resizeEvent(QResizeEvent* event) {
|
||||
this->container->setFixedSize(this->size());
|
||||
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
@@ -211,15 +215,15 @@ namespace Widgets
|
||||
}
|
||||
|
||||
if (confirmationPromptEnabled) {
|
||||
auto* confirmationDialog = new ConfirmationDialog(
|
||||
auto* confirmationDialog = new ConfirmationDialog{
|
||||
"Restore selected bytes",
|
||||
"This operation will write " + QString::number(addresses.size()) + " byte(s) to the target's "
|
||||
+ EnumToStringMappings::targetMemoryTypes.at(this->memoryDescriptor.type).toUpper()
|
||||
+ ".<br/><br/>Are you sure you want to proceed?",
|
||||
"This operation will write " + QString::number(addresses.size()) + " byte(s) to the target's \""
|
||||
+ QString::fromStdString(this->memorySegmentDescriptor.name)
|
||||
+ "\" segment.<br/><br/>Are you sure you want to proceed?",
|
||||
"Proceed",
|
||||
std::nullopt,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
confirmationDialog,
|
||||
@@ -234,23 +238,23 @@ namespace Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
auto writeBlocks = std::vector<WriteTargetMemory::Block>();
|
||||
auto writeBlocks = std::vector<WriteTargetMemory::Block>{};
|
||||
|
||||
Targets::TargetMemoryAddress blockStartAddress = *(addresses.begin());
|
||||
Targets::TargetMemoryAddress blockEndAddress = blockStartAddress;
|
||||
auto blockStartAddress = *(addresses.begin());
|
||||
auto blockEndAddress = blockStartAddress;
|
||||
|
||||
for (const auto& address : addresses) {
|
||||
if (address > (blockEndAddress + 1)) {
|
||||
// Commit the block
|
||||
const auto dataBeginOffset = blockStartAddress - this->memoryDescriptor.addressRange.startAddress;
|
||||
const auto dataEndOffset = blockEndAddress - this->memoryDescriptor.addressRange.startAddress + 1;
|
||||
const auto dataBeginOffset = blockStartAddress - this->memorySegmentDescriptor.addressRange.startAddress;
|
||||
const auto dataEndOffset = blockEndAddress - this->memorySegmentDescriptor.addressRange.startAddress + 1;
|
||||
|
||||
writeBlocks.emplace_back(
|
||||
blockStartAddress,
|
||||
Targets::TargetMemoryBuffer(
|
||||
Targets::TargetMemoryBuffer{
|
||||
this->snapshot.data.begin() + dataBeginOffset,
|
||||
this->snapshot.data.begin() + dataEndOffset
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
blockStartAddress = address;
|
||||
@@ -262,22 +266,22 @@ namespace Widgets
|
||||
}
|
||||
|
||||
{
|
||||
const auto dataBeginOffset = blockStartAddress - this->memoryDescriptor.addressRange.startAddress;
|
||||
const auto dataEndOffset = blockEndAddress - this->memoryDescriptor.addressRange.startAddress + 1;
|
||||
const auto dataBeginOffset = blockStartAddress - this->memorySegmentDescriptor.addressRange.startAddress;
|
||||
const auto dataEndOffset = blockEndAddress - this->memorySegmentDescriptor.addressRange.startAddress + 1;
|
||||
|
||||
writeBlocks.emplace_back(
|
||||
blockStartAddress,
|
||||
Targets::TargetMemoryBuffer(
|
||||
Targets::TargetMemoryBuffer{
|
||||
this->snapshot.data.begin() + dataBeginOffset,
|
||||
this->snapshot.data.begin() + dataEndOffset
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const auto writeMemoryTask = QSharedPointer<WriteTargetMemory>(
|
||||
new WriteTargetMemory(this->memoryDescriptor, std::move(writeBlocks)),
|
||||
const auto writeMemoryTask = QSharedPointer<WriteTargetMemory>{
|
||||
new WriteTargetMemory{this->addressSpaceDescriptor, this->memorySegmentDescriptor, std::move(writeBlocks)},
|
||||
&QObject::deleteLater
|
||||
);
|
||||
};
|
||||
|
||||
this->taskProgressIndicator->addTask(writeMemoryTask);
|
||||
InsightWorker::queueTask(writeMemoryTask);
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TaskProgressIndicator/TaskProgressIndicator.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp"
|
||||
@@ -28,7 +31,9 @@ namespace Widgets
|
||||
public:
|
||||
SnapshotViewer(
|
||||
MemorySnapshot& snapshot,
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
QWidget* parent = nullptr
|
||||
);
|
||||
|
||||
@@ -38,7 +43,8 @@ namespace Widgets
|
||||
|
||||
private:
|
||||
MemorySnapshot& snapshot;
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
|
||||
QWidget* container = nullptr;
|
||||
|
||||
@@ -52,7 +58,7 @@ namespace Widgets
|
||||
|
||||
std::optional<Targets::TargetMemoryBuffer> hexViewerData;
|
||||
HexViewerWidget* hexViewerWidget = nullptr;
|
||||
HexViewerWidgetSettings hexViewerWidgetSettings = HexViewerWidgetSettings();
|
||||
HexViewerWidgetSettings hexViewerWidgetSettings = {};
|
||||
|
||||
ContextMenuAction* restoreBytesAction = nullptr;
|
||||
|
||||
|
||||
@@ -20,50 +20,52 @@ namespace Widgets
|
||||
{
|
||||
using namespace Exceptions;
|
||||
|
||||
using Targets::TargetMemoryDescriptor;
|
||||
using Targets::TargetMemoryType;
|
||||
using Targets::TargetMemoryAddressRange;
|
||||
|
||||
TargetMemoryInspectionPane::TargetMemoryInspectionPane(
|
||||
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
TargetMemoryInspectionPaneSettings& settings,
|
||||
PaneState& paneState,
|
||||
PanelWidget* parent
|
||||
)
|
||||
: PaneWidget(paneState, parent)
|
||||
, targetMemoryDescriptor(targetMemoryDescriptor)
|
||||
, addressSpaceDescriptor(addressSpaceDescriptor)
|
||||
, memorySegmentDescriptor(memorySegmentDescriptor)
|
||||
, targetDescriptor(targetDescriptor)
|
||||
, targetState(targetState)
|
||||
, settings(settings)
|
||||
{
|
||||
this->setObjectName("target-memory-inspection-pane");
|
||||
|
||||
const auto memoryName = "Internal " + EnumToStringMappings::targetMemoryTypes.at(
|
||||
this->targetMemoryDescriptor.type
|
||||
).toUpper();
|
||||
const auto memoryName = QString::fromStdString(this->memorySegmentDescriptor.name);
|
||||
|
||||
this->setWindowTitle("Memory Inspection - " + memoryName);
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
auto uiFile = QFile(
|
||||
auto uiFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/UiFiles/TargetMemoryInspectionPane.ui"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
auto stylesheetFile = QFile(
|
||||
auto stylesheetFile = QFile{
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Stylesheets/TargetMemoryInspectionPane.qss"
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
if (!uiFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open MemoryInspectionPane UI file");
|
||||
throw Exception{"Failed to open MemoryInspectionPane UI file"};
|
||||
}
|
||||
|
||||
if (!stylesheetFile.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open MemoryInspectionPane stylesheet file");
|
||||
throw Exception{"Failed to open MemoryInspectionPane stylesheet file"};
|
||||
}
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
auto uiLoader = UiLoader{this};
|
||||
this->container = uiLoader.load(&uiFile, this);
|
||||
this->container->setStyleSheet(stylesheetFile.readAll());
|
||||
this->container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
@@ -94,35 +96,42 @@ namespace Widgets
|
||||
titleLabel->setText(memoryName);
|
||||
|
||||
auto* memoryCapacityLabel = this->container->findChild<Label*>("memory-capacity-label");
|
||||
memoryCapacityLabel->setText(QLocale(QLocale::English).toString(this->targetMemoryDescriptor.size()) + " bytes");
|
||||
memoryCapacityLabel->setText(
|
||||
QLocale{QLocale::English}.toString(this->memorySegmentDescriptor.size()) + " bytes"
|
||||
);
|
||||
|
||||
// Quick sanity check to ensure the validity of persisted settings.
|
||||
this->sanitiseSettings();
|
||||
|
||||
this->refreshButton->setDisabled(true);
|
||||
|
||||
this->hexViewerWidget = new HexViewerWidget(
|
||||
this->targetMemoryDescriptor,
|
||||
this->hexViewerWidget = new HexViewerWidget{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetState,
|
||||
this->data,
|
||||
this->settings.hexViewerWidgetSettings,
|
||||
this->settings.focusedMemoryRegions,
|
||||
this->settings.excludedMemoryRegions,
|
||||
this
|
||||
);
|
||||
};
|
||||
this->hexViewerWidget->setDisabled(true);
|
||||
|
||||
this->subContainerLayout->insertWidget(1, this->hexViewerWidget);
|
||||
|
||||
this->hexViewerWidget->init();
|
||||
|
||||
this->rightPanel = new PanelWidget(PanelWidgetType::RIGHT, this->settings.rightPanelState, this);
|
||||
this->rightPanel = new PanelWidget{PanelWidgetType::RIGHT, this->settings.rightPanelState, this};
|
||||
this->rightPanel->setObjectName("right-panel");
|
||||
this->rightPanel->setMinimumResize(200);
|
||||
this->rightPanel->setHandleSize(6);
|
||||
this->subContainerLayout->insertWidget(2, this->rightPanel);
|
||||
|
||||
this->snapshotManager = new SnapshotManager(
|
||||
this->targetMemoryDescriptor,
|
||||
this->snapshotManager = new SnapshotManager{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->targetDescriptor,
|
||||
this->targetState,
|
||||
this->data,
|
||||
this->staleData,
|
||||
this->settings.focusedMemoryRegions,
|
||||
@@ -130,13 +139,13 @@ namespace Widgets
|
||||
this->stackPointer,
|
||||
this->settings.snapshotManagerState,
|
||||
this->rightPanel
|
||||
);
|
||||
};
|
||||
this->rightPanel->layout()->addWidget(this->snapshotManager);
|
||||
|
||||
this->setRefreshOnTargetStopEnabled(this->settings.refreshOnTargetStop);
|
||||
this->setRefreshOnActivationEnabled(this->settings.refreshOnActivation);
|
||||
|
||||
this->taskProgressIndicator = new TaskProgressIndicator(this);
|
||||
this->taskProgressIndicator = new TaskProgressIndicator{this};
|
||||
this->bottomBarLayout->insertWidget(5, this->taskProgressIndicator);
|
||||
|
||||
QObject::connect(
|
||||
@@ -313,7 +322,7 @@ namespace Widgets
|
||||
this->refreshButton->setDisabled(true);
|
||||
this->refreshButton->startSpin();
|
||||
|
||||
auto excludedAddressRanges = std::set<Targets::TargetMemoryAddressRange>();
|
||||
auto excludedAddressRanges = std::set<Targets::TargetMemoryAddressRange>{};
|
||||
std::transform(
|
||||
this->settings.excludedMemoryRegions.begin(),
|
||||
this->settings.excludedMemoryRegions.end(),
|
||||
@@ -323,15 +332,16 @@ namespace Widgets
|
||||
}
|
||||
);
|
||||
|
||||
const auto readMemoryTask = QSharedPointer<ReadTargetMemory>(
|
||||
new ReadTargetMemory(
|
||||
this->targetMemoryDescriptor.type,
|
||||
this->targetMemoryDescriptor.addressRange.startAddress,
|
||||
this->targetMemoryDescriptor.size(),
|
||||
const auto readMemoryTask = QSharedPointer<ReadTargetMemory>{
|
||||
new ReadTargetMemory{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->memorySegmentDescriptor.addressRange.startAddress,
|
||||
this->memorySegmentDescriptor.size(),
|
||||
excludedAddressRanges
|
||||
),
|
||||
},
|
||||
&QObject::deleteLater
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
readMemoryTask.get(),
|
||||
@@ -341,11 +351,11 @@ namespace Widgets
|
||||
this->onMemoryRead(data);
|
||||
|
||||
// Refresh the stack pointer if this is RAM.
|
||||
if (this->targetMemoryDescriptor.type == Targets::TargetMemoryType::RAM) {
|
||||
const auto readStackPointerTask = QSharedPointer<ReadStackPointer>(
|
||||
new ReadStackPointer(),
|
||||
if (this->memorySegmentDescriptor.type == Targets::TargetMemorySegmentType::RAM) {
|
||||
const auto readStackPointerTask = QSharedPointer<ReadStackPointer>{
|
||||
new ReadStackPointer{},
|
||||
&QObject::deleteLater
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
readStackPointerTask.get(),
|
||||
@@ -366,7 +376,7 @@ namespace Widgets
|
||||
|
||||
this->refreshButton->stopSpin();
|
||||
|
||||
if (this->targetState == Targets::TargetState::STOPPED) {
|
||||
if (this->targetState.executionState == Targets::TargetExecutionState::STOPPED) {
|
||||
this->refreshButton->setDisabled(false);
|
||||
}
|
||||
}
|
||||
@@ -402,7 +412,7 @@ namespace Widgets
|
||||
);
|
||||
|
||||
// If we're refreshing RAM, the UI should only be updated once we've retrieved the current stack pointer.
|
||||
if (this->targetMemoryDescriptor.type != Targets::TargetMemoryType::RAM) {
|
||||
if (this->memorySegmentDescriptor.type != Targets::TargetMemorySegmentType::RAM) {
|
||||
QObject::connect(
|
||||
readMemoryTask.get(),
|
||||
&InsightWorkerTask::finished,
|
||||
@@ -410,7 +420,7 @@ namespace Widgets
|
||||
[this] {
|
||||
this->refreshButton->stopSpin();
|
||||
|
||||
if (this->targetState == Targets::TargetState::STOPPED) {
|
||||
if (this->targetState.executionState == Targets::TargetExecutionState::STOPPED) {
|
||||
this->refreshButton->setDisabled(false);
|
||||
}
|
||||
}
|
||||
@@ -433,7 +443,7 @@ namespace Widgets
|
||||
[this] {
|
||||
this->refreshButton->stopSpin();
|
||||
|
||||
if (this->targetState == Targets::TargetState::STOPPED) {
|
||||
if (this->targetState.executionState == Targets::TargetExecutionState::STOPPED) {
|
||||
this->refreshButton->setDisabled(false);
|
||||
}
|
||||
}
|
||||
@@ -462,7 +472,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void TargetMemoryInspectionPane::postActivate() {
|
||||
if (this->targetState == Targets::TargetState::STOPPED) {
|
||||
if (this->targetState.executionState == Targets::TargetExecutionState::STOPPED) {
|
||||
if (
|
||||
!this->activeRefreshTask.has_value()
|
||||
&& (this->settings.refreshOnActivation || !this->data.has_value())
|
||||
@@ -494,8 +504,8 @@ namespace Widgets
|
||||
|
||||
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>();
|
||||
auto processedExcludedMemoryRegions = std::vector<ExcludedMemoryRegion>();
|
||||
auto processedFocusedMemoryRegions = std::vector<FocusedMemoryRegion>{};
|
||||
auto processedExcludedMemoryRegions = std::vector<ExcludedMemoryRegion>{};
|
||||
|
||||
const auto regionIntersects = [
|
||||
&processedFocusedMemoryRegions,
|
||||
@@ -518,7 +528,7 @@ namespace Widgets
|
||||
|
||||
for (const auto& focusedRegion : this->settings.focusedMemoryRegions) {
|
||||
if (
|
||||
!this->targetMemoryDescriptor.addressRange.contains(focusedRegion.addressRange)
|
||||
!this->memorySegmentDescriptor.addressRange.contains(focusedRegion.addressRange)
|
||||
|| regionIntersects(focusedRegion)
|
||||
) {
|
||||
continue;
|
||||
@@ -529,7 +539,7 @@ namespace Widgets
|
||||
|
||||
for (const auto& excludedRegion : this->settings.excludedMemoryRegions) {
|
||||
if (
|
||||
!this->targetMemoryDescriptor.addressRange.contains(excludedRegion.addressRange)
|
||||
!this->memorySegmentDescriptor.addressRange.contains(excludedRegion.addressRange)
|
||||
|| regionIntersects(excludedRegion)
|
||||
) {
|
||||
continue;
|
||||
@@ -542,15 +552,17 @@ namespace Widgets
|
||||
this->settings.excludedMemoryRegions = std::move(processedExcludedMemoryRegions);
|
||||
}
|
||||
|
||||
void TargetMemoryInspectionPane::onTargetStateChanged(Targets::TargetState newState) {
|
||||
if (this->targetState == newState) {
|
||||
void TargetMemoryInspectionPane::onTargetStateChanged(
|
||||
Targets::TargetState newState,
|
||||
Targets::TargetState previousState
|
||||
) {
|
||||
if (newState.executionState == previousState.executionState) {
|
||||
return;
|
||||
}
|
||||
|
||||
using Targets::TargetState;
|
||||
this->targetState = newState;
|
||||
using Targets::TargetExecutionState;
|
||||
|
||||
if (newState == TargetState::STOPPED) {
|
||||
if (newState.executionState == TargetExecutionState::STOPPED) {
|
||||
if (this->state.activated && (this->settings.refreshOnTargetStop || !this->data.has_value())) {
|
||||
this->refreshMemoryValues([this] {
|
||||
this->hexViewerWidget->setDisabled(false);
|
||||
@@ -562,7 +574,7 @@ namespace Widgets
|
||||
}
|
||||
}
|
||||
|
||||
if (newState == TargetState::RUNNING) {
|
||||
if (newState.executionState == TargetExecutionState::RUNNING) {
|
||||
this->hexViewerWidget->setDisabled(true);
|
||||
this->refreshButton->setDisabled(true);
|
||||
|
||||
@@ -585,7 +597,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void TargetMemoryInspectionPane::onMemoryRead(const Targets::TargetMemoryBuffer& data) {
|
||||
assert(data.size() == this->targetMemoryDescriptor.size());
|
||||
assert(data.size() == this->memorySegmentDescriptor.size());
|
||||
|
||||
this->data = data;
|
||||
this->hexViewerWidget->updateValues();
|
||||
@@ -594,12 +606,13 @@ namespace Widgets
|
||||
|
||||
void TargetMemoryInspectionPane::openMemoryRegionManagerWindow() {
|
||||
if (this->memoryRegionManagerWindow == nullptr) {
|
||||
this->memoryRegionManagerWindow = new MemoryRegionManagerWindow(
|
||||
this->targetMemoryDescriptor,
|
||||
this->memoryRegionManagerWindow = new MemoryRegionManagerWindow{
|
||||
this->addressSpaceDescriptor,
|
||||
this->memorySegmentDescriptor,
|
||||
this->settings.focusedMemoryRegions,
|
||||
this->settings.excludedMemoryRegions,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
QObject::connect(
|
||||
this->memoryRegionManagerWindow,
|
||||
@@ -647,16 +660,18 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void TargetMemoryInspectionPane::onProgrammingModeDisabled() {
|
||||
const auto disabled = this->targetState != Targets::TargetState::STOPPED || !this->data.has_value();
|
||||
const auto disabled = this->targetState.executionState != Targets::TargetExecutionState::STOPPED
|
||||
|| !this->data.has_value();
|
||||
this->hexViewerWidget->setDisabled(disabled);
|
||||
this->refreshButton->setDisabled(disabled);
|
||||
}
|
||||
|
||||
void TargetMemoryInspectionPane::onTargetMemoryWritten(
|
||||
TargetMemoryType memoryType,
|
||||
TargetMemoryAddressRange
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
Targets::TargetMemoryAddressRange addressRange
|
||||
) {
|
||||
if (memoryType == this->targetMemoryDescriptor.type && this->data.has_value()) {
|
||||
if (memorySegmentDescriptor == this->memorySegmentDescriptor && this->data.has_value()) {
|
||||
this->setStaleData(true);
|
||||
this->snapshotManager->createSnapshotWindow->refreshForm();
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/PaneWidget.hpp"
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
||||
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/PanelWidget.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
||||
@@ -36,7 +38,10 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
TargetMemoryInspectionPane(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
const Targets::TargetDescriptor& targetDescriptor,
|
||||
const Targets::TargetState& targetState,
|
||||
TargetMemoryInspectionPaneSettings& settings,
|
||||
PaneState& paneState,
|
||||
PanelWidget* parent
|
||||
@@ -54,7 +59,10 @@ namespace Widgets
|
||||
void postDetach();
|
||||
|
||||
private:
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor;
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor;
|
||||
const Targets::TargetDescriptor& targetDescriptor;
|
||||
const Targets::TargetState& targetState;
|
||||
|
||||
TargetMemoryInspectionPaneSettings& settings;
|
||||
|
||||
@@ -86,14 +94,12 @@ namespace Widgets
|
||||
TaskProgressIndicator* taskProgressIndicator = nullptr;
|
||||
QWidget* staleDataLabelContainer = nullptr;
|
||||
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
MemoryRegionManagerWindow* memoryRegionManagerWindow = nullptr;
|
||||
|
||||
bool staleData = false;
|
||||
|
||||
void sanitiseSettings();
|
||||
void onTargetStateChanged(Targets::TargetState newState);
|
||||
void onTargetStateChanged(Targets::TargetState newState, Targets::TargetState previousState);
|
||||
void setRefreshOnTargetStopEnabled(bool enabled);
|
||||
void setRefreshOnActivationEnabled(bool enabled);
|
||||
void onMemoryRead(const Targets::TargetMemoryBuffer& data);
|
||||
@@ -104,7 +110,8 @@ namespace Widgets
|
||||
void onProgrammingModeEnabled();
|
||||
void onProgrammingModeDisabled();
|
||||
void onTargetMemoryWritten(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
||||
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
||||
Targets::TargetMemoryAddressRange addressRange
|
||||
);
|
||||
void onSubtaskCreated(const QSharedPointer<InsightWorkerTask>& task);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
#include "FocusedMemoryRegion.hpp"
|
||||
@@ -14,6 +15,8 @@ namespace Widgets
|
||||
{
|
||||
struct TargetMemoryInspectionPaneSettings
|
||||
{
|
||||
QString addressSpaceKey;
|
||||
QString memorySegmentKey;
|
||||
bool refreshOnTargetStop = false;
|
||||
bool refreshOnActivation = false;
|
||||
|
||||
@@ -22,7 +25,12 @@ namespace Widgets
|
||||
std::vector<FocusedMemoryRegion> focusedMemoryRegions;
|
||||
std::vector<ExcludedMemoryRegion> excludedMemoryRegions;
|
||||
|
||||
PanelState rightPanelState = PanelState(300, true);
|
||||
PaneState snapshotManagerState = PaneState(true, true, std::nullopt);
|
||||
PanelState rightPanelState = {300, true};
|
||||
PaneState snapshotManagerState = {true, true, std::nullopt};
|
||||
|
||||
TargetMemoryInspectionPaneSettings(const QString& addressSpaceKey, const QString& memorySegmentKey)
|
||||
: addressSpaceKey(addressSpaceKey)
|
||||
, memorySegmentKey(memorySegmentKey)
|
||||
{}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#include "ToolButton.hpp"
|
||||
|
||||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
|
||||
#include "src/Services/PathService.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
ToolButton::ToolButton(QString&& label, QWidget* parent)
|
||||
: QToolButton(parent)
|
||||
, layout(new QHBoxLayout{this})
|
||||
, icon(new SvgWidget{this})
|
||||
, label(new Label{label, this})
|
||||
{
|
||||
this->setCheckable(true);
|
||||
this->setToolTip(label);
|
||||
this->setLayout(this->layout);
|
||||
|
||||
this->icon->setSvgFilePath(
|
||||
QString::fromStdString(Services::PathService::compiledResourcesPath()
|
||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/Images/memory-inspection-icon.svg"
|
||||
)
|
||||
);
|
||||
this->icon->setContainerHeight(22);
|
||||
this->icon->setContainerWidth(14);
|
||||
|
||||
this->layout->addWidget(this->icon);
|
||||
this->layout->addWidget(this->label);
|
||||
|
||||
this->layout->setContentsMargins(10, 0, 10, 0);
|
||||
this->layout->setSpacing(8);
|
||||
|
||||
this->label->setContentsMargins(0, 0, 0, 0);
|
||||
this->icon->setContentsMargins(0, 1, 0, 0);
|
||||
|
||||
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
}
|
||||
|
||||
QSize ToolButton::minimumSizeHint() const {
|
||||
return this->layout->minimumSize();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <QToolButton>
|
||||
#include <QString>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgWidget.hpp"
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/Label.hpp"
|
||||
|
||||
namespace Widgets
|
||||
{
|
||||
class ToolButton: public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ToolButton(QString&& label, QWidget* parent);
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
private:
|
||||
QHBoxLayout* layout;
|
||||
SvgWidget* icon;
|
||||
Label* label;
|
||||
};
|
||||
}
|
||||
@@ -11,7 +11,12 @@ namespace Widgets
|
||||
std::bitset<std::numeric_limits<unsigned char>::digits>::reference bit,
|
||||
bool readOnly,
|
||||
QWidget* parent
|
||||
): ClickableWidget(parent), bitIndex(bitIndex), bit(bit), readOnly(readOnly) {
|
||||
)
|
||||
: ClickableWidget(parent)
|
||||
, bitIndex(bitIndex)
|
||||
, bit(bit)
|
||||
, readOnly(readOnly)
|
||||
{
|
||||
this->setFixedSize(BitBodyWidget::WIDTH, BitBodyWidget::HEIGHT);
|
||||
this->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
@@ -50,7 +55,7 @@ namespace Widgets
|
||||
}
|
||||
|
||||
void BitBodyWidget::paintEvent(QPaintEvent* event) {
|
||||
auto painter = QPainter(this);
|
||||
auto painter = QPainter{this};
|
||||
this->drawWidget(painter);
|
||||
}
|
||||
|
||||
@@ -60,7 +65,7 @@ namespace Widgets
|
||||
true
|
||||
);
|
||||
|
||||
auto bodyColor = QColor(this->bit == true ? "#7B5E38" : "#908D85");
|
||||
auto bodyColor = QColor{this->bit ? "#7B5E38" : "#908D85"};
|
||||
|
||||
if (!this->isEnabled()) {
|
||||
bodyColor.setAlpha(100);
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Widgets
|
||||
|
||||
public:
|
||||
static constexpr int WIDTH = 19;
|
||||
static constexpr int HEIGHT = 28;
|
||||
static constexpr int HEIGHT = 29;
|
||||
|
||||
BitBodyWidget(
|
||||
int bitIndex,
|
||||
|
||||
@@ -14,22 +14,28 @@ namespace Widgets
|
||||
std::bitset<std::numeric_limits<unsigned char>::digits>& bitset,
|
||||
bool readOnly,
|
||||
QWidget* parent
|
||||
): QWidget(parent), bitIndex(bitIndex), bitNumber(bitNumber), bitset(bitset), readOnly(readOnly) {
|
||||
)
|
||||
: QWidget(parent)
|
||||
, bitIndex(bitIndex)
|
||||
, bitNumber(bitNumber)
|
||||
, bitset(bitset)
|
||||
, readOnly(readOnly)
|
||||
{
|
||||
this->setFixedSize(BitWidget::WIDTH, BitWidget::HEIGHT);
|
||||
|
||||
auto* layout = new QVBoxLayout(this);
|
||||
auto* layout = new QVBoxLayout{this};
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignmentFlag::AlignTop);
|
||||
|
||||
this->body = new BitBodyWidget(
|
||||
this->body = new BitBodyWidget{
|
||||
this->bitIndex,
|
||||
this->bitset[static_cast<size_t>(this->bitIndex)],
|
||||
this->readOnly,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
this->bitNumberLabel = new Label(QString::number(this->bitNumber), this);
|
||||
this->bitNumberLabel = new Label{QString::number(this->bitNumber), this};
|
||||
this->bitNumberLabel->setObjectName("register-bit-number-label");
|
||||
this->bitNumberLabel->setFixedHeight(BitWidget::LABEL_HEIGHT);
|
||||
this->bitNumberLabel->setAlignment(Qt::AlignmentFlag::AlignCenter);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Widgets
|
||||
static constexpr int WIDTH = BitBodyWidget::WIDTH;
|
||||
static constexpr int HEIGHT = BitBodyWidget::HEIGHT + BitWidget::LABEL_HEIGHT
|
||||
+ BitWidget::VERTICAL_SPACING;
|
||||
static constexpr int SPACING = 5;
|
||||
static constexpr int SPACING = 3;
|
||||
|
||||
BitWidget(
|
||||
int bitIndex,
|
||||
|
||||
@@ -11,9 +11,13 @@
|
||||
namespace Widgets
|
||||
{
|
||||
BitsetWidget::BitsetWidget(int byteNumber, unsigned char& byte, bool readOnly, QWidget* parent)
|
||||
: QWidget(parent), byteNumber(byteNumber), byte(byte), readOnly(readOnly) {
|
||||
: QWidget(parent)
|
||||
, byteNumber(byteNumber)
|
||||
, byte(byte)
|
||||
, readOnly(readOnly)
|
||||
{
|
||||
this->setObjectName("bitset-widget");
|
||||
auto* bitLayout = new QHBoxLayout(this);
|
||||
auto* bitLayout = new QHBoxLayout{this};
|
||||
bitLayout->setSpacing(BitWidget::SPACING);
|
||||
bitLayout->setContentsMargins(0, 0, 0, 0);
|
||||
this->setContentsMargins(0, 0, 0, 0);
|
||||
@@ -23,13 +27,13 @@ namespace Widgets
|
||||
);
|
||||
|
||||
for (int bitIndex = (std::numeric_limits<unsigned char>::digits - 1); bitIndex >= 0; bitIndex--) {
|
||||
auto* bitWidget = new BitWidget(
|
||||
auto* bitWidget = new BitWidget{
|
||||
bitIndex,
|
||||
(this->byteNumber * 8) + bitIndex,
|
||||
this->bitset,
|
||||
this->readOnly,
|
||||
this
|
||||
);
|
||||
};
|
||||
|
||||
bitLayout->addWidget(bitWidget, 0, Qt::AlignmentFlag::AlignHCenter | Qt::AlignmentFlag::AlignTop);
|
||||
QObject::connect(
|
||||
@@ -52,56 +56,64 @@ namespace Widgets
|
||||
|
||||
void BitsetWidget::paintEvent(QPaintEvent* event) {
|
||||
QWidget::paintEvent(event);
|
||||
auto painter = QPainter(this);
|
||||
auto painter = QPainter{this};
|
||||
this->drawWidget(painter);
|
||||
}
|
||||
|
||||
void BitsetWidget::drawWidget(QPainter& painter) {
|
||||
auto byteHex = "0x" + QString::number(this->byte, 16).toUpper();
|
||||
|
||||
painter.setPen(QColor("#474747"));
|
||||
painter.setPen(QColor{"#474747"});
|
||||
constexpr int labelHeight = 11;
|
||||
int containerWidth = this->width();
|
||||
constexpr int charWidth = 6;
|
||||
auto labelWidth = static_cast<int>(charWidth * byteHex.size()) + 13;
|
||||
auto width = containerWidth - BitWidget::WIDTH;
|
||||
|
||||
painter.drawLine(QLine(
|
||||
BitWidget::WIDTH / 2,
|
||||
BitWidget::HEIGHT,
|
||||
BitWidget::WIDTH / 2,
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT
|
||||
));
|
||||
painter.drawLine(
|
||||
QLine{
|
||||
BitWidget::WIDTH / 2,
|
||||
BitWidget::HEIGHT,
|
||||
BitWidget::WIDTH / 2,
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT
|
||||
}
|
||||
);
|
||||
|
||||
painter.drawLine(QLine(
|
||||
containerWidth - (BitWidget::WIDTH / 2) - 1,
|
||||
BitWidget::HEIGHT,
|
||||
containerWidth - (BitWidget::WIDTH / 2) - 1,
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT
|
||||
));
|
||||
painter.drawLine(
|
||||
QLine{
|
||||
containerWidth - (BitWidget::WIDTH / 2) - 1,
|
||||
BitWidget::HEIGHT,
|
||||
containerWidth - (BitWidget::WIDTH / 2) - 1,
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT
|
||||
}
|
||||
);
|
||||
|
||||
painter.drawLine(QLine(
|
||||
BitWidget::WIDTH / 2,
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT,
|
||||
static_cast<int>((BitWidget::WIDTH / 2) + width),
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT
|
||||
));
|
||||
painter.drawLine(
|
||||
QLine{
|
||||
BitWidget::WIDTH / 2,
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT,
|
||||
static_cast<int>((BitWidget::WIDTH / 2) + width),
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT
|
||||
}
|
||||
);
|
||||
|
||||
painter.drawLine(QLine(
|
||||
static_cast<int>((BitWidget::WIDTH / 2) + (width / 2)),
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT,
|
||||
static_cast<int>((BitWidget::WIDTH / 2) + (width / 2)),
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT + 4
|
||||
));
|
||||
painter.drawLine(
|
||||
QLine{
|
||||
static_cast<int>((BitWidget::WIDTH / 2) + (width / 2)),
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT,
|
||||
static_cast<int>((BitWidget::WIDTH / 2) + (width / 2)),
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT + 4
|
||||
}
|
||||
);
|
||||
|
||||
painter.setPen(QColor("#8a8a8d"));
|
||||
painter.setPen(QColor{"#8a8a8d"});
|
||||
painter.drawText(
|
||||
QRect(
|
||||
QRect{
|
||||
static_cast<int>((BitWidget::WIDTH / 2) + (width / 2) - (labelWidth / 2)),
|
||||
BitWidget::HEIGHT + BitsetWidget::VALUE_GRAPHIC_HEIGHT + 7,
|
||||
labelWidth,
|
||||
labelHeight
|
||||
),
|
||||
},
|
||||
Qt::AlignCenter,
|
||||
byteHex
|
||||
);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user