[libcalamares] Make the RETRANSLATE macros more statement-line

Require a ; after RETRANSLATE macros. They are statement-like;
this makes it easier for some of them to be recognized by
clang-format and resolves some existing weird formatting.
This commit is contained in:
Adriaan de Groot 2021-03-16 14:55:26 +01:00
parent a90f510b85
commit 9341a84820
20 changed files with 44 additions and 42 deletions

View File

@ -134,9 +134,10 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug,
{
QPushButton* debugWindowBtn = new QPushButton;
debugWindowBtn->setObjectName( "debugButton" );
CALAMARES_RETRANSLATE_WIDGET( debugWindowBtn,
debugWindowBtn->setText( QCoreApplication::translate(
CalamaresWindow::staticMetaObject.className(), "Show debug information" ) ); )
CALAMARES_RETRANSLATE_WIDGET(
debugWindowBtn,
debugWindowBtn->setText( QCoreApplication::translate( CalamaresWindow::staticMetaObject.className(),
"Show debug information" ) ); );
sideLayout->addWidget( debugWindowBtn );
debugWindowBtn->setFlat( true );
debugWindowBtn->setCheckable( true );
@ -365,7 +366,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
CALAMARES_RETRANSLATE( const auto* branding = Calamares::Branding::instance();
setWindowTitle( Calamares::Settings::instance()->isSetupMode()
? tr( "%1 Setup Program" ).arg( branding->productName() )
: tr( "%1 Installer" ).arg( branding->productName() ) ); )
: tr( "%1 Installer" ).arg( branding->productName() ) ); );
const Calamares::Branding* const branding = Calamares::Branding::instance();
using ImageEntry = Calamares::Branding::ImageEntry;

View File

@ -213,7 +213,7 @@ DebugWindow::DebugWindow()
}
} );
CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); setWindowTitle( tr( "Debug information" ) ); )
CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); setWindowTitle( tr( "Debug information" ) ); );
}

View File

@ -91,15 +91,16 @@ private:
} // namespace CalamaresUtils
#define CALAMARES_RETRANSLATE( body ) CalamaresUtils::Retranslator::attachRetranslator( this, [=] { body } );
#define CALAMARES_RETRANSLATE( body ) CalamaresUtils::Retranslator::attachRetranslator( this, [=] { body } )
#define CALAMARES_RETRANSLATE_WIDGET( widget, body ) \
CalamaresUtils::Retranslator::attachRetranslator( widget, [=] { body } );
CalamaresUtils::Retranslator::attachRetranslator( widget, [=] { body } )
#define CALAMARES_RETRANSLATE_SLOT( slotfunc ) \
do \
{ \
this->connect( CalamaresUtils::Retranslator::retranslatorFor( this ), \
&CalamaresUtils::Retranslator::languageChange, \
this, \
slotfunc ); \
}
} while ( 0 )
#endif

View File

@ -81,7 +81,7 @@ ViewManager::ViewManager( QObject* parent )
connect( JobQueue::instance(), &JobQueue::failed, this, &ViewManager::onInstallationFailed );
connect( JobQueue::instance(), &JobQueue::finished, this, &ViewManager::next );
CALAMARES_RETRANSLATE_SLOT( &ViewManager::updateButtonLabels )
CALAMARES_RETRANSLATE_SLOT( &ViewManager::updateButtonLabels );
}

View File

@ -43,7 +43,7 @@ SlideshowQML::SlideshowQML( QWidget* parent )
, m_qmlComponent( nullptr )
, m_qmlObject( nullptr )
{
m_qmlShow->setObjectName("qml");
m_qmlShow->setObjectName( "qml" );
CalamaresUtils::registerQmlModels();
@ -53,7 +53,7 @@ SlideshowQML::SlideshowQML( QWidget* parent )
cDebug() << "QML import paths:" << Logger::DebugList( m_qmlShow->engine()->importPathList() );
#if QT_VERSION >= QT_VERSION_CHECK( 5, 10, 0 )
CALAMARES_RETRANSLATE( if ( m_qmlShow ) { m_qmlShow->engine()->retranslate(); } )
CALAMARES_RETRANSLATE( if ( m_qmlShow ) { m_qmlShow->engine()->retranslate(); } );
#endif
if ( Branding::instance()->slideshowAPI() == 2 )
@ -205,7 +205,7 @@ SlideshowPictures::SlideshowPictures( QWidget* parent )
, m_imageIndex( 0 )
, m_images( Branding::instance()->slideshowImages() )
{
m_label->setObjectName("image");
m_label->setObjectName( "image" );
m_label->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_label->setAlignment( Qt::AlignCenter );

View File

@ -99,5 +99,6 @@ void
InteractiveTerminalPage::setCommand( const QString& command )
{
m_command = command;
CALAMARES_RETRANSLATE( m_headerLabel->setText( tr( "Executing script: &nbsp;<code>%1</code>" ).arg( m_command ) ); )
CALAMARES_RETRANSLATE(
m_headerLabel->setText( tr( "Executing script: &nbsp;<code>%1</code>" ).arg( m_command ) ); );
}

View File

@ -70,9 +70,8 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent )
cDebug() << "Variants now" << model->rowCount() << model->currentIndex();
}
connect( ui->buttonRestore, &QPushButton::clicked, [ config = config ] {
config->keyboardModels()->setCurrentIndex();
} );
connect(
ui->buttonRestore, &QPushButton::clicked, [config = config] { config->keyboardModels()->setCurrentIndex(); } );
connect( ui->physicalModelSelector,
QOverload< int >::of( &QComboBox::currentIndexChanged ),
@ -83,25 +82,24 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent )
ui->physicalModelSelector,
&QComboBox::setCurrentIndex );
connect(
ui->layoutSelector->selectionModel(),
&QItemSelectionModel::currentChanged,
[ this ]( const QModelIndex& current ) { m_config->keyboardLayouts()->setCurrentIndex( current.row() ); } );
connect( config->keyboardLayouts(), &KeyboardLayoutModel::currentIndexChanged, [ this ]( int index ) {
connect( ui->layoutSelector->selectionModel(),
&QItemSelectionModel::currentChanged,
[this]( const QModelIndex& current ) { m_config->keyboardLayouts()->setCurrentIndex( current.row() ); } );
connect( config->keyboardLayouts(), &KeyboardLayoutModel::currentIndexChanged, [this]( int index ) {
ui->layoutSelector->setCurrentIndex( m_config->keyboardLayouts()->index( index ) );
m_keyboardPreview->setLayout( m_config->keyboardLayouts()->key( index ) );
m_keyboardPreview->setVariant( m_config->keyboardVariants()->key( m_config->keyboardVariants()->currentIndex() ) );
m_keyboardPreview->setVariant(
m_config->keyboardVariants()->key( m_config->keyboardVariants()->currentIndex() ) );
} );
connect(
ui->variantSelector->selectionModel(),
&QItemSelectionModel::currentChanged,
[ this ]( const QModelIndex& current ) { m_config->keyboardVariants()->setCurrentIndex( current.row() ); } );
connect( config->keyboardVariants(), &KeyboardVariantsModel::currentIndexChanged, [ this ]( int index ) {
connect( ui->variantSelector->selectionModel(),
&QItemSelectionModel::currentChanged,
[this]( const QModelIndex& current ) { m_config->keyboardVariants()->setCurrentIndex( current.row() ); } );
connect( config->keyboardVariants(), &KeyboardVariantsModel::currentIndexChanged, [this]( int index ) {
ui->variantSelector->setCurrentIndex( m_config->keyboardVariants()->index( index ) );
m_keyboardPreview->setVariant( m_config->keyboardVariants()->key( index ) );
} );
CALAMARES_RETRANSLATE_SLOT( &KeyboardPage::retranslate )
CALAMARES_RETRANSLATE_SLOT( &KeyboardPage::retranslate );
}
KeyboardPage::~KeyboardPage()

View File

@ -105,7 +105,7 @@ LicensePage::LicensePage( QWidget* parent )
connect( ui->acceptCheckBox, &QCheckBox::toggled, this, &LicensePage::checkAcceptance );
CALAMARES_RETRANSLATE_SLOT( &LicensePage::retranslate )
CALAMARES_RETRANSLATE_SLOT( &LicensePage::retranslate );
}
void

View File

@ -117,7 +117,7 @@ LocalePage::LocalePage( Config* config, QWidget* parent )
connect( m_localeChangeButton, &QPushButton::clicked, this, &LocalePage::changeLocale );
connect( m_formatsChangeButton, &QPushButton::clicked, this, &LocalePage::changeFormats );
CALAMARES_RETRANSLATE_SLOT( &LocalePage::updateLocaleLabels )
CALAMARES_RETRANSLATE_SLOT( &LocalePage::updateLocaleLabels );
}

View File

@ -37,7 +37,7 @@ NetInstallPage::NetInstallPage( Config* c, QWidget* parent )
connect( c, &Config::statusReady, this, &NetInstallPage::expandGroups );
setPageTitle( nullptr );
CALAMARES_RETRANSLATE_SLOT( &NetInstallPage::retranslate )
CALAMARES_RETRANSLATE_SLOT( &NetInstallPage::retranslate );
}
NetInstallPage::~NetInstallPage() {}

View File

@ -29,7 +29,7 @@ public:
{
m_ui->setupUi( this );
CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); )
CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); );
}
~OEMPage() override;

View File

@ -28,7 +28,7 @@ PackageChooserPage::PackageChooserPage( PackageChooserMode mode, QWidget* parent
m_introduction.screenshot = QPixmap( QStringLiteral( ":/images/no-selection.png" ) );
ui->setupUi( this );
CALAMARES_RETRANSLATE( updateLabels(); )
CALAMARES_RETRANSLATE( updateLabels(); );
switch ( mode )
{

View File

@ -85,7 +85,7 @@ PlasmaLnfPage::PlasmaLnfPage( Config* config, QWidget* parent )
"You can also skip this step and configure the look-and-feel "
"once the system is installed. Clicking on a look-and-feel "
"selection will give you a live preview of that look-and-feel." ) );
} )
} );
auto* view = new QListView( this );
view->setModel( m_config->themeModel() );

View File

@ -48,7 +48,7 @@ SummaryPage::SummaryPage( const SummaryViewStep* thisViewStep, QWidget* parent )
headerLabel->setText( tr( "This is an overview of what will happen once you start "
"the setup procedure." ) );
else headerLabel->setText( tr( "This is an overview of what will happen once you start "
"the install procedure." ) ); )
"the install procedure." ) ); );
layout->addWidget( headerLabel );
layout->addWidget( m_scrollArea );
m_scrollArea->setWidgetResizable( true );

View File

@ -28,7 +28,7 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent )
, ui( new Ui::TrackingPage )
{
ui->setupUi( this );
CALAMARES_RETRANSLATE_SLOT( &TrackingPage::retranslate )
CALAMARES_RETRANSLATE_SLOT( &TrackingPage::retranslate );
ui->noneCheckBox->setChecked( true );
ui->noneCheckBox->setEnabled( false );

View File

@ -140,7 +140,7 @@ UsersPage::UsersPage( Config* config, QWidget* parent )
config, &Config::requireStrongPasswordsChanged, ui->checkBoxRequireStrongPassword, &QCheckBox::setChecked );
}
CALAMARES_RETRANSLATE_SLOT( &UsersPage::retranslate )
CALAMARES_RETRANSLATE_SLOT( &UsersPage::retranslate );
onReuseUserPasswordChanged( m_config->reuseUserPasswordForRoot() );
onFullNameTextEdited( m_config->fullName() );

View File

@ -30,7 +30,7 @@ Config::Config( QObject* parent )
{
initLanguages();
CALAMARES_RETRANSLATE_SLOT( &Config::retranslate )
CALAMARES_RETRANSLATE_SLOT( &Config::retranslate );
}
void

View File

@ -75,7 +75,7 @@ WelcomePage::WelcomePage( Config* conf, QWidget* parent )
initLanguages();
CALAMARES_RETRANSLATE_SLOT( &WelcomePage::retranslate )
CALAMARES_RETRANSLATE_SLOT( &WelcomePage::retranslate );
connect( ui->aboutButton, &QPushButton::clicked, this, &WelcomePage::showAboutBox );
connect( Calamares::ModuleManager::instance(),

View File

@ -34,7 +34,8 @@ CheckerContainer::CheckerContainer( const Calamares::RequirementsModel& model, Q
CalamaresUtils::unmarginLayout( mainLayout );
mainLayout->addWidget( m_waitingWidget );
CALAMARES_RETRANSLATE( if ( m_waitingWidget ) m_waitingWidget->setText( tr( "Gathering system information..." ) ); )
CALAMARES_RETRANSLATE( if ( m_waitingWidget )
m_waitingWidget->setText( tr( "Gathering system information..." ) ); );
}
CheckerContainer::~CheckerContainer()

View File

@ -121,7 +121,7 @@ ResultsListDialog::ResultsListDialog( const Calamares::RequirementsModel& model,
connect( buttonBox, &QDialogButtonBox::clicked, this, &QDialog::close );
CALAMARES_RETRANSLATE_SLOT( &ResultsListDialog::retranslate )
CALAMARES_RETRANSLATE_SLOT( &ResultsListDialog::retranslate );
retranslate(); // Do it now to fill in the texts
}
@ -216,7 +216,7 @@ ResultsListWidget::ResultsListWidget( const Calamares::RequirementsModel& model,
m_explanation->setAlignment( Qt::AlignCenter );
}
CALAMARES_RETRANSLATE_SLOT( &ResultsListWidget::retranslate )
CALAMARES_RETRANSLATE_SLOT( &ResultsListWidget::retranslate );
retranslate();
}