[summary] Improve naming, shuffle parameters
- the page doesn't need to remember what step it belongs to, if the step tells it when creating widgets. - detach naming from the viewstep API that calls it.
This commit is contained in:
parent
87af923638
commit
763f29e2b8
@ -27,18 +27,15 @@
|
||||
#include <QLabel>
|
||||
#include <QScrollArea>
|
||||
|
||||
SummaryPage::SummaryPage( Config* config, const SummaryViewStep* thisViewStep, QWidget* parent )
|
||||
SummaryPage::SummaryPage( Config* config, QWidget* parent )
|
||||
: QWidget()
|
||||
, m_thisViewStep( thisViewStep )
|
||||
, m_contentWidget( nullptr )
|
||||
, m_scrollArea( new QScrollArea( this ) )
|
||||
{
|
||||
Q_UNUSED( parent )
|
||||
|
||||
|
||||
this->setObjectName( "summaryStep" );
|
||||
|
||||
Q_ASSERT( m_thisViewStep );
|
||||
QVBoxLayout* layout = new QVBoxLayout( this );
|
||||
layout->setContentsMargins( 0, 0, 0, 0 );
|
||||
|
||||
@ -85,7 +82,7 @@ createBodyLabel( const QString& text, const QPalette& bodyPalette )
|
||||
// Adds a widget for those ViewSteps that want a summary;
|
||||
// see SummaryPage documentation and also ViewStep docs.
|
||||
void
|
||||
SummaryPage::onActivate()
|
||||
SummaryPage::buildWidgets( Config* config, SummaryViewStep* viewstep )
|
||||
{
|
||||
const int SECTION_SPACING = 12;
|
||||
|
||||
@ -102,7 +99,7 @@ SummaryPage::onActivate()
|
||||
bodyPalette.setColor( WindowBackground, palette().window().color().lighter( 108 ) );
|
||||
|
||||
bool first = true;
|
||||
const Calamares::ViewStepList steps = stepsForSummary( Calamares::ViewManager::instance()->viewSteps() );
|
||||
const Calamares::ViewStepList steps = stepsForSummary( Calamares::ViewManager::instance()->viewSteps(), viewstep );
|
||||
|
||||
for ( Calamares::ViewStep* step : steps )
|
||||
{
|
||||
@ -151,12 +148,12 @@ SummaryPage::onActivate()
|
||||
|
||||
cDebug() << "Summary widget is larger than viewport, enlarge by" << enlarge << "to" << widgetSize;
|
||||
|
||||
emit m_thisViewStep->ensureSize( widgetSize ); // Only expand height
|
||||
emit viewstep->ensureSize( widgetSize ); // Only expand height
|
||||
}
|
||||
}
|
||||
|
||||
Calamares::ViewStepList
|
||||
SummaryPage::stepsForSummary( const Calamares::ViewStepList& allSteps ) const
|
||||
SummaryPage::stepsForSummary( const Calamares::ViewStepList& allSteps, SummaryViewStep* viewstep ) const
|
||||
{
|
||||
Calamares::ViewStepList steps;
|
||||
for ( Calamares::ViewStep* step : allSteps )
|
||||
@ -173,7 +170,7 @@ SummaryPage::stepsForSummary( const Calamares::ViewStepList& allSteps ) const
|
||||
|
||||
// If we reach the parent step of this page, we're done collecting the list of
|
||||
// steps to summarize.
|
||||
if ( m_thisViewStep == step )
|
||||
if ( viewstep == step )
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -185,7 +182,7 @@ SummaryPage::stepsForSummary( const Calamares::ViewStepList& allSteps ) const
|
||||
}
|
||||
|
||||
void
|
||||
SummaryPage::onLeave()
|
||||
SummaryPage::cleanup()
|
||||
{
|
||||
delete m_contentWidget;
|
||||
m_contentWidget = nullptr;
|
||||
|
@ -45,22 +45,19 @@ class SummaryPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SummaryPage( Config* config, const SummaryViewStep* thisViewStep, QWidget* parent = nullptr );
|
||||
explicit SummaryPage( Config* config, QWidget* parent = nullptr );
|
||||
|
||||
/// @brief Create contents showing all of the summary
|
||||
void onActivate();
|
||||
void buildWidgets( Config* config, SummaryViewStep* viewstep );
|
||||
/// @brief Clean up the widgets
|
||||
void onLeave();
|
||||
void cleanup();
|
||||
|
||||
private:
|
||||
Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const;
|
||||
|
||||
const SummaryViewStep* m_thisViewStep;
|
||||
Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps, SummaryViewStep* viewstep ) const;
|
||||
|
||||
QVBoxLayout* m_layout = nullptr;
|
||||
QWidget* m_contentWidget = nullptr;
|
||||
|
||||
QScrollArea* m_scrollArea;
|
||||
QScrollArea* m_scrollArea = nullptr;
|
||||
};
|
||||
|
||||
#endif // SUMMARYPAGE_H
|
||||
|
@ -16,7 +16,7 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( SummaryViewStepFactory, registerPlugin< Sum
|
||||
SummaryViewStep::SummaryViewStep( QObject* parent )
|
||||
: Calamares::ViewStep( parent )
|
||||
, m_config( new Config( this ) )
|
||||
, m_widget( new SummaryPage( m_config, this ) )
|
||||
, m_widget( new SummaryPage( m_config ) )
|
||||
{
|
||||
emit nextStatusChanged( true );
|
||||
}
|
||||
@ -85,7 +85,7 @@ void
|
||||
SummaryViewStep::onActivate()
|
||||
{
|
||||
m_config->collectSummaries( this, Config::Widgets::Enabled );
|
||||
m_widget->onActivate();
|
||||
m_widget->buildWidgets( m_config, this );
|
||||
}
|
||||
|
||||
|
||||
@ -93,5 +93,5 @@ void
|
||||
SummaryViewStep::onLeave()
|
||||
{
|
||||
m_config->clearSummaries();
|
||||
m_widget->onLeave();
|
||||
m_widget->cleanup();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user