From 874a0c1f38b0da4e5bc83083b13a63b1c7eed935 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 12:44:55 +0200 Subject: [PATCH] CI: apply coding style globally again --- src/calamares/CalamaresApplication.cpp | 3 +- src/calamares/CalamaresWindow.cpp | 13 +- src/calamares/DebugWindow.cpp | 168 ++++++++++-------- .../progresstree/ProgressTreeView.cpp | 2 +- src/libcalamares/JobQueue.cpp | 7 +- src/libcalamares/PythonJobApi.cpp | 8 +- src/libcalamares/Settings.cpp | 2 +- src/libcalamares/Tests.cpp | 5 +- src/libcalamares/geoip/Handler.cpp | 4 +- src/libcalamares/locale/Lookup.cpp | 8 +- src/libcalamares/locale/TimeZone.cpp | 29 +-- src/libcalamares/modulesystem/Preset.cpp | 2 +- .../modulesystem/RequirementsChecker.cpp | 25 +-- src/libcalamares/packages/Tests.cpp | 2 +- src/libcalamares/partition/KPMManager.cpp | 4 +- .../partition/PartitionIterator.cpp | 3 +- src/libcalamares/utils/RAII.h | 2 +- src/libcalamares/utils/Retranslator.h | 4 +- src/libcalamares/utils/Runner.cpp | 23 +-- src/libcalamares/utils/Tests.cpp | 2 +- .../modulesystem/PythonQtViewModule.cpp | 12 +- src/libcalamaresui/utils/Qml.cpp | 40 +++-- src/modules/finished/FinishedPage.cpp | 19 +- src/modules/keyboard/Config.cpp | 28 +-- src/modules/keyboard/KeyboardLayoutModel.cpp | 8 +- src/modules/keyboard/KeyboardPage.cpp | 37 ++-- src/modules/locale/Config.cpp | 52 +++--- src/modules/locale/LCLocaleDialog.cpp | 23 +-- .../locale/timezonewidget/timezonewidget.cpp | 7 +- src/modules/netinstall/NetInstallPage.cpp | 11 +- src/modules/netinstall/groupstreeview.cpp | 13 +- src/modules/netinstall/groupstreeview.h | 2 +- .../packagechooser/PackageChooserViewStep.cpp | 6 +- src/modules/plasmalnf/PlasmaLnfPage.cpp | 3 +- src/modules/tracking/TrackingPage.cpp | 49 ++--- src/modules/users/CheckPWQuality.cpp | 9 +- src/modules/welcome/WelcomePage.cpp | 2 +- .../welcome/checker/GeneralRequirements.cpp | 18 +- .../welcome/checker/ResultsListWidget.cpp | 14 +- 39 files changed, 376 insertions(+), 293 deletions(-) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 6c3eed6d1..c06e13aa3 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -67,8 +67,7 @@ CalamaresApplication::init() { Logger::setupLogfile(); cDebug() << "Calamares version:" << CALAMARES_VERSION; - cDebug() << Logger::SubEntry - << "languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).replace( ";", ", " ); + cDebug() << Logger::SubEntry << "languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).replace( ";", ", " ); if ( !Calamares::Settings::instance() ) { diff --git a/src/calamares/CalamaresWindow.cpp b/src/calamares/CalamaresWindow.cpp index d95b87933..81e7ca97f 100644 --- a/src/calamares/CalamaresWindow.cpp +++ b/src/calamares/CalamaresWindow.cpp @@ -134,10 +134,9 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug, { QPushButton* debugWindowBtn = new QPushButton; debugWindowBtn->setObjectName( "debugButton" ); - CALAMARES_RETRANSLATE_FOR( - debugWindowBtn, - debugWindowBtn->setText( QCoreApplication::translate( CalamaresWindow::staticMetaObject.className(), - "Show debug information" ) ); ); + CALAMARES_RETRANSLATE_FOR( debugWindowBtn, + debugWindowBtn->setText( QCoreApplication::translate( + CalamaresWindow::staticMetaObject.className(), "Show debug information" ) ); ); sideLayout->addWidget( debugWindowBtn ); debugWindowBtn->setFlat( true ); debugWindowBtn->setCheckable( true ); @@ -173,7 +172,7 @@ getWidgetNavigation( Calamares::DebugWindowManager*, QObject::connect( viewManager, &Calamares::ViewManager::backEnabledChanged, back, &QPushButton::setEnabled ); QObject::connect( viewManager, &Calamares::ViewManager::backLabelChanged, back, &QPushButton::setText ); QObject::connect( - viewManager, &Calamares::ViewManager::backIconChanged, [=]( QString n ) { setButtonIcon( back, n ); } ); + viewManager, &Calamares::ViewManager::backIconChanged, [ = ]( QString n ) { setButtonIcon( back, n ); } ); QObject::connect( viewManager, &Calamares::ViewManager::backAndNextVisibleChanged, back, &QPushButton::setVisible ); bottomLayout->addWidget( back ); @@ -189,7 +188,7 @@ getWidgetNavigation( Calamares::DebugWindowManager*, QObject::connect( viewManager, &Calamares::ViewManager::nextEnabledChanged, next, &QPushButton::setEnabled ); QObject::connect( viewManager, &Calamares::ViewManager::nextLabelChanged, next, &QPushButton::setText ); QObject::connect( - viewManager, &Calamares::ViewManager::nextIconChanged, [=]( QString n ) { setButtonIcon( next, n ); } ); + viewManager, &Calamares::ViewManager::nextIconChanged, [ = ]( QString n ) { setButtonIcon( next, n ); } ); QObject::connect( viewManager, &Calamares::ViewManager::backAndNextVisibleChanged, next, &QPushButton::setVisible ); bottomLayout->addWidget( next ); @@ -205,7 +204,7 @@ getWidgetNavigation( Calamares::DebugWindowManager*, QObject::connect( viewManager, &Calamares::ViewManager::quitEnabledChanged, quit, &QPushButton::setEnabled ); QObject::connect( viewManager, &Calamares::ViewManager::quitLabelChanged, quit, &QPushButton::setText ); QObject::connect( - viewManager, &Calamares::ViewManager::quitIconChanged, [=]( QString n ) { setButtonIcon( quit, n ); } ); + viewManager, &Calamares::ViewManager::quitIconChanged, [ = ]( QString n ) { setButtonIcon( quit, n ); } ); QObject::connect( viewManager, &Calamares::ViewManager::quitTooltipChanged, quit, &QPushButton::setToolTip ); QObject::connect( viewManager, &Calamares::ViewManager::quitVisibleChanged, quit, &QPushButton::setVisible ); bottomLayout->addWidget( quit ); diff --git a/src/calamares/DebugWindow.cpp b/src/calamares/DebugWindow.cpp index b5fd899d4..8813999a4 100644 --- a/src/calamares/DebugWindow.cpp +++ b/src/calamares/DebugWindow.cpp @@ -85,17 +85,22 @@ DebugWindow::DebugWindow() m_ui->globalStorageView->expandAll(); // Do above when the GS changes, too - connect( gs, &GlobalStorage::changed, this, [=] { - m_globals = JobQueue::instance()->globalStorage()->data(); - m_globals_model->reload(); - m_ui->globalStorageView->expandAll(); - } ); + connect( gs, + &GlobalStorage::changed, + this, + [ = ] + { + m_globals = JobQueue::instance()->globalStorage()->data(); + m_globals_model->reload(); + m_ui->globalStorageView->expandAll(); + } ); // JobQueue page m_ui->jobQueueText->setReadOnly( true ); - connect( JobQueue::instance(), &JobQueue::queueChanged, this, [this]( const QStringList& jobs ) { - m_ui->jobQueueText->setText( jobs.join( '\n' ) ); - } ); + connect( JobQueue::instance(), + &JobQueue::queueChanged, + this, + [ this ]( const QStringList& jobs ) { m_ui->jobQueueText->setText( jobs.join( '\n' ) ); } ); // Modules page QStringList modulesKeys; @@ -116,67 +121,74 @@ DebugWindow::DebugWindow() m_ui->modulesVerticalLayout->insertWidget( 1, pythonConsoleButton ); pythonConsoleButton->hide(); - QObject::connect( pythonConsoleButton, &QPushButton::clicked, this, [this, moduleConfigModel] { - QString moduleName = m_ui->modulesListView->currentIndex().data().toString(); - Module* module = ModuleManager::instance()->moduleInstance( moduleName ); - if ( module->interface() != Module::Interface::PythonQt || module->type() != Module::Type::View ) - return; - - for ( ViewStep* step : ViewManager::instance()->viewSteps() ) + QObject::connect( + pythonConsoleButton, + &QPushButton::clicked, + this, + [ this, moduleConfigModel ] { - if ( step->moduleInstanceKey() == module->instanceKey() ) + QString moduleName = m_ui->modulesListView->currentIndex().data().toString(); + Module* module = ModuleManager::instance()->moduleInstance( moduleName ); + if ( module->interface() != Module::Interface::PythonQt || module->type() != Module::Type::View ) + return; + + for ( ViewStep* step : ViewManager::instance()->viewSteps() ) { - PythonQtViewStep* pqvs = qobject_cast< PythonQtViewStep* >( step ); - if ( pqvs ) + if ( step->moduleInstanceKey() == module->instanceKey() ) { - QWidget* consoleWindow = new QWidget; + PythonQtViewStep* pqvs = qobject_cast< PythonQtViewStep* >( step ); + if ( pqvs ) + { + QWidget* consoleWindow = new QWidget; - QWidget* console = pqvs->createScriptingConsole(); - console->setParent( consoleWindow ); + QWidget* console = pqvs->createScriptingConsole(); + console->setParent( consoleWindow ); - QVBoxLayout* layout = new QVBoxLayout; - consoleWindow->setLayout( layout ); - layout->addWidget( console ); + QVBoxLayout* layout = new QVBoxLayout; + consoleWindow->setLayout( layout ); + layout->addWidget( console ); - QHBoxLayout* bottomLayout = new QHBoxLayout; - layout->addLayout( bottomLayout ); + QHBoxLayout* bottomLayout = new QHBoxLayout; + layout->addLayout( bottomLayout ); - QLabel* bottomLabel = new QLabel( consoleWindow ); - bottomLayout->addWidget( bottomLabel ); - QString line = QString( "Module: %1
" - "Python class: %2" ) - .arg( module->instanceKey() ) - .arg( console->property( "classname" ).toString() ); - bottomLabel->setText( line ); + QLabel* bottomLabel = new QLabel( consoleWindow ); + bottomLayout->addWidget( bottomLabel ); + QString line = QString( "Module: %1
" + "Python class: %2" ) + .arg( module->instanceKey() ) + .arg( console->property( "classname" ).toString() ); + bottomLabel->setText( line ); - QPushButton* closeButton = new QPushButton( consoleWindow ); - closeButton->setText( "&Close" ); - QObject::connect( closeButton, &QPushButton::clicked, [consoleWindow] { consoleWindow->close(); } ); - bottomLayout->addWidget( closeButton ); - bottomLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); + QPushButton* closeButton = new QPushButton( consoleWindow ); + closeButton->setText( "&Close" ); + QObject::connect( + closeButton, &QPushButton::clicked, [ consoleWindow ] { consoleWindow->close(); } ); + bottomLayout->addWidget( closeButton ); + bottomLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); - consoleWindow->setParent( this ); - consoleWindow->setWindowFlags( Qt::Window ); - consoleWindow->setWindowTitle( "Calamares Python console" ); - consoleWindow->setAttribute( Qt::WA_DeleteOnClose, true ); - consoleWindow->showNormal(); - break; + consoleWindow->setParent( this ); + consoleWindow->setWindowFlags( Qt::Window ); + consoleWindow->setWindowTitle( "Calamares Python console" ); + consoleWindow->setAttribute( Qt::WA_DeleteOnClose, true ); + consoleWindow->showNormal(); + break; + } } } - } - } ); + } ); #endif connect( m_ui->modulesListView->selectionModel(), &QItemSelectionModel::selectionChanged, this, - [this + [ this #ifdef WITH_PYTHONQT - , - pythonConsoleButton + , + pythonConsoleButton #endif - ] { + ] + { QString moduleName = m_ui->modulesListView->currentIndex().data().toString(); Module* module = ModuleManager::instance()->moduleInstance( ModuleSystem::InstanceKey::fromString( moduleName ) ); @@ -196,27 +208,33 @@ DebugWindow::DebugWindow() // Tools page connect( m_ui->crashButton, &QPushButton::clicked, this, [] { ::crash(); } ); - connect( m_ui->reloadStylesheetButton, &QPushButton::clicked, []() { - for ( auto* w : qApp->topLevelWidgets() ) - { - // Needs to match what's set in CalamaresWindow - if ( w->objectName() == QStringLiteral( "mainApp" ) ) - { - w->setStyleSheet( Calamares::Branding::instance()->stylesheet() ); - } - } - } ); - connect( m_ui->widgetTreeButton, &QPushButton::clicked, []() { - for ( auto* w : qApp->topLevelWidgets() ) - { - Logger::CDebug deb; - dumpWidgetTree( deb, w, 0 ); - } - } ); + connect( m_ui->reloadStylesheetButton, + &QPushButton::clicked, + []() + { + for ( auto* w : qApp->topLevelWidgets() ) + { + // Needs to match what's set in CalamaresWindow + if ( w->objectName() == QStringLiteral( "mainApp" ) ) + { + w->setStyleSheet( Calamares::Branding::instance()->stylesheet() ); + } + } + } ); + connect( m_ui->widgetTreeButton, + &QPushButton::clicked, + []() + { + for ( auto* w : qApp->topLevelWidgets() ) + { + Logger::CDebug deb; + dumpWidgetTree( deb, w, 0 ); + } + } ); // Send Log button only if it would be useful m_ui->sendLogButton->setVisible( CalamaresUtils::Paste::isEnabled() ); - connect( m_ui->sendLogButton, &QPushButton::clicked, [this]() { CalamaresUtils::Paste::doLogUploadUI( this ); } ); + connect( m_ui->sendLogButton, &QPushButton::clicked, [ this ]() { CalamaresUtils::Paste::doLogUploadUI( this ); } ); CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); setWindowTitle( tr( "Debug information" ) ); ); } @@ -260,11 +278,15 @@ DebugWindowManager::show( bool visible ) { m_debugWindow = new Calamares::DebugWindow(); m_debugWindow->show(); - connect( m_debugWindow.data(), &Calamares::DebugWindow::closed, this, [=]() { - m_debugWindow->deleteLater(); - m_visible = false; - emit visibleChanged( false ); - } ); + connect( m_debugWindow.data(), + &Calamares::DebugWindow::closed, + this, + [ = ]() + { + m_debugWindow->deleteLater(); + m_visible = false; + emit visibleChanged( false ); + } ); m_visible = true; emit visibleChanged( true ); } diff --git a/src/calamares/progresstree/ProgressTreeView.cpp b/src/calamares/progresstree/ProgressTreeView.cpp index b953db64d..900dd5028 100644 --- a/src/calamares/progresstree/ProgressTreeView.cpp +++ b/src/calamares/progresstree/ProgressTreeView.cpp @@ -51,6 +51,6 @@ ProgressTreeView::setModel( QAbstractItemModel* model ) Calamares::ViewManager::instance(), &Calamares::ViewManager::currentStepChanged, this, - [this]() { viewport()->update(); }, + [ this ]() { viewport()->update(); }, Qt::UniqueConnection ); } diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index d7078c6d2..e15df345e 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -89,9 +89,10 @@ public: = m_queuedJobs->isEmpty() ? 0.0 : ( m_queuedJobs->last().cumulative + m_queuedJobs->last().weight ); qreal totalJobWeight - = std::accumulate( jobs.cbegin(), jobs.cend(), qreal( 0.0 ), []( qreal total, const job_ptr& j ) { - return total + j->getJobWeight(); - } ); + = std::accumulate( jobs.cbegin(), + jobs.cend(), + qreal( 0.0 ), + []( qreal total, const job_ptr& j ) { return total + j->getJobWeight(); } ); if ( totalJobWeight < 1 ) { totalJobWeight = 1.0; diff --git a/src/libcalamares/PythonJobApi.cpp b/src/libcalamares/PythonJobApi.cpp index c95edfb63..3532d8f32 100644 --- a/src/libcalamares/PythonJobApi.cpp +++ b/src/libcalamares/PythonJobApi.cpp @@ -211,14 +211,14 @@ _process_output( Calamares::Utils::RunLocation location, bp::extract< bp::list > x( callback ); if ( x.check() ) { - QObject::connect( &r, &decltype( r )::output, [cb = callback.attr( "append" )]( const QString& s ) { - cb( s.toStdString() ); - } ); + QObject::connect( &r, + &decltype( r )::output, + [ cb = callback.attr( "append" ) ]( const QString& s ) { cb( s.toStdString() ); } ); } else { QObject::connect( - &r, &decltype( r )::output, [&callback]( const QString& s ) { callback( s.toStdString() ); } ); + &r, &decltype( r )::output, [ &callback ]( const QString& s ) { callback( s.toStdString() ); } ); } r.enableOutputProcessing(); } diff --git a/src/libcalamares/Settings.cpp b/src/libcalamares/Settings.cpp index d494d98bc..2ce85ec8d 100644 --- a/src/libcalamares/Settings.cpp +++ b/src/libcalamares/Settings.cpp @@ -290,7 +290,7 @@ Settings::reconcileInstancesAndSequence() // Since moduleFinder captures targetKey by reference, we can // update targetKey to change what the finder lambda looks for. Calamares::ModuleSystem::InstanceKey targetKey; - auto moduleFinder = [&targetKey]( const InstanceDescription& d ) { return d.isValid() && d.key() == targetKey; }; + auto moduleFinder = [ &targetKey ]( const InstanceDescription& d ) { return d.isValid() && d.key() == targetKey; }; // Check the sequence against the existing instances (which so far are only custom) for ( const auto& step : m_modulesSequence ) diff --git a/src/libcalamares/Tests.cpp b/src/libcalamares/Tests.cpp index bde7ac0d3..51fd92a2f 100644 --- a/src/libcalamares/Tests.cpp +++ b/src/libcalamares/Tests.cpp @@ -425,9 +425,8 @@ sequence: // Make a lambda where we can adjust what it looks for from the outside, // by capturing a reference. QString moduleKey = QString( "welcome" ); - auto moduleFinder = [&moduleKey]( const Calamares::InstanceDescription& d ) { - return d.isValid() && d.key().module() == moduleKey; - }; + auto moduleFinder = [ &moduleKey ]( const Calamares::InstanceDescription& d ) + { return d.isValid() && d.key().module() == moduleKey; }; const auto it0 = std::find_if( s.moduleInstances().constBegin(), s.moduleInstances().constEnd(), moduleFinder ); QVERIFY( it0 != s.moduleInstances().constEnd() ); diff --git a/src/libcalamares/geoip/Handler.cpp b/src/libcalamares/geoip/Handler.cpp index 8ef72d99b..14de9f39c 100644 --- a/src/libcalamares/geoip/Handler.cpp +++ b/src/libcalamares/geoip/Handler.cpp @@ -150,7 +150,7 @@ Handler::query() const QString url = m_url; QString selector = m_selector; - return QtConcurrent::run( [=] { return do_query( type, url, selector ); } ); + return QtConcurrent::run( [ = ] { return do_query( type, url, selector ); } ); } QString @@ -171,7 +171,7 @@ Handler::queryRaw() const QString url = m_url; QString selector = m_selector; - return QtConcurrent::run( [=] { return do_raw_query( type, url, selector ); } ); + return QtConcurrent::run( [ = ] { return do_raw_query( type, url, selector ); } ); } } // namespace GeoIP diff --git a/src/libcalamares/locale/Lookup.cpp b/src/libcalamares/locale/Lookup.cpp index f792f08ed..3dba50898 100644 --- a/src/libcalamares/locale/Lookup.cpp +++ b/src/libcalamares/locale/Lookup.cpp @@ -43,9 +43,9 @@ lookup( TwoChar c ) } const CountryData* p - = std::find_if( country_data_table, country_data_table + country_data_size, [c = c]( const CountryData& d ) { - return ( d.cc1 == c.cc1 ) && ( d.cc2 == c.cc2 ); - } ); + = std::find_if( country_data_table, + country_data_table + country_data_size, + [ c = c ]( const CountryData& d ) { return ( d.cc1 == c.cc1 ) && ( d.cc2 == c.cc2 ); } ); if ( p == country_data_table + country_data_size ) { return nullptr; @@ -86,7 +86,7 @@ languageForCountry( QLocale::Country country ) { const CountryData* p = std::find_if( country_data_table, country_data_table + country_data_size, - [c = country]( const CountryData& d ) { return d.c == c; } ); + [ c = country ]( const CountryData& d ) { return d.c == c; } ); if ( p == country_data_table + country_data_size ) { return QLocale::Language::AnyLanguage; diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index b9dbac5ee..c0804ebd6 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -224,16 +224,19 @@ public: loadTZData( m_regions, m_altZones, in ); } - std::sort( m_regions.begin(), m_regions.end(), []( const RegionData* lhs, const RegionData* rhs ) { - return lhs->key() < rhs->key(); - } ); - std::sort( m_zones.begin(), m_zones.end(), []( const TimeZoneData* lhs, const TimeZoneData* rhs ) { - if ( lhs->region() == rhs->region() ) - { - return lhs->zone() < rhs->zone(); - } - return lhs->region() < rhs->region(); - } ); + std::sort( m_regions.begin(), + m_regions.end(), + []( const RegionData* lhs, const RegionData* rhs ) { return lhs->key() < rhs->key(); } ); + std::sort( m_zones.begin(), + m_zones.end(), + []( const TimeZoneData* lhs, const TimeZoneData* rhs ) + { + if ( lhs->region() == rhs->region() ) + { + return lhs->zone() < rhs->zone(); + } + return lhs->region() < rhs->region(); + } ); for ( auto* z : m_zones ) { @@ -399,7 +402,8 @@ ZonesModel::find( double latitude, double longitude ) const * either N/S or E/W equal to any other; this obviously * falls apart at the poles. */ - auto distance = [&]( const TimeZoneData* zone ) -> double { + auto distance = [ & ]( const TimeZoneData* zone ) -> double + { // Latitude doesn't wrap around: there is nothing north of 90 double latitudeDifference = abs( zone->latitude() - latitude ); @@ -445,7 +449,8 @@ ZonesModel::Iterator::operator bool() const return 0 <= m_index && m_index < m_p->m_zones.count(); } -const TimeZoneData* ZonesModel::Iterator::operator*() const +const TimeZoneData* +ZonesModel::Iterator::operator*() const { if ( *this ) { diff --git a/src/libcalamares/modulesystem/Preset.cpp b/src/libcalamares/modulesystem/Preset.cpp index a2e3f3264..1c5779afe 100644 --- a/src/libcalamares/modulesystem/Preset.cpp +++ b/src/libcalamares/modulesystem/Preset.cpp @@ -47,7 +47,7 @@ Presets::Presets( const QVariantMap& configurationMap, const QStringList& recogn { reserve( recognizedKeys.size() ); loadPresets( - *this, configurationMap, [&recognizedKeys]( const QString& s ) { return recognizedKeys.contains( s ); } ); + *this, configurationMap, [ &recognizedKeys ]( const QString& s ) { return recognizedKeys.contains( s ); } ); } bool diff --git a/src/libcalamares/modulesystem/RequirementsChecker.cpp b/src/libcalamares/modulesystem/RequirementsChecker.cpp index 32c7254de..3d3e16172 100644 --- a/src/libcalamares/modulesystem/RequirementsChecker.cpp +++ b/src/libcalamares/modulesystem/RequirementsChecker.cpp @@ -63,9 +63,9 @@ RequirementsChecker::finished() static QMutex finishedMutex; QMutexLocker lock( &finishedMutex ); - if ( m_progressTimer && std::all_of( m_watchers.cbegin(), m_watchers.cend(), []( const Watcher* w ) { - return w && w->isFinished(); - } ) ) + if ( m_progressTimer + && std::all_of( + m_watchers.cbegin(), m_watchers.cend(), []( const Watcher* w ) { return w && w->isFinished(); } ) ) { cDebug() << "All requirements have been checked."; if ( m_progressTimer ) @@ -100,14 +100,17 @@ RequirementsChecker::reportProgress() m_progressTimeouts++; QStringList remainingNames; - auto remaining = std::count_if( m_watchers.cbegin(), m_watchers.cend(), [&]( const Watcher* w ) { - if ( w && !w->isFinished() ) - { - remainingNames << w->objectName(); - return true; - } - return false; - } ); + auto remaining = std::count_if( m_watchers.cbegin(), + m_watchers.cend(), + [ & ]( const Watcher* w ) + { + if ( w && !w->isFinished() ) + { + remainingNames << w->objectName(); + return true; + } + return false; + } ); if ( remaining > 0 ) { cDebug() << "Remaining modules:" << remaining << Logger::DebugList( remainingNames ); diff --git a/src/libcalamares/packages/Tests.cpp b/src/libcalamares/packages/Tests.cpp index 09159abdf..a0422cb36 100644 --- a/src/libcalamares/packages/Tests.cpp +++ b/src/libcalamares/packages/Tests.cpp @@ -140,7 +140,7 @@ PackagesTests::testAdd() { // This is the "original" instance, so it's missing extraEditor auto op = action[ "install" ].toList(); - QCOMPARE( op.length(), packages.length()-1 ); // changed from original length + QCOMPARE( op.length(), packages.length() - 1 ); // changed from original length QVERIFY( !op.contains( extraEditor ) ); } } diff --git a/src/libcalamares/partition/KPMManager.cpp b/src/libcalamares/partition/KPMManager.cpp index ff7701703..8031030b1 100644 --- a/src/libcalamares/partition/KPMManager.cpp +++ b/src/libcalamares/partition/KPMManager.cpp @@ -102,9 +102,7 @@ KPMManager::KPMManager() { } -KPMManager::~KPMManager() -{ -} +KPMManager::~KPMManager() {} KPMManager::operator bool() const { diff --git a/src/libcalamares/partition/PartitionIterator.cpp b/src/libcalamares/partition/PartitionIterator.cpp index 7c68e6170..8b4556f7f 100644 --- a/src/libcalamares/partition/PartitionIterator.cpp +++ b/src/libcalamares/partition/PartitionIterator.cpp @@ -29,7 +29,8 @@ PartitionIterator::PartitionIterator( PartitionTable* table ) { } -Partition* PartitionIterator::operator*() const +Partition* +PartitionIterator::operator*() const { return m_current; } diff --git a/src/libcalamares/utils/RAII.h b/src/libcalamares/utils/RAII.h index 957e4fe42..8d4a9073b 100644 --- a/src/libcalamares/utils/RAII.h +++ b/src/libcalamares/utils/RAII.h @@ -108,5 +108,5 @@ struct cScopedAssignment }; template < typename T > -cScopedAssignment( T p )->cScopedAssignment< decltype( *p ) >; +cScopedAssignment( T p ) -> cScopedAssignment< decltype( *p ) >; #endif diff --git a/src/libcalamares/utils/Retranslator.h b/src/libcalamares/utils/Retranslator.h index 8bb044983..94eba8b1c 100644 --- a/src/libcalamares/utils/Retranslator.h +++ b/src/libcalamares/utils/Retranslator.h @@ -116,7 +116,7 @@ private: * immediately after setting up the connection. This allows * setup and translation code to be mixed together. */ -#define CALAMARES_RETRANSLATE( body ) CalamaresUtils::Retranslator::attach( this, [=] { body } ) +#define CALAMARES_RETRANSLATE( body ) CalamaresUtils::Retranslator::attach( this, [ = ] { body } ) /** @brief Call code for the given object (widget) when language changes * * This is identical to CALAMARES_RETRANSLATE, except the @p body is called @@ -126,7 +126,7 @@ private: * immediately after setting up the connection. This allows * setup and translation code to be mixed together. */ -#define CALAMARES_RETRANSLATE_FOR( object, body ) CalamaresUtils::Retranslator::attach( object, [=] { body } ) +#define CALAMARES_RETRANSLATE_FOR( object, body ) CalamaresUtils::Retranslator::attach( object, [ = ] { body } ) /** @brief Call a slot in this object when language changes * * Given a slot (in method-function-pointer notation), call that slot when the diff --git a/src/libcalamares/utils/Runner.cpp b/src/libcalamares/utils/Runner.cpp index c7146c2d7..d45836334 100644 --- a/src/libcalamares/utils/Runner.cpp +++ b/src/libcalamares/utils/Runner.cpp @@ -151,16 +151,19 @@ Calamares::Utils::Runner::run() if ( m_output ) { - connect( &process, &QProcess::readyReadStandardOutput, [this, &process]() { - do - { - QString s = process.readLine(); - if ( !s.isEmpty() ) - { - Q_EMIT this->output( s ); - } - } while ( process.canReadLine() ); - } ); + connect( &process, + &QProcess::readyReadStandardOutput, + [ this, &process ]() + { + do + { + QString s = process.readLine(); + if ( !s.isEmpty() ) + { + Q_EMIT this->output( s ); + } + } while ( process.canReadLine() ); + } ); } cDebug() << Logger::SubEntry << "Running" << Logger::RedactedCommand( m_command ); diff --git a/src/libcalamares/utils/Tests.cpp b/src/libcalamares/utils/Tests.cpp index ce1f5d24b..1105915ad 100644 --- a/src/libcalamares/utils/Tests.cpp +++ b/src/libcalamares/utils/Tests.cpp @@ -993,7 +993,7 @@ LibCalamaresTests::testRunnerOutput() Calamares::Utils::Runner r( { "cat" } ); r.enableOutputProcessing().setInput( QStringLiteral( "hello\nworld\n\n!\n" ) ); - QObject::connect( &r, &decltype( r )::output, [&collectedOutput]( QString s ) { collectedOutput << s; } ); + QObject::connect( &r, &decltype( r )::output, [ &collectedOutput ]( QString s ) { collectedOutput << s; } ); { auto result = r.run(); diff --git a/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp b/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp index ae2b2915f..105dd2998 100644 --- a/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp +++ b/src/libcalamaresui/modulesystem/PythonQtViewModule.cpp @@ -97,12 +97,12 @@ PythonQtViewModule::loadSelf() cala.addVariable( "configuration", m_configurationMap ); // Basic stdout/stderr handling - QObject::connect( PythonQt::self(), &PythonQt::pythonStdOut, []( const QString& message ) { - cDebug() << "PythonQt OUT>" << message; - } ); - QObject::connect( PythonQt::self(), &PythonQt::pythonStdErr, []( const QString& message ) { - cDebug() << "PythonQt ERR>" << message; - } ); + QObject::connect( PythonQt::self(), + &PythonQt::pythonStdOut, + []( const QString& message ) { cDebug() << "PythonQt OUT>" << message; } ); + QObject::connect( PythonQt::self(), + &PythonQt::pythonStdErr, + []( const QString& message ) { cDebug() << "PythonQt ERR>" << message; } ); } QDir workingDir( m_workingPath ); diff --git a/src/libcalamaresui/utils/Qml.cpp b/src/libcalamaresui/utils/Qml.cpp index 534b2d3f5..b73bf7172 100644 --- a/src/libcalamaresui/utils/Qml.cpp +++ b/src/libcalamaresui/utils/Qml.cpp @@ -135,14 +135,14 @@ addExpansions( QmlSearch method, QStringList& candidates, const QStringList& nam std::transform( names.constBegin(), names.constEnd(), std::back_inserter( candidates ), - [&]( const QString& s ) { return s.isEmpty() ? QString() : bPath.arg( brandDir, s ); } ); + [ & ]( const QString& s ) { return s.isEmpty() ? QString() : bPath.arg( brandDir, s ); } ); } if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::QrcOnly ) ) { std::transform( names.constBegin(), names.constEnd(), std::back_inserter( candidates ), - [&]( const QString& s ) { return s.isEmpty() ? QString() : qrPath.arg( s ); } ); + [ & ]( const QString& s ) { return s.isEmpty() ? QString() : qrPath.arg( s ); } ); } } @@ -222,22 +222,30 @@ registerQmlModels() // Because branding and viewmanager have a parent (CalamaresApplication // and CalamaresWindow), they will not be deleted by QmlEngine. // https://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership - qmlRegisterSingletonType< Calamares::Branding >( - "io.calamares.ui", 1, 0, "Branding", []( QQmlEngine*, QJSEngine* ) -> QObject* { - return Calamares::Branding::instance(); - } ); - qmlRegisterSingletonType< Calamares::ViewManager >( - "io.calamares.ui", 1, 0, "ViewManager", []( QQmlEngine*, QJSEngine* ) -> QObject* { - return Calamares::ViewManager::instance(); - } ); + qmlRegisterSingletonType< Calamares::Branding >( "io.calamares.ui", + 1, + 0, + "Branding", + []( QQmlEngine*, QJSEngine* ) -> QObject* + { return Calamares::Branding::instance(); } ); + qmlRegisterSingletonType< Calamares::ViewManager >( "io.calamares.ui", + 1, + 0, + "ViewManager", + []( QQmlEngine*, QJSEngine* ) -> QObject* + { return Calamares::ViewManager::instance(); } ); qmlRegisterSingletonType< Calamares::GlobalStorage >( - "io.calamares.core", 1, 0, "Global", []( QQmlEngine*, QJSEngine* ) -> QObject* { - return Calamares::JobQueue::instance()->globalStorage(); - } ); + "io.calamares.core", + 1, + 0, + "Global", + []( QQmlEngine*, QJSEngine* ) -> QObject* { return Calamares::JobQueue::instance()->globalStorage(); } ); qmlRegisterSingletonType< CalamaresUtils::Network::Manager >( - "io.calamares.core", 1, 0, "Network", []( QQmlEngine*, QJSEngine* ) -> QObject* { - return &CalamaresUtils::Network::Manager::instance(); - } ); + "io.calamares.core", + 1, + 0, + "Network", + []( QQmlEngine*, QJSEngine* ) -> QObject* { return &CalamaresUtils::Network::Manager::instance(); } ); } } diff --git a/src/modules/finished/FinishedPage.cpp b/src/modules/finished/FinishedPage.cpp index 6c5f9ad16..949c5f64c 100644 --- a/src/modules/finished/FinishedPage.cpp +++ b/src/modules/finished/FinishedPage.cpp @@ -31,16 +31,19 @@ FinishedPage::FinishedPage( Config* config, QWidget* parent ) ui->mainText->setWordWrap( true ); ui->mainText->setOpenExternalLinks( true ); - connect( config, &Config::restartModeChanged, [this]( Config::RestartMode mode ) { - using Mode = Config::RestartMode; + connect( config, + &Config::restartModeChanged, + [ this ]( Config::RestartMode mode ) + { + using Mode = Config::RestartMode; - ui->restartCheckBox->setVisible( mode != Mode::Never ); - ui->restartCheckBox->setEnabled( mode != Mode::Always ); - } ); + ui->restartCheckBox->setVisible( mode != Mode::Never ); + ui->restartCheckBox->setEnabled( mode != Mode::Always ); + } ); connect( config, &Config::restartNowWantedChanged, ui->restartCheckBox, &QCheckBox::setChecked ); - connect( ui->restartCheckBox, &QCheckBox::stateChanged, [config]( int state ) { - config->setRestartNowWanted( state != 0 ); - } ); + connect( ui->restartCheckBox, + &QCheckBox::stateChanged, + [ config ]( int state ) { config->setRestartNowWanted( state != 0 ); } ); CALAMARES_RETRANSLATE_SLOT( &FinishedPage::retranslate ); } diff --git a/src/modules/keyboard/Config.cpp b/src/modules/keyboard/Config.cpp index 720588810..9afaef5f3 100644 --- a/src/modules/keyboard/Config.cpp +++ b/src/modules/keyboard/Config.cpp @@ -156,18 +156,24 @@ Config::Config( QObject* parent ) m_setxkbmapTimer.setSingleShot( true ); // Connect signals and slots - connect( m_keyboardModelsModel, &KeyboardModelsModel::currentIndexChanged, [&]( int index ) { - // Set Xorg keyboard model - m_selectedModel = m_keyboardModelsModel->key( index ); - QProcess::execute( "setxkbmap", xkbmap_model_args( m_selectedModel ) ); - emit prettyStatusChanged(); - } ); + connect( m_keyboardModelsModel, + &KeyboardModelsModel::currentIndexChanged, + [ & ]( int index ) + { + // Set Xorg keyboard model + m_selectedModel = m_keyboardModelsModel->key( index ); + QProcess::execute( "setxkbmap", xkbmap_model_args( m_selectedModel ) ); + emit prettyStatusChanged(); + } ); - connect( m_keyboardLayoutsModel, &KeyboardLayoutModel::currentIndexChanged, [&]( int index ) { - m_selectedLayout = m_keyboardLayoutsModel->item( index ).first; - updateVariants( QPersistentModelIndex( m_keyboardLayoutsModel->index( index ) ) ); - emit prettyStatusChanged(); - } ); + connect( m_keyboardLayoutsModel, + &KeyboardLayoutModel::currentIndexChanged, + [ & ]( int index ) + { + m_selectedLayout = m_keyboardLayoutsModel->item( index ).first; + updateVariants( QPersistentModelIndex( m_keyboardLayoutsModel->index( index ) ) ); + emit prettyStatusChanged(); + } ); connect( m_keyboardVariantsModel, &KeyboardVariantsModel::currentIndexChanged, this, &Config::xkbChanged ); diff --git a/src/modules/keyboard/KeyboardLayoutModel.cpp b/src/modules/keyboard/KeyboardLayoutModel.cpp index 3b9ba19fe..ed171a476 100644 --- a/src/modules/keyboard/KeyboardLayoutModel.cpp +++ b/src/modules/keyboard/KeyboardLayoutModel.cpp @@ -27,7 +27,8 @@ retranslateKeyboardModels() { s_kbtranslator = new QTranslator; } - (void)CalamaresUtils::loadTranslator( CalamaresUtils::translatorLocaleName(), QStringLiteral( "kb_" ), s_kbtranslator ); + (void)CalamaresUtils::loadTranslator( + CalamaresUtils::translatorLocaleName(), QStringLiteral( "kb_" ), s_kbtranslator ); } @@ -220,9 +221,8 @@ KeyboardLayoutModel::init() std::stable_sort( m_layouts.begin(), m_layouts.end(), []( const QPair< QString, KeyboardGlobal::KeyboardInfo >& a, - const QPair< QString, KeyboardGlobal::KeyboardInfo >& b ) { - return a.second.description < b.second.description; - } ); + const QPair< QString, KeyboardGlobal::KeyboardInfo >& b ) + { return a.second.description < b.second.description; } ); } QHash< int, QByteArray > diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp index 13ff5ca78..c821c4633 100644 --- a/src/modules/keyboard/KeyboardPage.cpp +++ b/src/modules/keyboard/KeyboardPage.cpp @@ -69,8 +69,9 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent ) cDebug() << "Variants now total=" << model->rowCount() << "selected=" << 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,21 +84,29 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent ) 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() ) ); - } ); + [ 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() ) ); + } ); 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 ) ); - } ); + [ 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 ); } diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index 8593f8385..5888fd071 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -118,15 +118,15 @@ loadLocales( const QString& localeGenPath ) // Assuming we have a list of supported locales, we usually only want UTF-8 ones // because it's not 1995. - auto notUtf8 = []( const QString& s ) { - return !s.contains( "UTF-8", Qt::CaseInsensitive ) && !s.contains( "utf8", Qt::CaseInsensitive ); - }; + auto notUtf8 = []( const QString& s ) + { return !s.contains( "UTF-8", Qt::CaseInsensitive ) && !s.contains( "utf8", Qt::CaseInsensitive ); }; auto it = std::remove_if( localeGenLines.begin(), localeGenLines.end(), notUtf8 ); localeGenLines.erase( it, localeGenLines.end() ); // We strip " UTF-8" from "en_US.UTF-8 UTF-8" because it's redundant redundant. // Also simplify whitespace. - auto unredundant = []( QString& s ) { + auto unredundant = []( QString& s ) + { if ( s.endsWith( " UTF-8" ) ) { s.chop( 6 ); @@ -183,30 +183,36 @@ Config::Config( QObject* parent ) // we don't need to call an update-GS method, or introduce an intermediate // update-thing-and-GS method. And everywhere where we **do** change // language or location, we already emit the signal. - connect( this, &Config::currentLanguageCodeChanged, [&]() { - auto* gs = Calamares::JobQueue::instance()->globalStorage(); - gs->insert( "locale", m_selectedLocaleConfiguration.toBcp47() ); - } ); + connect( this, + &Config::currentLanguageCodeChanged, + [ & ]() + { + auto* gs = Calamares::JobQueue::instance()->globalStorage(); + gs->insert( "locale", m_selectedLocaleConfiguration.toBcp47() ); + } ); - connect( this, &Config::currentLCCodeChanged, [&]() { - updateGSLocale( Calamares::JobQueue::instance()->globalStorage(), localeConfiguration() ); - } ); + connect( this, + &Config::currentLCCodeChanged, + [ & ]() { updateGSLocale( Calamares::JobQueue::instance()->globalStorage(), localeConfiguration() ); } ); - connect( this, &Config::currentLocationChanged, [&]() { - const bool locationChanged - = updateGSLocation( Calamares::JobQueue::instance()->globalStorage(), currentLocation() ); + connect( this, + &Config::currentLocationChanged, + [ & ]() + { + const bool locationChanged + = updateGSLocation( Calamares::JobQueue::instance()->globalStorage(), currentLocation() ); - if ( locationChanged && m_adjustLiveTimezone ) - { - QProcess::execute( "timedatectl", // depends on systemd - { "set-timezone", currentTimezoneCode() } ); - } + if ( locationChanged && m_adjustLiveTimezone ) + { + QProcess::execute( "timedatectl", // depends on systemd + { "set-timezone", currentTimezoneCode() } ); + } - emit currentTimezoneCodeChanged( currentTimezoneCode() ); - emit currentTimezoneNameChanged( currentTimezoneName() ); - } ); + emit currentTimezoneCodeChanged( currentTimezoneCode() ); + emit currentTimezoneNameChanged( currentTimezoneName() ); + } ); - auto prettyStatusNotify = [&]() { emit prettyStatusChanged( prettyStatus() ); }; + auto prettyStatusNotify = [ & ]() { emit prettyStatusChanged( prettyStatus() ); }; connect( this, &Config::currentLanguageStatusChanged, prettyStatusNotify ); connect( this, &Config::currentLCStatusChanged, prettyStatusNotify ); connect( this, &Config::currentLocationStatusChanged, prettyStatusNotify ); diff --git a/src/modules/locale/LCLocaleDialog.cpp b/src/modules/locale/LCLocaleDialog.cpp index efa85c536..afdceb2a1 100644 --- a/src/modules/locale/LCLocaleDialog.cpp +++ b/src/modules/locale/LCLocaleDialog.cpp @@ -60,16 +60,19 @@ LCLocaleDialog::LCLocaleDialog( const QString& guessedLCLocale, const QStringLis connect( dbb->button( QDialogButtonBox::Cancel ), &QPushButton::clicked, this, &QDialog::reject ); connect( m_localesWidget, &QListWidget::itemDoubleClicked, this, &QDialog::accept ); - connect( m_localesWidget, &QListWidget::itemSelectionChanged, [this, dbb]() { - if ( m_localesWidget->selectedItems().isEmpty() ) - { - dbb->button( QDialogButtonBox::Ok )->setEnabled( false ); - } - else - { - dbb->button( QDialogButtonBox::Ok )->setEnabled( true ); - } - } ); + connect( m_localesWidget, + &QListWidget::itemSelectionChanged, + [ this, dbb ]() + { + if ( m_localesWidget->selectedItems().isEmpty() ) + { + dbb->button( QDialogButtonBox::Ok )->setEnabled( false ); + } + else + { + dbb->button( QDialogButtonBox::Ok )->setEnabled( true ); + } + } ); if ( selected > -1 ) { diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index 9ad9f2d3f..724bc59f7 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -140,9 +140,9 @@ TimeZoneWidget::paintEvent( QPaintEvent* ) // .. the lambda manages deprecations: the old one works in Qt 5.9 and Qt 5.10, // while the new one avoids deprecation messages in Qt 5.13 and later. #if QT_VERSION >= QT_VERSION_CHECK( 5, 11, 0 ) - auto textwidth = [&]( const QString& s ) { return fontMetrics.horizontalAdvance( s ); }; + auto textwidth = [ & ]( const QString& s ) { return fontMetrics.horizontalAdvance( s ); }; #else - auto textwidth = [&]( const QString& s ) { return fontMetrics.width( s ); }; + auto textwidth = [ & ]( const QString& s ) { return fontMetrics.width( s ); }; #endif const int textWidth = textwidth( m_currentLocation ? m_currentLocation->tr() : QString() ); const int textHeight = fontMetrics.height(); @@ -185,7 +185,8 @@ TimeZoneWidget::mousePressEvent( QMouseEvent* event ) int mX = event->pos().x(); int mY = event->pos().y(); - auto distance = [&]( const CalamaresUtils::Locale::TimeZoneData* zone ) { + auto distance = [ & ]( const CalamaresUtils::Locale::TimeZoneData* zone ) + { QPoint locPos = TimeZoneImageList::getLocationPosition( zone->longitude(), zone->latitude() ); return double( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) ); }; diff --git a/src/modules/netinstall/NetInstallPage.cpp b/src/modules/netinstall/NetInstallPage.cpp index f7a2f66fc..9c70e97eb 100644 --- a/src/modules/netinstall/NetInstallPage.cpp +++ b/src/modules/netinstall/NetInstallPage.cpp @@ -35,10 +35,13 @@ NetInstallPage::NetInstallPage( Config* c, QWidget* parent ) ui->groupswidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents ); ui->groupswidget->setModel( c->model() ); connect( c, &Config::statusChanged, ui->netinst_status, &QLabel::setText ); - connect( c, &Config::titleLabelChanged, [ui = this->ui]( const QString title ) { - ui->label->setVisible( !title.isEmpty() ); - ui->label->setText( title ); - } ); + connect( c, + &Config::titleLabelChanged, + [ ui = this->ui ]( const QString title ) + { + ui->label->setVisible( !title.isEmpty() ); + ui->label->setText( title ); + } ); connect( c, &Config::statusReady, this, &NetInstallPage::expandGroups ); } diff --git a/src/modules/netinstall/groupstreeview.cpp b/src/modules/netinstall/groupstreeview.cpp index 226fccc7e..4e5ab8c8d 100644 --- a/src/modules/netinstall/groupstreeview.cpp +++ b/src/modules/netinstall/groupstreeview.cpp @@ -12,19 +12,20 @@ #include -void GroupsTreeView::drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const +void +GroupsTreeView::drawBranches( QPainter* painter, const QRect& rect, const QModelIndex& index ) const { - QTreeView::drawBranches(painter, rect, index); + QTreeView::drawBranches( painter, rect, index ); // Empty names are handled specially: don't draw them as items, // so the "branch" seems to just pass them by. const QString s = index.data().toString(); - if (s.isEmpty()) + if ( s.isEmpty() ) { QStyleOptionViewItem opt = viewOptions(); opt.state = QStyle::State_Sibling; - opt.rect = QRect (!isRightToLeft() ? rect.left() : rect.right() + 1, rect.top(), indentation(), rect.height()); - painter->eraseRect(opt.rect); - style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this); + opt.rect = QRect( !isRightToLeft() ? rect.left() : rect.right() + 1, rect.top(), indentation(), rect.height() ); + painter->eraseRect( opt.rect ); + style()->drawPrimitive( QStyle::PE_IndicatorBranch, &opt, painter, this ); } } diff --git a/src/modules/netinstall/groupstreeview.h b/src/modules/netinstall/groupstreeview.h index fb096db58..82f8bc031 100644 --- a/src/modules/netinstall/groupstreeview.h +++ b/src/modules/netinstall/groupstreeview.h @@ -14,5 +14,5 @@ public: using QTreeView::QTreeView; protected: - virtual void drawBranches(QPainter*painter, const QRect& rect, const QModelIndex& index) const override; + virtual void drawBranches( QPainter* painter, const QRect& rect, const QModelIndex& index ) const override; }; diff --git a/src/modules/packagechooser/PackageChooserViewStep.cpp b/src/modules/packagechooser/PackageChooserViewStep.cpp index c3f2ce6e2..e3b27df5c 100644 --- a/src/modules/packagechooser/PackageChooserViewStep.cpp +++ b/src/modules/packagechooser/PackageChooserViewStep.cpp @@ -56,9 +56,9 @@ PackageChooserViewStep::widget() if ( !m_widget ) { m_widget = new PackageChooserPage( m_config->mode(), nullptr ); - connect( m_widget, &PackageChooserPage::selectionChanged, [=]() { - emit nextStatusChanged( this->isNextEnabled() ); - } ); + connect( m_widget, + &PackageChooserPage::selectionChanged, + [ = ]() { emit nextStatusChanged( this->isNextEnabled() ); } ); hookupModel(); } return m_widget; diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index a4de6cc47..7a5f2bab4 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -96,7 +96,8 @@ PlasmaLnfPage::PlasmaLnfPage( Config* config, QWidget* parent ) connect( view->selectionModel(), &QItemSelectionModel::selectionChanged, - [this]( const QItemSelection& selected, const QItemSelection& ) { + [ this ]( const QItemSelection& selected, const QItemSelection& ) + { auto i = selected.indexes(); if ( !i.isEmpty() ) { diff --git a/src/modules/tracking/TrackingPage.cpp b/src/modules/tracking/TrackingPage.cpp index 727efebbd..a5fb3ccc6 100644 --- a/src/modules/tracking/TrackingPage.cpp +++ b/src/modules/tracking/TrackingPage.cpp @@ -45,16 +45,22 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent ) &QCheckBox::stateChanged, \ config->x##Tracking(), \ QOverload< bool >::of( &TrackingStyleConfig::setTracking ) ); \ - connect( config->x##Tracking(), &TrackingStyleConfig::trackingChanged, this, [this, config]() { \ - this->trackerChanged( config->x##Tracking(), this->ui->x##Group, this->ui->x##CheckBox ); \ - } ); \ - connect( ui->x##PolicyButton, &QAbstractButton::clicked, config, [config] { \ - QString url( config->x##Tracking()->policy() ); \ - if ( !url.isEmpty() ) \ - { \ - QDesktopServices::openUrl( url ); \ - } \ - } ); \ + connect( config->x##Tracking(), \ + &TrackingStyleConfig::trackingChanged, \ + this, \ + [ this, config ]() \ + { this->trackerChanged( config->x##Tracking(), this->ui->x##Group, this->ui->x##CheckBox ); } ); \ + connect( ui->x##PolicyButton, \ + &QAbstractButton::clicked, \ + config, \ + [ config ] \ + { \ + QString url( config->x##Tracking()->policy() ); \ + if ( !url.isEmpty() ) \ + { \ + QDesktopServices::openUrl( url ); \ + } \ + } ); \ } while ( false ) trackingSetup( install ); @@ -63,16 +69,19 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent ) #undef trackingSetup - connect( config, &Config::generalPolicyChanged, [this]( const QString& url ) { - this->ui->generalPolicyLabel->setVisible( !url.isEmpty() ); - } ); - connect( ui->generalPolicyLabel, &QLabel::linkActivated, [config] { - QString url( config->generalPolicy() ); - if ( !url.isEmpty() ) - { - QDesktopServices::openUrl( url ); - } - } ); + connect( config, + &Config::generalPolicyChanged, + [ this ]( const QString& url ) { this->ui->generalPolicyLabel->setVisible( !url.isEmpty() ); } ); + connect( ui->generalPolicyLabel, + &QLabel::linkActivated, + [ config ] + { + QString url( config->generalPolicy() ); + if ( !url.isEmpty() ) + { + QDesktopServices::openUrl( url ); + } + } ); retranslate(); } diff --git a/src/modules/users/CheckPWQuality.cpp b/src/modules/users/CheckPWQuality.cpp index 0a67a117a..fc692d246 100644 --- a/src/modules/users/CheckPWQuality.cpp +++ b/src/modules/users/CheckPWQuality.cpp @@ -49,7 +49,7 @@ DEFINE_CHECK_FUNC( minLength ) { cDebug() << Logger::SubEntry << "minLength set to" << minLength; checks.push_back( PasswordCheck( []() { return QCoreApplication::translate( "PWQ", "Password is too short" ); }, - [minLength]( const QString& s ) { return s.length() >= minLength; }, + [ minLength ]( const QString& s ) { return s.length() >= minLength; }, PasswordCheck::Weight( 10 ) ) ); } } @@ -65,7 +65,7 @@ DEFINE_CHECK_FUNC( maxLength ) { cDebug() << Logger::SubEntry << "maxLength set to" << maxLength; checks.push_back( PasswordCheck( []() { return QCoreApplication::translate( "PWQ", "Password is too long" ); }, - [maxLength]( const QString& s ) { return s.length() <= maxLength; }, + [ maxLength ]( const QString& s ) { return s.length() <= maxLength; }, PasswordCheck::Weight( 10 ) ) ); } } @@ -378,8 +378,9 @@ DEFINE_CHECK_FUNC( libpwquality ) /* Something actually added? */ if ( requirement_count ) { - checks.push_back( PasswordCheck( [settings]() { return settings->explanation(); }, - [settings]( const QString& s ) { + checks.push_back( PasswordCheck( [ settings ]() { return settings->explanation(); }, + [ settings ]( const QString& s ) + { int r = settings->check( s ); if ( r < 0 ) { diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 3dfeb2d8e..dcfdea79e 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -165,7 +165,7 @@ WelcomePage::setupButton( Button role, const QString& url ) { auto size = 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ); button->setIcon( CalamaresUtils::defaultPixmap( icon, CalamaresUtils::Original, size ) ); - connect( button, &QPushButton::clicked, [u]() { QDesktopServices::openUrl( u ); } ); + connect( button, &QPushButton::clicked, [ u ]() { QDesktopServices::openUrl( u ); } ); } else { diff --git a/src/modules/welcome/checker/GeneralRequirements.cpp b/src/modules/welcome/checker/GeneralRequirements.cpp index ca7219ca4..5950bd396 100644 --- a/src/modules/welcome/checker/GeneralRequirements.cpp +++ b/src/modules/welcome/checker/GeneralRequirements.cpp @@ -152,10 +152,10 @@ GeneralRequirements::checkRequirements() { checkEntries.append( { entry, - [req = m_requiredStorageGiB] { return tr( "has at least %1 GiB available drive space" ).arg( req ); }, - [req = m_requiredStorageGiB] { - return tr( "There is not enough drive space. At least %1 GiB is required." ).arg( req ); - }, + [ req = m_requiredStorageGiB ] + { return tr( "has at least %1 GiB available drive space" ).arg( req ); }, + [ req = m_requiredStorageGiB ] + { return tr( "There is not enough drive space. At least %1 GiB is required." ).arg( req ); }, enoughStorage, m_entriesToRequire.contains( entry ) } ); } @@ -163,8 +163,8 @@ GeneralRequirements::checkRequirements() { checkEntries.append( { entry, - [req = m_requiredRamGiB] { return tr( "has at least %1 GiB working memory" ).arg( req ); }, - [req = m_requiredRamGiB] { + [ req = m_requiredRamGiB ] { return tr( "has at least %1 GiB working memory" ).arg( req ); }, + [ req = m_requiredRamGiB ] { return tr( "The system does not have enough working memory. At least %1 GiB is required." ) .arg( req ); }, @@ -191,7 +191,8 @@ GeneralRequirements::checkRequirements() { checkEntries.append( { entry, [] { return tr( "is running the installer as an administrator (root)" ); }, - [] { + [] + { return Calamares::Settings::instance()->isSetupMode() ? tr( "The setup program is not running with administrator rights." ) : tr( "The installer is not running with administrator rights." ); @@ -203,7 +204,8 @@ GeneralRequirements::checkRequirements() { checkEntries.append( { entry, [] { return tr( "has a screen large enough to show the whole installer" ); }, - [] { + [] + { return Calamares::Settings::instance()->isSetupMode() ? tr( "The screen is too small to display the setup program." ) : tr( "The screen is too small to display the installer." ); diff --git a/src/modules/welcome/checker/ResultsListWidget.cpp b/src/modules/welcome/checker/ResultsListWidget.cpp index acbb48e42..a5d92b590 100644 --- a/src/modules/welcome/checker/ResultsListWidget.cpp +++ b/src/modules/welcome/checker/ResultsListWidget.cpp @@ -110,10 +110,11 @@ ResultsListDialog::ResultsListDialog( const Calamares::RequirementsModel& model, m_title = new QLabel( this ); m_title->setObjectName( "resultDialogTitle" ); - createResultWidgets( - entriesLayout, m_resultWidgets, model, []( const Calamares::RequirementsModel& m, QModelIndex i ) { - return m.data( i, Calamares::RequirementsModel::HasDetails ).toBool(); - } ); + createResultWidgets( entriesLayout, + m_resultWidgets, + model, + []( const Calamares::RequirementsModel& m, QModelIndex i ) + { return m.data( i, Calamares::RequirementsModel::HasDetails ).toBool(); } ); QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close, Qt::Horizontal, this ); buttonBox->setObjectName( "resultDialogButtons" ); @@ -182,9 +183,8 @@ ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent ) // all *mandatory* entries are satisfied (gives errors if not). const bool requirementsSatisfied = config->requirementsModel()->satisfiedRequirements(); - auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i ) { - return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool(); - }; + auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i ) + { return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool(); }; createResultWidgets( entriesLayout, m_resultWidgets, *( config->requirementsModel() ), isUnSatisfied );