From 5de99d53d20e92b363e4556e6f9b41d2e5953f2a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 20 Jul 2021 16:00:53 +0200 Subject: [PATCH] [summary] Move title to Config object Rather than Config asking its (owning) ViewStep what the title is -- all existing implementations have a prettyName() for that -- move the title into Config and re-do-the ViewSteps to use it. Rename init() to something meaningful. --- src/modules/summary/Config.cpp | 17 ++++++++--------- src/modules/summary/Config.h | 5 ++--- src/modules/summary/SummaryViewStep.cpp | 4 ++-- src/modules/summaryq/SummaryQmlViewStep.cpp | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/modules/summary/Config.cpp b/src/modules/summary/Config.cpp index 18ce9354d..5110e09a6 100644 --- a/src/modules/summary/Config.cpp +++ b/src/modules/summary/Config.cpp @@ -67,9 +67,8 @@ SummaryModel::setSummaryList( const Calamares::ViewStepList& steps, bool withWid Q_EMIT endResetModel(); } -Config::Config( Calamares::ViewStep* parent ) +Config::Config( QObject* parent ) : QObject( parent ) - , m_thisViewStep( parent ) , m_summary( new SummaryModel( this ) ) { @@ -80,24 +79,24 @@ Config::Config( Calamares::ViewStep* parent ) void Config::retranslate() { - m_title = m_thisViewStep->prettyName(); + m_title = tr( "Summary" ); if ( Calamares::Settings::instance()->isSetupMode() ) { - m_message = ( tr( "This is an overview of what will happen once you start " - "the setup procedure." ) ); + m_message = tr( "This is an overview of what will happen once you start " + "the setup procedure." ); } else { - m_message = ( tr( "This is an overview of what will happen once you start " - "the install procedure." ) ); + m_message = tr( "This is an overview of what will happen once you start " + "the install procedure." ); } Q_EMIT titleChanged( m_title ); Q_EMIT messageChanged( m_message ); } void -Config::init() +Config::collectSummaries( const Calamares::ViewStep* upToHere ) { Calamares::ViewStepList steps; for ( Calamares::ViewStep* step : Calamares::ViewManager::instance()->viewSteps() ) @@ -116,7 +115,7 @@ Config::init() // we know we're providing a summary of steps up until this // view step, so we now have steps since the previous exec, up // to this summary. - if ( m_thisViewStep == step ) + if ( upToHere == step ) { break; } diff --git a/src/modules/summary/Config.h b/src/modules/summary/Config.h index 19cd6212c..15604d933 100644 --- a/src/modules/summary/Config.h +++ b/src/modules/summary/Config.h @@ -70,10 +70,10 @@ class Config : public QObject Q_PROPERTY( QAbstractListModel* summaryModel READ summaryModel CONSTANT FINAL ) public: - explicit Config( Calamares::ViewStep* parent = nullptr ); + explicit Config( QObject* parent = nullptr ); ///@brief Called later, to load the model once all viewsteps are there - void init(); + void collectSummaries( const Calamares::ViewStep* upToHere ); QAbstractListModel* summaryModel() const { return m_summary; } @@ -84,7 +84,6 @@ private: Calamares::ViewStepList stepsForSummary( const Calamares::ViewStepList& allSteps ) const; void retranslate(); - const Calamares::ViewStep* m_thisViewStep; SummaryModel* m_summary; QString m_title; diff --git a/src/modules/summary/SummaryViewStep.cpp b/src/modules/summary/SummaryViewStep.cpp index e29fbae03..d4e439ae3 100644 --- a/src/modules/summary/SummaryViewStep.cpp +++ b/src/modules/summary/SummaryViewStep.cpp @@ -35,7 +35,7 @@ SummaryViewStep::~SummaryViewStep() QString SummaryViewStep::prettyName() const { - return tr( "Summary" ); + return m_config->title(); } @@ -84,7 +84,7 @@ SummaryViewStep::jobs() const void SummaryViewStep::onActivate() { - m_config->init(); + m_config->collectSummaries( this ); m_widget->onActivate(); } diff --git a/src/modules/summaryq/SummaryQmlViewStep.cpp b/src/modules/summaryq/SummaryQmlViewStep.cpp index 0be2b1615..23e18a861 100644 --- a/src/modules/summaryq/SummaryQmlViewStep.cpp +++ b/src/modules/summaryq/SummaryQmlViewStep.cpp @@ -25,7 +25,7 @@ SummaryQmlViewStep::~SummaryQmlViewStep() {} QString SummaryQmlViewStep::prettyName() const { - return tr( "Summary" ); + return m_config->title(); } @@ -69,5 +69,5 @@ SummaryQmlViewStep::onActivate() { // Collect the steps before this one: those need to have their // summary (text or widget) displayed. - m_config->init(); + m_config->collectSummaries( this ); }