diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp
index 7576c7a05..69ea4cb2e 100644
--- a/src/modules/partition/PartitionViewStep.cpp
+++ b/src/modules/partition/PartitionViewStep.cpp
@@ -109,6 +109,12 @@ PartitionViewStep::prettyName() const
return tr( "Partitions" );
}
+/** @brief Gather the pretty descriptions of all the partitioning jobs
+ *
+ * Returns a QStringList of each job's pretty description, including
+ * empty strings and duplicates. The list is in-order of how the
+ * jobs will be run.
+ */
static QStringList jobDescriptions( const Calamares::JobList& jobs )
{
QStringList jobsLines;
@@ -122,6 +128,10 @@ static QStringList jobDescriptions( const Calamares::JobList& jobs )
return jobsLines;
}
+/** @brief A top-level description of what @p choice does
+ *
+ * Returns a (branded) string describing what @p choice will do.
+ */
static QString modeDescription( Config::InstallChoice choice )
{
const auto* branding = Calamares::Branding::instance();
@@ -146,15 +156,62 @@ static QString modeDescription( Config::InstallChoice choice )
return QString();
}
+/** @brief A top-level description of what @p choice does to disk @p info
+ *
+ * Returns a (branded, and device-specific) string describing what
+ * will be done to device @p info when @p choice is made. The @p listLength
+ * is used to provide context; when more than one disk is in use, the description
+ * works differently.
+ */
+static QString diskDescription( int listLength, const PartitionCoreModule::SummaryInfo& info, Config::InstallChoice choice )
+{
+ const auto* branding = Calamares::Branding::instance();
+ static const char context[] = "PartitionViewStep";
+
+ if ( listLength == 1 ) // this is the only disk preview
+ {
+ switch ( choice )
+ {
+ case Config::Alongside:
+ return QCoreApplication::translate( context, "Install %1 alongside another operating system on disk "
+ "%2 (%3)." )
+ .arg( branding->shortVersionedName() )
+ .arg( info.deviceNode )
+ .arg( info.deviceName );
+ break;
+ case Config::Erase:
+ return QCoreApplication::translate( context, "Erase disk %2 (%3) and install %1." )
+ .arg( branding->shortVersionedName() )
+ .arg( info.deviceNode )
+ .arg( info.deviceName );
+ break;
+ case Config::Replace:
+ return QCoreApplication::translate( context, "Replace a partition on disk %2 (%3) with %1." )
+ .arg( branding->shortVersionedName() )
+ .arg( info.deviceNode )
+ .arg( info.deviceName );
+ break;
+ case Config::NoChoice:
+ case Config::Manual:
+ return QCoreApplication::translate( context, "Manual partitioning on disk %1 (%2)." )
+ .arg( info.deviceNode )
+ .arg( info.deviceName );
+ }
+ return QString();
+ }
+ else // multiple disk previews!
+ {
+ return QCoreApplication::translate( context, "Disk %1 (%2)" ).arg( info.deviceNode ).arg( info.deviceName ) ;
+ }
+}
+
QString
PartitionViewStep::prettyStatus() const
{
QString jobsLabel, modeText, diskInfoLabel;
- Config::InstallChoice choice = m_config->installChoice();
- const auto* branding = Calamares::Branding::instance();
-
- QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo();
+ const Config::InstallChoice choice = m_config->installChoice();
+ const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo();
cDebug() << "Summary for Partition" << list.length() << choice;
if ( list.length() > 1 ) // There are changes on more than one disk
@@ -164,40 +221,8 @@ PartitionViewStep::prettyStatus() const
for ( const auto& info : list )
{
- if ( list.length() == 1 ) // this is the only disk preview
- {
- switch ( choice )
- {
- case Config::Alongside:
- diskInfoLabel = tr( "Install %1 alongside another operating system on disk "
- "%2 (%3)." )
- .arg( branding->shortVersionedName() )
- .arg( info.deviceNode )
- .arg( info.deviceName );
- break;
- case Config::Erase:
- diskInfoLabel = tr( "Erase disk %2 (%3) and install %1." )
- .arg( branding->shortVersionedName() )
- .arg( info.deviceNode )
- .arg( info.deviceName );
- break;
- case Config::Replace:
- diskInfoLabel = tr( "Replace a partition on disk %2 (%3) with %1." )
- .arg( branding->shortVersionedName() )
- .arg( info.deviceNode )
- .arg( info.deviceName );
- break;
- case Config::NoChoice:
- case Config::Manual:
- diskInfoLabel = tr( "Manual partitioning on disk %1 (%2)." )
- .arg( info.deviceNode )
- .arg( info.deviceName );
- }
- }
- else // multiple disk previews!
- {
- diskInfoLabel = tr( "Disk %1 (%2)" ).arg( info.deviceNode ).arg( info.deviceName ) ;
- }
+ // TODO: this overwrites each iteration
+ diskInfoLabel = diskDescription( list.length(), info, choice );
}
const QStringList jobsLines = jobDescriptions( jobs() );
@@ -224,8 +249,7 @@ PartitionViewStep::createSummaryWidget() const
formLayout->setContentsMargins( MARGIN, 0, MARGIN, MARGIN );
mainLayout->addLayout( formLayout );
- const auto* branding = Calamares::Branding::instance();
- QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo();
+ const QList< PartitionCoreModule::SummaryInfo > list = m_core->createSummaryInfo();
if ( list.length() > 1 ) // There are changes on more than one disk
{
//NOTE: all of this should only happen when Manual partitioning is active.
@@ -237,43 +261,7 @@ PartitionViewStep::createSummaryWidget() const
for ( const auto& info : list )
{
QLabel* diskInfoLabel = new QLabel;
- if ( list.length() == 1 ) // this is the only disk preview
- {
- QString modeText;
- switch ( choice )
- {
- case Config::InstallChoice::Alongside:
- modeText = tr( "Install %1 alongside another operating system on disk "
- "%2 (%3)." )
- .arg( branding->shortVersionedName() )
- .arg( info.deviceNode )
- .arg( info.deviceName );
- break;
- case Config::InstallChoice::Erase:
- modeText = tr( "Erase disk %2 (%3) and install %1." )
- .arg( branding->shortVersionedName() )
- .arg( info.deviceNode )
- .arg( info.deviceName );
- break;
- case Config::InstallChoice::Replace:
- modeText = tr( "Replace a partition on disk %2 (%3) with %1." )
- .arg( branding->shortVersionedName() )
- .arg( info.deviceNode )
- .arg( info.deviceName );
- break;
- case Config::InstallChoice::NoChoice:
- case Config::InstallChoice::Manual:
- modeText = tr( "Manual partitioning on disk %1 (%2)." )
- .arg( info.deviceNode )
- .arg( info.deviceName );
- }
- diskInfoLabel->setText( modeText );
- }
- else // multiple disk previews!
- {
- diskInfoLabel->setText(
- tr( "Disk %1 (%2)" ).arg( info.deviceNode ).arg( info.deviceName ) );
- }
+ diskInfoLabel->setText( diskDescription( list.length(), info, choice ) );
formLayout->addRow( diskInfoLabel );
PartitionBarsView* preview;