From d1c3b5bd71fec9e6d7b14a8e1c2363c6eaafe8c2 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Thu, 11 Apr 2019 15:13:51 +0200 Subject: [PATCH] ProjectExplorer: Remember build step expansion state ... when switching targets. If a user expands a build step and then switches the target, it's reasonable for them to assume that the step is still expanded when switching back. Ideally, we would also do this for aspects (if only for consistency), but unlike for build steps there's no central code location, so let's leave it at this for now. Fixes: QTCREATORBUG-21343 Change-Id: Ic142ab5d676bf7d3b6aeabb6f7a26be7bd18f22c Reviewed-by: hjk --- src/plugins/projectexplorer/buildstep.h | 6 ++++++ src/plugins/projectexplorer/buildstepspage.cpp | 15 +++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index 4d2cf7bea21..0abf7d5b78b 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -28,6 +28,7 @@ #include "projectconfiguration.h" #include "projectexplorer_export.h" +#include #include #include @@ -88,6 +89,10 @@ public: bool widgetExpandedByDefault() const; void setWidgetExpandedByDefault(bool widgetExpandedByDefault); + bool hasUserExpansionState() const { return m_wasExpanded.has_value(); } + bool wasUserExpanded() const { return m_wasExpanded.value_or(false); } + void setUserExpanded(bool expanded) { m_wasExpanded = expanded; } + bool isImmutable() const { return m_immutable; } void setImmutable(bool immutable) { m_immutable = immutable; } @@ -123,6 +128,7 @@ private: bool m_immutable = false; bool m_widgetExpandedByDefault = true; bool m_runInGuiThread = true; + Utils::optional m_wasExpanded; }; class PROJECTEXPLORER_EXPORT BuildStepInfo diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp index a9897e610c7..331ccd9f402 100644 --- a/src/plugins/projectexplorer/buildstepspage.cpp +++ b/src/plugins/projectexplorer/buildstepspage.cpp @@ -258,8 +258,11 @@ void BuildStepListWidget::init(BuildStepList *bsl) for (int i = 0; i < bsl->count(); ++i) { addBuildStep(i); // addBuilStep expands the config widget by default, which we don't want here - if (m_buildStepsData.at(i)->step->widgetExpandedByDefault()) - m_buildStepsData.at(i)->detailsWidget->setState(DetailsWidget::Collapsed); + if (m_buildStepsData.at(i)->step->widgetExpandedByDefault()) { + m_buildStepsData.at(i)->detailsWidget->setState( + m_buildStepsData.at(i)->step->wasUserExpanded() + ? DetailsWidget::Expanded : DetailsWidget::Collapsed); + } } m_noStepsLabel->setVisible(bsl->isEmpty()); @@ -323,10 +326,10 @@ void BuildStepListWidget::addBuildStep(int pos) this, &BuildStepListWidget::updateEnabledState); // Expand new build steps by default - if (newStep->widgetExpandedByDefault()) - s->detailsWidget->setState(DetailsWidget::Expanded); - else - s->detailsWidget->setState(DetailsWidget::OnlySummary); + const bool expand = newStep->hasUserExpansionState() + ? newStep->wasUserExpanded() : newStep->widgetExpandedByDefault(); + s->detailsWidget->setState(expand ? DetailsWidget::Expanded : DetailsWidget::OnlySummary); + connect(s->detailsWidget, &DetailsWidget::expanded, newStep, &BuildStep::setUserExpanded); m_noStepsLabel->setVisible(false); updateBuildStepButtonsState();