From 7e992f781ebf061e936cddc0a4a2a59dcf7289e4 Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 6 Feb 2022 20:26:31 +0000 Subject: [PATCH] Enforced absolute minimum Insight window size --- .../InsightWindow/InsightWindow.cpp | 87 +++++++++++++++++-- 1 file changed, 81 insertions(+), 6 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index cda8d049..1ba55f87 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -235,7 +235,7 @@ namespace Bloom } void InsightWindow::closeEvent(QCloseEvent* event) { - this->insightProjectSettings.mainWindowSize = this->size(); + this->recordInsightSettings(); return QMainWindow::closeEvent(event); } @@ -314,6 +314,37 @@ namespace Bloom this->createPanes(); + const auto& lastLeftPanelState = this->insightProjectSettings.previousLeftPanelState; + const auto& lastBottomPanelState = this->insightProjectSettings.previousBottomPanelState; + + if (lastLeftPanelState.has_value() && this->leftPanel != nullptr) { + this->leftPanel->setSize(lastLeftPanelState->size); + + if (lastLeftPanelState->open && this->targetRegistersSidePane != nullptr + && this->insightProjectSettings.previousRegistersPaneState.has_value() + && this->insightProjectSettings.previousRegistersPaneState->activated + ) { + this->toggleTargetRegistersPane(); + } + } + + if (lastBottomPanelState.has_value()) { + this->bottomPanel->setSize(lastBottomPanelState->size); + + if (this->ramInspectionPane != nullptr + && this->insightProjectSettings.previousRamInspectionPaneState.has_value() + && this->insightProjectSettings.previousRamInspectionPaneState->activated + ) { + this->toggleRamInspectionPane(); + + } else if (this->eepromInspectionPane != nullptr + && this->insightProjectSettings.previousEepromInspectionPaneState.has_value() + && this->insightProjectSettings.previousEepromInspectionPaneState->activated + ) { + this->toggleEepromInspectionPane(); + } + } + this->setUiDisabled(this->targetState != TargetState::STOPPED); this->activated = true; } @@ -567,6 +598,8 @@ namespace Bloom } void InsightWindow::deactivate() { + this->recordInsightSettings(); + if (this->selectedVariant != nullptr) { this->previouslySelectedVariant = *(this->selectedVariant); this->selectedVariant = nullptr; @@ -602,7 +635,11 @@ namespace Bloom void InsightWindow::adjustPanels() { const auto targetPackageWidgetSize = (this->targetPackageWidget != nullptr) ? this->targetPackageWidget->size() : QSize(); - const auto containerSize = this->container->size(); + const auto containerSize = this->size(); + + if (!this->isVisible()) { + return; + } /* * The purpose of the -20 is to ensure there is some padding between the panel borders and the @@ -622,24 +659,32 @@ namespace Bloom this->bottomPanel->setMaximumResize( std::max( this->bottomPanel->getMinimumResize(), - (containerSize.height() / 2) - this->bottomMenuBar->height() + (containerSize.height() / 2) - this->mainMenuBar->height() - this->bottomMenuBar->height() - 20 ) ); } void InsightWindow::adjustMinimumSize() { - auto minSize = QSize(800, 500); + static const auto absoluteMinimum = QSize(900, 400); + auto minSize = QSize(); if (this->targetPackageWidget != nullptr) { - minSize.setWidth(this->targetPackageWidget->width() + 700); + minSize.setWidth(this->targetPackageWidget->width() + 250); minSize.setHeight(this->targetPackageWidget->height() + 150); } + if (this->leftPanel->isVisible()) { + minSize.setWidth(minSize.width() + this->leftPanel->getMinimumResize()); + } + if (this->bottomPanel->isVisible()) { minSize.setHeight(minSize.height() + this->bottomPanel->getMinimumResize()); } - this->setMinimumSize(minSize); + this->setMinimumSize( + std::max(minSize.width(), absoluteMinimum.width()), + std::max(minSize.height(), absoluteMinimum.height()) + ); } void InsightWindow::onTargetControllerSuspended() { @@ -763,6 +808,8 @@ namespace Bloom this->targetRegistersButton->setChecked(true); this->leftPanel->setVisible(true); } + + this->adjustMinimumSize(); } void InsightWindow::toggleRamInspectionPane() { @@ -802,4 +849,32 @@ namespace Bloom this->adjustMinimumSize(); } + + void InsightWindow::recordInsightSettings() { + auto& projectSettings = this->insightProjectSettings; + + projectSettings.mainWindowSize = this->size(); + + if (this->activated) { + if (this->leftPanel != nullptr) { + projectSettings.previousLeftPanelState = this->leftPanel->getCurrentState(); + + if (this->targetRegistersSidePane != nullptr) { + projectSettings.previousRegistersPaneState = this->targetRegistersSidePane->getCurrentState(); + } + } + + if (this->bottomPanel != nullptr) { + projectSettings.previousBottomPanelState = this->bottomPanel->getCurrentState(); + + if (this->ramInspectionPane != nullptr) { + projectSettings.previousRamInspectionPaneState = this->ramInspectionPane->getCurrentState(); + } + + if (this->eepromInspectionPane != nullptr) { + projectSettings.previousEepromInspectionPaneState = this->eepromInspectionPane->getCurrentState(); + } + } + } + } }