From 9341a848201dd11559bc126699ab292bff227acf Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 16 Mar 2021 14:55:26 +0100 Subject: [PATCH] [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. --- src/calamares/CalamaresWindow.cpp | 9 +++--- src/calamares/DebugWindow.cpp | 2 +- src/libcalamares/utils/Retranslator.h | 7 +++-- src/libcalamaresui/ViewManager.cpp | 2 +- src/libcalamaresui/viewpages/Slideshow.cpp | 6 ++-- .../InteractiveTerminalPage.cpp | 3 +- src/modules/keyboard/KeyboardPage.cpp | 28 +++++++++---------- src/modules/license/LicensePage.cpp | 2 +- src/modules/locale/LocalePage.cpp | 2 +- src/modules/netinstall/NetInstallPage.cpp | 2 +- src/modules/oemid/OEMViewStep.cpp | 2 +- .../packagechooser/PackageChooserPage.cpp | 2 +- src/modules/plasmalnf/PlasmaLnfPage.cpp | 2 +- src/modules/summary/SummaryPage.cpp | 2 +- src/modules/tracking/TrackingPage.cpp | 2 +- src/modules/users/UsersPage.cpp | 2 +- src/modules/welcome/Config.cpp | 2 +- src/modules/welcome/WelcomePage.cpp | 2 +- .../welcome/checker/CheckerContainer.cpp | 3 +- .../welcome/checker/ResultsListWidget.cpp | 4 +-- 20 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index c37ad97d7..d85d0de74 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -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; diff --git a/src/calamares/DebugWindow.cpp b/src/calamares/DebugWindow.cpp index ba5171437..45e28878c 100644 --- a/src/calamares/DebugWindow.cpp +++ b/src/calamares/DebugWindow.cpp @@ -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" ) ); ); } diff --git a/src/libcalamares/utils/Retranslator.h b/src/libcalamares/utils/Retranslator.h index df38fa4d8..f6169e9aa 100644 --- a/src/libcalamares/utils/Retranslator.h +++ b/src/libcalamares/utils/Retranslator.h @@ -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 diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp index b22d34c88..566a77f93 100644 --- a/src/libcalamaresui/ViewManager.cpp +++ b/src/libcalamaresui/ViewManager.cpp @@ -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 ); } diff --git a/src/libcalamaresui/viewpages/Slideshow.cpp b/src/libcalamaresui/viewpages/Slideshow.cpp index f6df1cae4..6ae5618db 100644 --- a/src/libcalamaresui/viewpages/Slideshow.cpp +++ b/src/libcalamaresui/viewpages/Slideshow.cpp @@ -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 ); diff --git a/src/modules/interactiveterminal/InteractiveTerminalPage.cpp b/src/modules/interactiveterminal/InteractiveTerminalPage.cpp index ea4e3b42e..65818aa03 100644 --- a/src/modules/interactiveterminal/InteractiveTerminalPage.cpp +++ b/src/modules/interactiveterminal/InteractiveTerminalPage.cpp @@ -99,5 +99,6 @@ void InteractiveTerminalPage::setCommand( const QString& command ) { m_command = command; - CALAMARES_RETRANSLATE( m_headerLabel->setText( tr( "Executing script:  %1" ).arg( m_command ) ); ) + CALAMARES_RETRANSLATE( + m_headerLabel->setText( tr( "Executing script:  %1" ).arg( m_command ) ); ); } diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp index 5044d9bb6..902f65f9e 100644 --- a/src/modules/keyboard/KeyboardPage.cpp +++ b/src/modules/keyboard/KeyboardPage.cpp @@ -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() diff --git a/src/modules/license/LicensePage.cpp b/src/modules/license/LicensePage.cpp index 1a92e9ac1..cb5481a1e 100644 --- a/src/modules/license/LicensePage.cpp +++ b/src/modules/license/LicensePage.cpp @@ -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 diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index e296b790b..f63aed10d 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -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 ); } diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index 75175a941..3addf86b3 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -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() {} diff --git a/src/modules/oemid/OEMViewStep.cpp b/src/modules/oemid/OEMViewStep.cpp index f996d4ff3..0c1bdd1d8 100644 --- a/src/modules/oemid/OEMViewStep.cpp +++ b/src/modules/oemid/OEMViewStep.cpp @@ -29,7 +29,7 @@ public: { m_ui->setupUi( this ); - CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); ) + CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); ); } ~OEMPage() override; diff --git a/src/modules/packagechooser/PackageChooserPage.cpp b/src/modules/packagechooser/PackageChooserPage.cpp index e46809fdd..020365a7f 100644 --- a/src/modules/packagechooser/PackageChooserPage.cpp +++ b/src/modules/packagechooser/PackageChooserPage.cpp @@ -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 ) { diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 0e7f05e43..a4de6cc47 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -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() ); diff --git a/src/modules/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp index 96781c25e..3dd797be0 100644 --- a/src/modules/summary/SummaryPage.cpp +++ b/src/modules/summary/SummaryPage.cpp @@ -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 ); diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp index ffdb8be66..727efebbd 100644 --- a/src/modules/tracking/TrackingPage.cpp +++ b/src/modules/tracking/TrackingPage.cpp @@ -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 ); diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp index 0e86931c1..04554454c 100644 --- a/src/modules/users/UsersPage.cpp +++ b/src/modules/users/UsersPage.cpp @@ -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() ); diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 72e1cfc3b..097126ea6 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -30,7 +30,7 @@ Config::Config( QObject* parent ) { initLanguages(); - CALAMARES_RETRANSLATE_SLOT( &Config::retranslate ) + CALAMARES_RETRANSLATE_SLOT( &Config::retranslate ); } void diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index aa9e9d7bb..616c91bff 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -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(), diff --git a/src/modules/welcome/checker/CheckerContainer.cpp b/src/modules/welcome/checker/CheckerContainer.cpp index 0dcd820a3..eb3416ce5 100644 --- a/src/modules/welcome/checker/CheckerContainer.cpp +++ b/src/modules/welcome/checker/CheckerContainer.cpp @@ -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() diff --git a/src/modules/welcome/checker/ResultsListWidget.cpp b/src/modules/welcome/checker/ResultsListWidget.cpp index b0e8a175e..c04d2a48b 100644 --- a/src/modules/welcome/checker/ResultsListWidget.cpp +++ b/src/modules/welcome/checker/ResultsListWidget.cpp @@ -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(); }