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 <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-04-11 15:13:51 +02:00
parent ca39832c5d
commit d1c3b5bd71
2 changed files with 15 additions and 6 deletions

View File

@@ -28,6 +28,7 @@
#include "projectconfiguration.h" #include "projectconfiguration.h"
#include "projectexplorer_export.h" #include "projectexplorer_export.h"
#include <utils/optional.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QFutureInterface> #include <QFutureInterface>
@@ -88,6 +89,10 @@ public:
bool widgetExpandedByDefault() const; bool widgetExpandedByDefault() const;
void setWidgetExpandedByDefault(bool widgetExpandedByDefault); 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; } bool isImmutable() const { return m_immutable; }
void setImmutable(bool immutable) { m_immutable = immutable; } void setImmutable(bool immutable) { m_immutable = immutable; }
@@ -123,6 +128,7 @@ private:
bool m_immutable = false; bool m_immutable = false;
bool m_widgetExpandedByDefault = true; bool m_widgetExpandedByDefault = true;
bool m_runInGuiThread = true; bool m_runInGuiThread = true;
Utils::optional<bool> m_wasExpanded;
}; };
class PROJECTEXPLORER_EXPORT BuildStepInfo class PROJECTEXPLORER_EXPORT BuildStepInfo

View File

@@ -258,8 +258,11 @@ void BuildStepListWidget::init(BuildStepList *bsl)
for (int i = 0; i < bsl->count(); ++i) { for (int i = 0; i < bsl->count(); ++i) {
addBuildStep(i); addBuildStep(i);
// addBuilStep expands the config widget by default, which we don't want here // addBuilStep expands the config widget by default, which we don't want here
if (m_buildStepsData.at(i)->step->widgetExpandedByDefault()) if (m_buildStepsData.at(i)->step->widgetExpandedByDefault()) {
m_buildStepsData.at(i)->detailsWidget->setState(DetailsWidget::Collapsed); m_buildStepsData.at(i)->detailsWidget->setState(
m_buildStepsData.at(i)->step->wasUserExpanded()
? DetailsWidget::Expanded : DetailsWidget::Collapsed);
}
} }
m_noStepsLabel->setVisible(bsl->isEmpty()); m_noStepsLabel->setVisible(bsl->isEmpty());
@@ -323,10 +326,10 @@ void BuildStepListWidget::addBuildStep(int pos)
this, &BuildStepListWidget::updateEnabledState); this, &BuildStepListWidget::updateEnabledState);
// Expand new build steps by default // Expand new build steps by default
if (newStep->widgetExpandedByDefault()) const bool expand = newStep->hasUserExpansionState()
s->detailsWidget->setState(DetailsWidget::Expanded); ? newStep->wasUserExpanded() : newStep->widgetExpandedByDefault();
else s->detailsWidget->setState(expand ? DetailsWidget::Expanded : DetailsWidget::OnlySummary);
s->detailsWidget->setState(DetailsWidget::OnlySummary); connect(s->detailsWidget, &DetailsWidget::expanded, newStep, &BuildStep::setUserExpanded);
m_noStepsLabel->setVisible(false); m_noStepsLabel->setVisible(false);
updateBuildStepButtonsState(); updateBuildStepButtonsState();