C++ trickery, part two: shorten code

This commit is contained in:
Adriaan de Groot 2017-07-04 08:29:31 -04:00 committed by Philip
parent f6cbf48b17
commit 854e6d3883
5 changed files with 31 additions and 62 deletions

View File

@ -53,10 +53,8 @@ FinishedPage::FinishedPage( QWidget* parent )
"%1 has been installed on your computer.<br/>"
"You may now restart into your new system, or continue "
"using the %2 Live environment." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ProductName ) ) );
.arg( *Calamares::Branding::VersionedName )
.arg( *Calamares::Branding::ProductName ) );
)
}

View File

@ -1180,13 +1180,11 @@ ChoicePage::setupActions()
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
"The installer will shrink a partition to make room for %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) ) );
.arg( *Calamares::Branding::ShortVersionedName ) );
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
"Replaces a partition with %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) ) );
.arg( *Calamares::Branding::ShortVersionedName ) );
)
m_replaceButton->hide();
@ -1211,8 +1209,7 @@ ChoicePage::setupActions()
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
"The installer will shrink a partition to make room for %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) ) );
.arg( *Calamares::Branding::ShortVersionedName ) );
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
"This will <font color=\"red\">delete</font> all data "
@ -1221,8 +1218,7 @@ ChoicePage::setupActions()
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
"Replaces a partition with %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) ) );
.arg( *Calamares::Branding::ShortVersionedName ) );
)
}
else
@ -1235,8 +1231,7 @@ ChoicePage::setupActions()
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
"The installer will shrink a partition to make room for %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) ) );
.arg( *Calamares::Branding::ShortVersionedName ) );
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
"This will <font color=\"red\">delete</font> all data "
@ -1244,8 +1239,7 @@ ChoicePage::setupActions()
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
"Replaces a partition with %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) ) );
.arg( *Calamares::Branding::ShortVersionedName ) );
)
}
@ -1273,8 +1267,7 @@ ChoicePage::setupActions()
m_alongsideButton->setText( tr( "<strong>Install alongside</strong><br/>"
"The installer will shrink a partition to make room for %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) ) );
.arg( *Calamares::Branding::ShortVersionedName ) );
m_eraseButton->setText( tr( "<strong>Erase disk</strong><br/>"
"This will <font color=\"red\">delete</font> all data "
@ -1282,8 +1275,7 @@ ChoicePage::setupActions()
m_replaceButton->setText( tr( "<strong>Replace a partition</strong><br/>"
"Replaces a partition with %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) ) );
.arg( *Calamares::Branding::ShortVersionedName ) );
)
m_replaceButton->show();

View File

@ -156,18 +156,15 @@ PartitionViewStep::createSummaryWidget() const
{
case ChoicePage::Alongside:
modeText = tr( "Install %1 <strong>alongside</strong> another operating system." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) );
.arg( *Calamares::Branding::ShortVersionedName );
break;
case ChoicePage::Erase:
modeText = tr( "<strong>Erase</strong> disk and install %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) );
.arg( *Calamares::Branding::ShortVersionedName );
break;
case ChoicePage::Replace:
modeText = tr( "<strong>Replace</strong> a partition with %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) );
.arg( *Calamares::Branding::ShortVersionedName );
break;
default:
modeText = tr( "<strong>Manual</strong> partitioning." );
@ -184,22 +181,19 @@ PartitionViewStep::createSummaryWidget() const
{
case ChoicePage::Alongside:
modeText = tr( "Install %1 <strong>alongside</strong> another operating system on disk <strong>%2</strong> (%3)." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) )
.arg( *Calamares::Branding::ShortVersionedName )
.arg( info.deviceNode )
.arg( info.deviceName );
break;
case ChoicePage::Erase:
modeText = tr( "<strong>Erase</strong> disk <strong>%2</strong> (%3) and install %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) )
.arg( *Calamares::Branding::ShortVersionedName )
.arg( info.deviceNode )
.arg( info.deviceName );
break;
case ChoicePage::Replace:
modeText = tr( "<strong>Replace</strong> a partition on disk <strong>%2</strong> (%3) with %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortVersionedName ) )
.arg( *Calamares::Branding::ShortVersionedName )
.arg( info.deviceNode )
.arg( info.deviceName );
break;
@ -250,8 +244,7 @@ PartitionViewStep::createSummaryWidget() const
previewLabels->setModel( info.partitionModelAfter );
preview->setSelectionMode( QAbstractItemView::NoSelection );
previewLabels->setSelectionMode( QAbstractItemView::NoSelection );
previewLabels->setCustomNewRootLabel( Calamares::Branding::instance()->
string( Calamares::Branding::BootloaderEntryName ) );
previewLabels->setCustomNewRootLabel( *Calamares::Branding::BootloaderEntryName );
info.partitionModelAfter->setParent( widget );
field = new QVBoxLayout;
CalamaresUtils::unmarginLayout( field );
@ -411,8 +404,7 @@ PartitionViewStep::onLeave()
"<strong>%2</strong>.<br/><br/>"
"You can continue without setting up an EFI system "
"partition but your system may fail to start." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortProductName ) )
.arg( *Calamares::Branding::ShortProductName )
.arg( espMountPoint );
}
else if ( esp && !esp->activeFlags().testFlag( PartitionTable::FlagEsp ) )
@ -427,8 +419,7 @@ PartitionViewStep::onLeave()
"<br/><br/>"
"You can continue without setting the flag but your "
"system may fail to start." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortProductName ) )
.arg( *Calamares::Branding::ShortProductName )
.arg( espMountPoint );
}

View File

@ -134,8 +134,7 @@ ReplaceWidget::onPartitionSelected()
tr( "Select where to install %1.<br/>"
"<font color=\"red\">Warning: </font>this will delete all files "
"on the selected partition." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) ) );
.arg( *Calamares::Branding::VersionedName ) );
setNextEnabled( false );
return;
}
@ -168,8 +167,7 @@ ReplaceWidget::onPartitionSelected()
updateStatus( CalamaresUtils::Fail,
tr( "%1 cannot be installed on empty space. Please select an "
"existing partition." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) ) );
.arg( *Calamares::Branding::VersionedName ) );
setNextEnabled( false );
return;
}
@ -179,8 +177,7 @@ ReplaceWidget::onPartitionSelected()
updateStatus( CalamaresUtils::Fail,
tr( "%1 cannot be installed on an extended partition. Please select an "
"existing primary or logical partition." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) ) );
.arg( *Calamares::Branding::VersionedName ) );
setNextEnabled( false );
return;
}
@ -189,8 +186,7 @@ ReplaceWidget::onPartitionSelected()
{
updateStatus( CalamaresUtils::Fail,
tr( "%1 cannot be installed on this partition." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) ) );
.arg( *Calamares::Branding::VersionedName ) );
setNextEnabled( false );
return;
}
@ -232,8 +228,7 @@ ReplaceWidget::onPartitionSelected()
"The partition %1 is too small for %2. Please select a partition "
"with capacity at least %3 GiB." )
.arg( partition->partitionPath() )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) )
.arg( *Calamares::Branding::VersionedName )
.arg( requiredSpaceB / ( 1024. * 1024. * 1024. ),
0, 'f', 1 )
.arg( prettyName ) );
@ -256,8 +251,7 @@ ReplaceWidget::onPartitionSelected()
"An EFI system partition cannot be found anywhere "
"on this system. Please go back and use manual "
"partitioning to set up %1." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortProductName ) )
.arg( *Calamares::Branding::ShortProductName )
.arg( prettyName ) );
setNextEnabled( false );
}
@ -268,16 +262,14 @@ ReplaceWidget::onPartitionSelected()
"%1 will be installed on %2.<br/>"
"<font color=\"red\">Warning: </font>all data on partition "
"%2 will be lost.")
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) )
.arg( *Calamares::Branding::VersionedName )
.arg( partition->partitionPath() )
.arg( prettyName ) );
m_ui->bootStatusLabel->show();
m_ui->bootStatusLabel->setText(
tr( "The EFI system partition at %1 will be used for starting %2." )
.arg( efiSystemPartitions.first()->partitionPath() )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ShortProductName ) ) );
.arg( *Calamares::Branding::ShortProductName ) );
setNextEnabled( true );
}
else
@ -287,8 +279,7 @@ ReplaceWidget::onPartitionSelected()
"%1 will be installed on %2.<br/>"
"<font color=\"red\">Warning: </font>all data on partition "
"%2 will be lost.")
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) )
.arg( *Calamares::Branding::VersionedName )
.arg( partition->partitionPath() )
.arg( prettyName ) );
m_ui->bootStatusLabel->show();
@ -312,8 +303,7 @@ ReplaceWidget::onPartitionSelected()
"%1 will be installed on %2.<br/>"
"<font color=\"red\">Warning: </font>all data on partition "
"%2 will be lost.")
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) )
.arg( *Calamares::Branding::VersionedName )
.arg( partition->partitionPath() )
.arg( prettyName ) );
setNextEnabled( true );

View File

@ -145,8 +145,7 @@ FillGlobalStorageJob::prettyDescription() const
{
if ( mountPoint == "/" )
lines.append( tr( "Install %1 on <strong>new</strong> %2 system partition." )
.arg( Calamares::Branding::instance()->string(
Calamares::Branding::ShortProductName ) )
.arg( *Calamares::Branding::ShortProductName )
.arg( fsType ) );
else
lines.append( tr( "Set up <strong>new</strong> %2 partition with mount point "
@ -159,8 +158,7 @@ FillGlobalStorageJob::prettyDescription() const
if ( mountPoint == "/" )
lines.append( tr( "Install %2 on %3 system partition <strong>%1</strong>." )
.arg( path )
.arg( Calamares::Branding::instance()->string(
Calamares::Branding::ShortProductName ) )
.arg( *Calamares::Branding::ShortProductName )
.arg( fsType ) );
else
lines.append( tr( "Set up %3 partition <strong>%1</strong> with mount point "