C++ trickery to make the code shorter to read.
This commit is contained in:
parent
843706e38d
commit
f6cbf48b17
@ -43,8 +43,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
|
||||
|
||||
CALAMARES_RETRANSLATE(
|
||||
setWindowTitle( tr( "%1 Installer" )
|
||||
.arg( Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::ProductName ) ) );
|
||||
.arg( *Calamares::Branding::ProductName ) );
|
||||
)
|
||||
|
||||
using CalamaresUtils::windowMinimumHeight;
|
||||
|
@ -37,6 +37,11 @@ class UIDLLEXPORT Branding : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Descriptive strings in the configuration file. use
|
||||
* e.g. *Branding::ProductName to get the string value for
|
||||
* the product name.
|
||||
*/
|
||||
enum StringEntry : short
|
||||
{
|
||||
ProductName,
|
||||
@ -112,6 +117,8 @@ private:
|
||||
bool m_welcomeStyleCalamares;
|
||||
};
|
||||
|
||||
template<typename U> inline QString operator*(U e) { return Branding::instance()->string( e ); }
|
||||
|
||||
}
|
||||
|
||||
#endif // BRANDING_H
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -226,10 +227,8 @@ ViewManager::next()
|
||||
tr( "The %1 installer is about to make changes to your "
|
||||
"disk in order to install %2.<br/><strong>You will not be able "
|
||||
"to undo these changes.</strong>" )
|
||||
.arg( Calamares::Branding::instance()->string(
|
||||
Calamares::Branding::ShortProductName ) )
|
||||
.arg( Calamares::Branding::instance()->string(
|
||||
Calamares::Branding::ShortVersionedName ) ),
|
||||
.arg( *Calamares::Branding::ShortProductName )
|
||||
.arg( *Calamares::Branding::ShortVersionedName ),
|
||||
tr( "&Install now" ),
|
||||
tr( "Go &back" ),
|
||||
QString(),
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -474,8 +475,7 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current,
|
||||
qRound64( part->used() * 1.1 ),
|
||||
part->capacity() - requiredStorageB,
|
||||
part->capacity() / 2,
|
||||
Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::ProductName ) );
|
||||
*Calamares::Branding::ProductName );
|
||||
|
||||
if ( m_isEfi )
|
||||
setupEfiSystemPartitionSelector();
|
||||
@ -775,8 +775,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
|
||||
if ( !homePartitionPath->isEmpty() )
|
||||
m_reuseHomeCheckBox->setText( tr( "Reuse %1 as home partition for %2." )
|
||||
.arg( *homePartitionPath )
|
||||
.arg( Calamares::Branding::instance()->string(
|
||||
Calamares::Branding::ShortProductName ) ) );
|
||||
.arg( *Calamares::Branding::ShortProductName ) );
|
||||
delete homePartitionPath;
|
||||
|
||||
if ( m_isEfi )
|
||||
@ -919,8 +918,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice )
|
||||
.arg( m_beforePartitionBarsView->selectionModel()->currentIndex().data().toString() )
|
||||
.arg( size / ( 1024 * 1024 ) )
|
||||
.arg( sizeNext / ( 1024 * 1024 ) )
|
||||
.arg( Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::ShortProductName ) ) );
|
||||
.arg( *Calamares::Branding::ShortProductName ) );
|
||||
} );
|
||||
|
||||
m_previewAfterFrame->show();
|
||||
@ -948,8 +946,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice )
|
||||
m_afterPartitionBarsView->setNestedPartitionsMode( mode );
|
||||
m_afterPartitionLabelsView = new PartitionLabelsView( m_previewAfterFrame );
|
||||
m_afterPartitionLabelsView->setExtendedPartitionHidden( mode == PartitionBarsView::NoNestedPartitions );
|
||||
m_afterPartitionLabelsView->setCustomNewRootLabel( Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::BootloaderEntryName ) );
|
||||
m_afterPartitionLabelsView->setCustomNewRootLabel( *Calamares::Branding::BootloaderEntryName );
|
||||
|
||||
PartitionModel* model = m_core->partitionModelForDevice( selectedDevice() );
|
||||
|
||||
@ -1073,8 +1070,7 @@ ChoicePage::setupEfiSystemPartitionSelector()
|
||||
tr( "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 ) );
|
||||
updateNextEnabled();
|
||||
}
|
||||
else if ( efiSystemPartitions.count() == 1 ) //probably most usual situation
|
||||
@ -1083,8 +1079,7 @@ ChoicePage::setupEfiSystemPartitionSelector()
|
||||
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 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -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 );
|
||||
)
|
||||
|
||||
@ -89,8 +88,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,
|
||||
@ -193,12 +191,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,
|
||||
@ -206,7 +203,7 @@ WelcomePage::setUpLinks( bool showSupportUrl,
|
||||
CalamaresUtils::defaultFontHeight() ) ) );
|
||||
connect( ui->supportButton, &QPushButton::clicked, []
|
||||
{
|
||||
QDesktopServices::openUrl( Branding::instance()->string( Branding::SupportUrl ) );
|
||||
QDesktopServices::openUrl( *Branding::SupportUrl );
|
||||
} );
|
||||
}
|
||||
else
|
||||
@ -214,7 +211,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,
|
||||
@ -222,7 +219,7 @@ WelcomePage::setUpLinks( bool showSupportUrl,
|
||||
CalamaresUtils::defaultFontHeight() ) ) );
|
||||
connect( ui->knownIssuesButton, &QPushButton::clicked, []
|
||||
{
|
||||
QDesktopServices::openUrl( Branding::instance()->string( Branding::KnownIssuesUrl ) );
|
||||
QDesktopServices::openUrl( *Branding::KnownIssuesUrl );
|
||||
} );
|
||||
}
|
||||
else
|
||||
@ -230,7 +227,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,
|
||||
@ -238,7 +235,7 @@ WelcomePage::setUpLinks( bool showSupportUrl,
|
||||
CalamaresUtils::defaultFontHeight() ) ) );
|
||||
connect( ui->releaseNotesButton, &QPushButton::clicked, []
|
||||
{
|
||||
QDesktopServices::openUrl( Branding::instance()->string( Branding::ReleaseNotesUrl ) );
|
||||
QDesktopServices::openUrl( *Branding::ReleaseNotesUrl );
|
||||
} );
|
||||
}
|
||||
else
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -96,8 +97,7 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries )
|
||||
"requirements for installing %1.<br/>"
|
||||
"Installation cannot continue. "
|
||||
"<a href=\"#details\">Details...</a>" )
|
||||
.arg( Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::ShortVersionedName ) ) );
|
||||
.arg( *Calamares::Branding::ShortVersionedName ) );
|
||||
)
|
||||
textLabel->setOpenExternalLinks( false );
|
||||
connect( textLabel, &QLabel::linkActivated,
|
||||
@ -114,8 +114,7 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries )
|
||||
"recommended requirements for installing %1.<br/>"
|
||||
"Installation can continue, but some features "
|
||||
"might be disabled." )
|
||||
.arg( Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::ShortVersionedName ) ) );
|
||||
.arg( *Calamares::Branding::ShortVersionedName ) );
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -141,8 +140,7 @@ CheckerWidget::init( const QList< PrepareEntry >& checkEntries )
|
||||
CALAMARES_RETRANSLATE(
|
||||
textLabel->setText( tr( "This program will ask you some questions and "
|
||||
"set up %2 on your computer." )
|
||||
.arg( Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::ProductName ) ) );
|
||||
.arg( *Calamares::Branding::ProductName ) );
|
||||
textLabel->setAlignment( Qt::AlignCenter );
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user