C++ trickery to make the code shorter to read.

This commit is contained in:
Adriaan de Groot 2017-07-03 18:07:18 -04:00
parent 3ecd2f2ff6
commit ee4e4dfccc
6 changed files with 32 additions and 37 deletions

View file

@ -54,12 +54,11 @@ WelcomePage::WelcomePage( RequirementsChecker* requirementsChecker, QWidget* par
ui->mainText->setOpenExternalLinks( true );
cDebug() << "Welcome string" << Calamares::Branding::instance()->welcomeStyleCalamares()
<< Calamares::Branding::instance()->string( Calamares::Branding::VersionedName );
<< *Calamares::Branding::VersionedName;
CALAMARES_RETRANSLATE(
ui->mainText->setText( (Calamares::Branding::instance()->welcomeStyleCalamares() ? tr( "<h1>Welcome to the Calamares installer for %1.</h1>" ) : tr( "<h1>Welcome to the %1 installer.</h1>" ))
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) ) );
.arg( *Calamares::Branding::VersionedName ) );
ui->retranslateUi( this );
)
@ -90,8 +89,7 @@ WelcomePage::WelcomePage( RequirementsChecker* requirementsChecker, QWidget* par
)
.arg( CALAMARES_APPLICATION_NAME )
.arg( CALAMARES_VERSION )
.arg( Calamares::Branding::instance()->string(
Calamares::Branding::VersionedName ) ),
.arg( *Calamares::Branding::VersionedName ),
QMessageBox::Ok,
this );
mb.setIconPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Squid,
@ -194,12 +192,11 @@ WelcomePage::setUpLinks( bool showSupportUrl,
bool showReleaseNotesUrl )
{
using namespace Calamares;
Branding* b = Branding::instance();
if ( showSupportUrl && !b->string( Branding::SupportUrl ).isEmpty() )
if ( showSupportUrl && !( *Branding::SupportUrl ).isEmpty() )
{
CALAMARES_RETRANSLATE(
ui->supportButton->setText( tr( "%1 support" )
.arg( b->string( Branding::ShortProductName ) ) );
.arg( *Branding::ShortProductName ) );
)
ui->supportButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Help,
CalamaresUtils::Original,
@ -207,7 +204,7 @@ WelcomePage::setUpLinks( bool showSupportUrl,
CalamaresUtils::defaultFontHeight() ) ) );
connect( ui->supportButton, &QPushButton::clicked, []
{
QDesktopServices::openUrl( Branding::instance()->string( Branding::SupportUrl ) );
QDesktopServices::openUrl( *Branding::SupportUrl );
} );
}
else
@ -215,7 +212,7 @@ WelcomePage::setUpLinks( bool showSupportUrl,
ui->supportButton->hide();
}
if ( showKnownIssuesUrl && !b->string( Branding::KnownIssuesUrl ).isEmpty() )
if ( showKnownIssuesUrl && !( *Branding::KnownIssuesUrl ).isEmpty() )
{
ui->knownIssuesButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Bugs,
CalamaresUtils::Original,
@ -223,7 +220,7 @@ WelcomePage::setUpLinks( bool showSupportUrl,
CalamaresUtils::defaultFontHeight() ) ) );
connect( ui->knownIssuesButton, &QPushButton::clicked, []
{
QDesktopServices::openUrl( Branding::instance()->string( Branding::KnownIssuesUrl ) );
QDesktopServices::openUrl( *Branding::KnownIssuesUrl );
} );
}
else
@ -231,7 +228,7 @@ WelcomePage::setUpLinks( bool showSupportUrl,
ui->knownIssuesButton->hide();
}
if ( showReleaseNotesUrl && !b->string( Branding::ReleaseNotesUrl ).isEmpty() )
if ( showReleaseNotesUrl && !( *Branding::ReleaseNotesUrl ).isEmpty() )
{
ui->releaseNotesButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Release,
CalamaresUtils::Original,
@ -239,7 +236,7 @@ WelcomePage::setUpLinks( bool showSupportUrl,
CalamaresUtils::defaultFontHeight() ) ) );
connect( ui->releaseNotesButton, &QPushButton::clicked, []
{
QDesktopServices::openUrl( Branding::instance()->string( Branding::ReleaseNotesUrl ) );
QDesktopServices::openUrl( *Branding::ReleaseNotesUrl );
} );
}
else