From 051b7e1e8e3525e318641b63080b64faf883ef5a Mon Sep 17 00:00:00 2001 From: Nav Date: Sat, 22 Jan 2022 16:14:03 +0000 Subject: [PATCH] Made Insight settings object mutable via Insight --- src/Insight/Insight.hpp | 7 +-- .../InsightWindow/InsightWindow.cpp | 52 ++++++++++++++----- .../InsightWindow/InsightWindow.hpp | 8 ++- .../TargetMemoryInspectionPane.hpp | 4 +- 4 files changed, 52 insertions(+), 19 deletions(-) diff --git a/src/Insight/Insight.hpp b/src/Insight/Insight.hpp index be51974b..2fd67b8a 100644 --- a/src/Insight/Insight.hpp +++ b/src/Insight/Insight.hpp @@ -43,7 +43,7 @@ namespace Bloom const ProjectConfig& projectConfig, const EnvironmentConfig& environmentConfig, const InsightConfig& insightConfig, - const InsightProjectSettings& insightProjectSettings + InsightProjectSettings& insightProjectSettings ): eventManager(eventManager), projectConfig(projectConfig), @@ -74,7 +74,7 @@ namespace Bloom EnvironmentConfig environmentConfig; InsightConfig insightConfig; - InsightProjectSettings insightProjectSettings; + InsightProjectSettings& insightProjectSettings; EventManager& eventManager; EventListenerPointer eventListener = std::make_shared("InsightEventListener"); @@ -84,7 +84,8 @@ namespace Bloom InsightWindow* mainWindow = new InsightWindow( *(this->insightWorker), this->environmentConfig, - this->insightConfig + this->insightConfig, + this->insightProjectSettings ); TargetControllerConsole targetControllerConsole = TargetControllerConsole( diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index ed7a531f..2f2064a1 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -30,17 +30,30 @@ using Bloom::Targets::TargetMemoryType; InsightWindow::InsightWindow( InsightWorker& insightWorker, const EnvironmentConfig& environmentConfig, - const InsightConfig& insightConfig + const InsightConfig& insightConfig, + InsightProjectSettings& insightProjectSettings ): QMainWindow(nullptr), insightWorker(insightWorker), environmentConfig(environmentConfig), targetConfig(environmentConfig.targetConfig), - insightConfig(insightConfig) + insightConfig(insightConfig), + insightProjectSettings(insightProjectSettings) { this->setObjectName("main-window"); this->setWindowTitle("Bloom Insight"); - this->setMinimumSize(1000, 500); + + const auto defaultMinimumSize = QSize(1000, 500); + + if (this->insightProjectSettings.mainWindowSize.has_value()) { + this->setMinimumSize( + std::max(this->insightProjectSettings.mainWindowSize->width(), defaultMinimumSize.width()), + std::max(this->insightProjectSettings.mainWindowSize->height(), defaultMinimumSize.height()) + ); + + } else { + this->setMinimumSize(defaultMinimumSize); + } auto mainWindowUiFile = QFile( QString::fromStdString(Paths::compiledResourcesPath() @@ -220,6 +233,12 @@ void InsightWindow::showEvent(QShowEvent* event) { this->adjustMinimumSize(); } +void InsightWindow::closeEvent(QCloseEvent* event) { + this->insightProjectSettings.mainWindowSize = this->size(); + + return QMainWindow::closeEvent(event); +} + bool InsightWindow::isVariantSupported(const TargetVariant& variant) { const auto pinCount = variant.pinDescriptorsByNumber.size(); @@ -466,18 +485,25 @@ void InsightWindow::createPanes() { this->targetRegistersButton->setChecked(false); this->targetRegistersButton->setDisabled(false); + auto& memoryInspectionPaneSettingsByMemoryType = + this->insightProjectSettings.memoryInspectionPaneSettingsByMemoryType; + // Target memory inspection panes auto* bottomPanelLayout = this->bottomPanel->layout(); if (this->targetDescriptor.memoryDescriptorsByType.contains(TargetMemoryType::RAM)) { auto& ramDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::RAM); + + if (!memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::RAM)) { + memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM] = TargetMemoryInspectionPaneSettings(); + } + this->ramInspectionPane = new TargetMemoryInspectionPane( ramDescriptor, - this->memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::RAM) ? - this->memoryInspectionPaneSettingsByMemoryType.at(TargetMemoryType::RAM) - : TargetMemoryInspectionPaneSettings(), + memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM], this->insightWorker, this->bottomPanel ); + bottomPanelLayout->addWidget(this->ramInspectionPane); this->ramInspectionPane->deactivate(); this->ramInspectionButton->setChecked(false); @@ -486,14 +512,18 @@ void InsightWindow::createPanes() { if (this->targetDescriptor.memoryDescriptorsByType.contains(TargetMemoryType::EEPROM)) { auto& eepromDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::EEPROM); + + if (!memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::EEPROM)) { + memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM] = TargetMemoryInspectionPaneSettings(); + } + this->eepromInspectionPane = new TargetMemoryInspectionPane( eepromDescriptor, - this->memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::EEPROM) ? - this->memoryInspectionPaneSettingsByMemoryType.at(TargetMemoryType::EEPROM) - : TargetMemoryInspectionPaneSettings(), + memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM], this->insightWorker, this->bottomPanel ); + bottomPanelLayout->addWidget(this->eepromInspectionPane); this->eepromInspectionPane->deactivate(); this->eepromInspectionButton->setChecked(false); @@ -515,8 +545,6 @@ void InsightWindow::destroyPanes() { * hex viewer settings, etc), in order to persist them through debug sessions. */ if (this->ramInspectionPane != nullptr) { - this->memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM] = this->ramInspectionPane->settings; - this->ramInspectionPane->deactivate(); this->ramInspectionPane->deleteLater(); this->ramInspectionPane = nullptr; @@ -527,8 +555,6 @@ void InsightWindow::destroyPanes() { } if (this->eepromInspectionPane != nullptr) { - this->memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM] = this->eepromInspectionPane->settings; - this->eepromInspectionPane->deactivate(); this->eepromInspectionPane->deleteLater(); this->eepromInspectionPane = nullptr; diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp index 80430ca4..4573861d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp @@ -3,9 +3,11 @@ #include #include #include +#include #include #include +#include "src/ProjectSettings.hpp" #include "src/ProjectConfig.hpp" #include "src/Insight/InsightWorker/InsightWorker.hpp" #include "src/Targets/TargetState.hpp" @@ -33,7 +35,8 @@ namespace Bloom InsightWindow( InsightWorker& insightWorker, const EnvironmentConfig& environmentConfig, - const InsightConfig& insightConfig + const InsightConfig& insightConfig, + InsightProjectSettings& insightProjectSettings ); void setEnvironmentConfig(const EnvironmentConfig& environmentConfig) { @@ -50,8 +53,11 @@ namespace Bloom protected: void resizeEvent(QResizeEvent* event) override; void showEvent(QShowEvent* event) override; + void closeEvent(QCloseEvent* event) override; private: + InsightProjectSettings& insightProjectSettings; + InsightConfig insightConfig; EnvironmentConfig environmentConfig; TargetConfig targetConfig; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp index 6b8bd194..a301c1d1 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp @@ -24,12 +24,12 @@ namespace Bloom::Widgets Q_OBJECT public: - TargetMemoryInspectionPaneSettings settings; + TargetMemoryInspectionPaneSettings& settings; bool activated = false; TargetMemoryInspectionPane( const Targets::TargetMemoryDescriptor& targetMemoryDescriptor, - const TargetMemoryInspectionPaneSettings& settings, + TargetMemoryInspectionPaneSettings& settings, InsightWorker& insightWorker, PanelWidget* parent );