[partition] Factor out description of action in status and widget

This commit is contained in:
Adriaan de Groot 2021-07-12 15:17:34 +02:00
parent 535f81ba8a
commit 400a5751f9

View File

@ -122,6 +122,30 @@ static QStringList jobDescriptions( const Calamares::JobList& jobs )
return jobsLines; return jobsLines;
} }
static QString modeDescription( Config::InstallChoice choice )
{
const auto* branding = Calamares::Branding::instance();
static const char context[] = "PartitionViewStep";
switch ( choice )
{
case Config::InstallChoice::Alongside:
return QCoreApplication::translate( context, "Install %1 <strong>alongside</strong> another operating system." )
.arg( branding->shortVersionedName() );
break;
case Config::InstallChoice::Erase:
return QCoreApplication::translate( context, "<strong>Erase</strong> disk and install %1." ).arg( branding->shortVersionedName() );
break;
case Config::InstallChoice::Replace:
return QCoreApplication::translate( context, "<strong>Replace</strong> a partition with %1." ).arg( branding->shortVersionedName() );
break;
case Config::InstallChoice::NoChoice:
case Config::InstallChoice::Manual:
return QCoreApplication::translate( context, "<strong>Manual</strong> partitioning." );
}
return QString();
}
QString QString
PartitionViewStep::prettyStatus() const PartitionViewStep::prettyStatus() const
{ {
@ -135,26 +159,7 @@ PartitionViewStep::prettyStatus() const
cDebug() << "Summary for Partition" << list.length() << choice; cDebug() << "Summary for Partition" << list.length() << choice;
if ( list.length() > 1 ) // There are changes on more than one disk if ( list.length() > 1 ) // There are changes on more than one disk
{ {
// NOTE: all of this should only happen when Manual partitioning is active. modeText = modeDescription(choice);
// Any other choice should result in a list.length() == 1.
switch ( choice )
{
case Config::Alongside:
modeText = tr( "Install %1 <strong>alongside</strong> another operating system." )
.arg( branding->shortVersionedName() );
break;
case Config::Erase:
modeText
= tr( "<strong>Erase</strong> disk and install %1." ).arg( branding->shortVersionedName() );
break;
case Config::Replace:
modeText
= tr( "<strong>Replace</strong> a partition with %1." ).arg( branding->shortVersionedName() );
break;
case Config::NoChoice:
case Config::Manual:
modeText = tr( "<strong>Manual</strong> partitioning." );
}
} }
for ( const auto& info : list ) for ( const auto& info : list )
@ -227,24 +232,7 @@ PartitionViewStep::createSummaryWidget() const
// Any other choice should result in a list.length() == 1. // Any other choice should result in a list.length() == 1.
QLabel* modeLabel = new QLabel; QLabel* modeLabel = new QLabel;
formLayout->addRow( modeLabel ); formLayout->addRow( modeLabel );
QString modeText; modeLabel->setText( modeDescription( choice ) );
switch ( choice )
{
case Config::InstallChoice::Alongside:
modeText = tr( "Install %1 <strong>alongside</strong> another operating system." )
.arg( branding->shortVersionedName() );
break;
case Config::InstallChoice::Erase:
modeText = tr( "<strong>Erase</strong> disk and install %1." ).arg( branding->shortVersionedName() );
break;
case Config::InstallChoice::Replace:
modeText = tr( "<strong>Replace</strong> a partition with %1." ).arg( branding->shortVersionedName() );
break;
case Config::InstallChoice::NoChoice:
case Config::InstallChoice::Manual:
modeText = tr( "<strong>Manual</strong> partitioning." );
}
modeLabel->setText( modeText );
} }
for ( const auto& info : list ) for ( const auto& info : list )
{ {