CI: apply coding style globally again

This commit is contained in:
Adriaan de Groot 2022-05-18 12:44:55 +02:00
parent 8fea6f71ab
commit 874a0c1f38
39 changed files with 376 additions and 293 deletions

View File

@ -67,8 +67,7 @@ CalamaresApplication::init()
{ {
Logger::setupLogfile(); Logger::setupLogfile();
cDebug() << "Calamares version:" << CALAMARES_VERSION; cDebug() << "Calamares version:" << CALAMARES_VERSION;
cDebug() << Logger::SubEntry cDebug() << Logger::SubEntry << "languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).replace( ";", ", " );
<< "languages:" << QString( CALAMARES_TRANSLATION_LANGUAGES ).replace( ";", ", " );
if ( !Calamares::Settings::instance() ) if ( !Calamares::Settings::instance() )
{ {

View File

@ -134,10 +134,9 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug,
{ {
QPushButton* debugWindowBtn = new QPushButton; QPushButton* debugWindowBtn = new QPushButton;
debugWindowBtn->setObjectName( "debugButton" ); debugWindowBtn->setObjectName( "debugButton" );
CALAMARES_RETRANSLATE_FOR( CALAMARES_RETRANSLATE_FOR( debugWindowBtn,
debugWindowBtn, debugWindowBtn->setText( QCoreApplication::translate(
debugWindowBtn->setText( QCoreApplication::translate( CalamaresWindow::staticMetaObject.className(), CalamaresWindow::staticMetaObject.className(), "Show debug information" ) ); );
"Show debug information" ) ); );
sideLayout->addWidget( debugWindowBtn ); sideLayout->addWidget( debugWindowBtn );
debugWindowBtn->setFlat( true ); debugWindowBtn->setFlat( true );
debugWindowBtn->setCheckable( 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::backEnabledChanged, back, &QPushButton::setEnabled );
QObject::connect( viewManager, &Calamares::ViewManager::backLabelChanged, back, &QPushButton::setText ); QObject::connect( viewManager, &Calamares::ViewManager::backLabelChanged, back, &QPushButton::setText );
QObject::connect( QObject::connect(
viewManager, &Calamares::ViewManager::backIconChanged, [=]( QString n ) { setButtonIcon( back, n ); } ); viewManager, &Calamares::ViewManager::backIconChanged, [ = ]( QString n ) { setButtonIcon( back, n ); } );
QObject::connect( QObject::connect(
viewManager, &Calamares::ViewManager::backAndNextVisibleChanged, back, &QPushButton::setVisible ); viewManager, &Calamares::ViewManager::backAndNextVisibleChanged, back, &QPushButton::setVisible );
bottomLayout->addWidget( back ); bottomLayout->addWidget( back );
@ -189,7 +188,7 @@ getWidgetNavigation( Calamares::DebugWindowManager*,
QObject::connect( viewManager, &Calamares::ViewManager::nextEnabledChanged, next, &QPushButton::setEnabled ); QObject::connect( viewManager, &Calamares::ViewManager::nextEnabledChanged, next, &QPushButton::setEnabled );
QObject::connect( viewManager, &Calamares::ViewManager::nextLabelChanged, next, &QPushButton::setText ); QObject::connect( viewManager, &Calamares::ViewManager::nextLabelChanged, next, &QPushButton::setText );
QObject::connect( QObject::connect(
viewManager, &Calamares::ViewManager::nextIconChanged, [=]( QString n ) { setButtonIcon( next, n ); } ); viewManager, &Calamares::ViewManager::nextIconChanged, [ = ]( QString n ) { setButtonIcon( next, n ); } );
QObject::connect( QObject::connect(
viewManager, &Calamares::ViewManager::backAndNextVisibleChanged, next, &QPushButton::setVisible ); viewManager, &Calamares::ViewManager::backAndNextVisibleChanged, next, &QPushButton::setVisible );
bottomLayout->addWidget( next ); bottomLayout->addWidget( next );
@ -205,7 +204,7 @@ getWidgetNavigation( Calamares::DebugWindowManager*,
QObject::connect( viewManager, &Calamares::ViewManager::quitEnabledChanged, quit, &QPushButton::setEnabled ); QObject::connect( viewManager, &Calamares::ViewManager::quitEnabledChanged, quit, &QPushButton::setEnabled );
QObject::connect( viewManager, &Calamares::ViewManager::quitLabelChanged, quit, &QPushButton::setText ); QObject::connect( viewManager, &Calamares::ViewManager::quitLabelChanged, quit, &QPushButton::setText );
QObject::connect( 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::quitTooltipChanged, quit, &QPushButton::setToolTip );
QObject::connect( viewManager, &Calamares::ViewManager::quitVisibleChanged, quit, &QPushButton::setVisible ); QObject::connect( viewManager, &Calamares::ViewManager::quitVisibleChanged, quit, &QPushButton::setVisible );
bottomLayout->addWidget( quit ); bottomLayout->addWidget( quit );

View File

@ -85,17 +85,22 @@ DebugWindow::DebugWindow()
m_ui->globalStorageView->expandAll(); m_ui->globalStorageView->expandAll();
// Do above when the GS changes, too // Do above when the GS changes, too
connect( gs, &GlobalStorage::changed, this, [=] { connect( gs,
m_globals = JobQueue::instance()->globalStorage()->data(); &GlobalStorage::changed,
m_globals_model->reload(); this,
m_ui->globalStorageView->expandAll(); [ = ]
} ); {
m_globals = JobQueue::instance()->globalStorage()->data();
m_globals_model->reload();
m_ui->globalStorageView->expandAll();
} );
// JobQueue page // JobQueue page
m_ui->jobQueueText->setReadOnly( true ); m_ui->jobQueueText->setReadOnly( true );
connect( JobQueue::instance(), &JobQueue::queueChanged, this, [this]( const QStringList& jobs ) { connect( JobQueue::instance(),
m_ui->jobQueueText->setText( jobs.join( '\n' ) ); &JobQueue::queueChanged,
} ); this,
[ this ]( const QStringList& jobs ) { m_ui->jobQueueText->setText( jobs.join( '\n' ) ); } );
// Modules page // Modules page
QStringList modulesKeys; QStringList modulesKeys;
@ -116,67 +121,74 @@ DebugWindow::DebugWindow()
m_ui->modulesVerticalLayout->insertWidget( 1, pythonConsoleButton ); m_ui->modulesVerticalLayout->insertWidget( 1, pythonConsoleButton );
pythonConsoleButton->hide(); pythonConsoleButton->hide();
QObject::connect( pythonConsoleButton, &QPushButton::clicked, this, [this, moduleConfigModel] { QObject::connect(
QString moduleName = m_ui->modulesListView->currentIndex().data().toString(); pythonConsoleButton,
Module* module = ModuleManager::instance()->moduleInstance( moduleName ); &QPushButton::clicked,
if ( module->interface() != Module::Interface::PythonQt || module->type() != Module::Type::View ) this,
return; [ this, moduleConfigModel ]
for ( ViewStep* step : ViewManager::instance()->viewSteps() )
{ {
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 ( step->moduleInstanceKey() == module->instanceKey() )
if ( pqvs )
{ {
QWidget* consoleWindow = new QWidget; PythonQtViewStep* pqvs = qobject_cast< PythonQtViewStep* >( step );
if ( pqvs )
{
QWidget* consoleWindow = new QWidget;
QWidget* console = pqvs->createScriptingConsole(); QWidget* console = pqvs->createScriptingConsole();
console->setParent( consoleWindow ); console->setParent( consoleWindow );
QVBoxLayout* layout = new QVBoxLayout; QVBoxLayout* layout = new QVBoxLayout;
consoleWindow->setLayout( layout ); consoleWindow->setLayout( layout );
layout->addWidget( console ); layout->addWidget( console );
QHBoxLayout* bottomLayout = new QHBoxLayout; QHBoxLayout* bottomLayout = new QHBoxLayout;
layout->addLayout( bottomLayout ); layout->addLayout( bottomLayout );
QLabel* bottomLabel = new QLabel( consoleWindow ); QLabel* bottomLabel = new QLabel( consoleWindow );
bottomLayout->addWidget( bottomLabel ); bottomLayout->addWidget( bottomLabel );
QString line = QString( "Module: <font color=\"#008000\"><code>%1</code></font><br/>" QString line = QString( "Module: <font color=\"#008000\"><code>%1</code></font><br/>"
"Python class: <font color=\"#008000\"><code>%2</code></font>" ) "Python class: <font color=\"#008000\"><code>%2</code></font>" )
.arg( module->instanceKey() ) .arg( module->instanceKey() )
.arg( console->property( "classname" ).toString() ); .arg( console->property( "classname" ).toString() );
bottomLabel->setText( line ); bottomLabel->setText( line );
QPushButton* closeButton = new QPushButton( consoleWindow ); QPushButton* closeButton = new QPushButton( consoleWindow );
closeButton->setText( "&Close" ); closeButton->setText( "&Close" );
QObject::connect( closeButton, &QPushButton::clicked, [consoleWindow] { consoleWindow->close(); } ); QObject::connect(
bottomLayout->addWidget( closeButton ); closeButton, &QPushButton::clicked, [ consoleWindow ] { consoleWindow->close(); } );
bottomLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); bottomLayout->addWidget( closeButton );
bottomLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
consoleWindow->setParent( this ); consoleWindow->setParent( this );
consoleWindow->setWindowFlags( Qt::Window ); consoleWindow->setWindowFlags( Qt::Window );
consoleWindow->setWindowTitle( "Calamares Python console" ); consoleWindow->setWindowTitle( "Calamares Python console" );
consoleWindow->setAttribute( Qt::WA_DeleteOnClose, true ); consoleWindow->setAttribute( Qt::WA_DeleteOnClose, true );
consoleWindow->showNormal(); consoleWindow->showNormal();
break; break;
}
} }
} }
} } );
} );
#endif #endif
connect( m_ui->modulesListView->selectionModel(), connect( m_ui->modulesListView->selectionModel(),
&QItemSelectionModel::selectionChanged, &QItemSelectionModel::selectionChanged,
this, this,
[this [ this
#ifdef WITH_PYTHONQT #ifdef WITH_PYTHONQT
, ,
pythonConsoleButton pythonConsoleButton
#endif #endif
] { ]
{
QString moduleName = m_ui->modulesListView->currentIndex().data().toString(); QString moduleName = m_ui->modulesListView->currentIndex().data().toString();
Module* module Module* module
= ModuleManager::instance()->moduleInstance( ModuleSystem::InstanceKey::fromString( moduleName ) ); = ModuleManager::instance()->moduleInstance( ModuleSystem::InstanceKey::fromString( moduleName ) );
@ -196,27 +208,33 @@ DebugWindow::DebugWindow()
// Tools page // Tools page
connect( m_ui->crashButton, &QPushButton::clicked, this, [] { ::crash(); } ); connect( m_ui->crashButton, &QPushButton::clicked, this, [] { ::crash(); } );
connect( m_ui->reloadStylesheetButton, &QPushButton::clicked, []() { connect( m_ui->reloadStylesheetButton,
for ( auto* w : qApp->topLevelWidgets() ) &QPushButton::clicked,
{ []()
// Needs to match what's set in CalamaresWindow {
if ( w->objectName() == QStringLiteral( "mainApp" ) ) for ( auto* w : qApp->topLevelWidgets() )
{ {
w->setStyleSheet( Calamares::Branding::instance()->stylesheet() ); // 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; connect( m_ui->widgetTreeButton,
dumpWidgetTree( deb, w, 0 ); &QPushButton::clicked,
} []()
} ); {
for ( auto* w : qApp->topLevelWidgets() )
{
Logger::CDebug deb;
dumpWidgetTree( deb, w, 0 );
}
} );
// Send Log button only if it would be useful // Send Log button only if it would be useful
m_ui->sendLogButton->setVisible( CalamaresUtils::Paste::isEnabled() ); 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" ) ); ); 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 = new Calamares::DebugWindow();
m_debugWindow->show(); m_debugWindow->show();
connect( m_debugWindow.data(), &Calamares::DebugWindow::closed, this, [=]() { connect( m_debugWindow.data(),
m_debugWindow->deleteLater(); &Calamares::DebugWindow::closed,
m_visible = false; this,
emit visibleChanged( false ); [ = ]()
} ); {
m_debugWindow->deleteLater();
m_visible = false;
emit visibleChanged( false );
} );
m_visible = true; m_visible = true;
emit visibleChanged( true ); emit visibleChanged( true );
} }

View File

@ -51,6 +51,6 @@ ProgressTreeView::setModel( QAbstractItemModel* model )
Calamares::ViewManager::instance(), Calamares::ViewManager::instance(),
&Calamares::ViewManager::currentStepChanged, &Calamares::ViewManager::currentStepChanged,
this, this,
[this]() { viewport()->update(); }, [ this ]() { viewport()->update(); },
Qt::UniqueConnection ); Qt::UniqueConnection );
} }

View File

@ -89,9 +89,10 @@ public:
= m_queuedJobs->isEmpty() ? 0.0 : ( m_queuedJobs->last().cumulative + m_queuedJobs->last().weight ); = m_queuedJobs->isEmpty() ? 0.0 : ( m_queuedJobs->last().cumulative + m_queuedJobs->last().weight );
qreal totalJobWeight qreal totalJobWeight
= std::accumulate( jobs.cbegin(), jobs.cend(), qreal( 0.0 ), []( qreal total, const job_ptr& j ) { = std::accumulate( jobs.cbegin(),
return total + j->getJobWeight(); jobs.cend(),
} ); qreal( 0.0 ),
[]( qreal total, const job_ptr& j ) { return total + j->getJobWeight(); } );
if ( totalJobWeight < 1 ) if ( totalJobWeight < 1 )
{ {
totalJobWeight = 1.0; totalJobWeight = 1.0;

View File

@ -211,14 +211,14 @@ _process_output( Calamares::Utils::RunLocation location,
bp::extract< bp::list > x( callback ); bp::extract< bp::list > x( callback );
if ( x.check() ) if ( x.check() )
{ {
QObject::connect( &r, &decltype( r )::output, [cb = callback.attr( "append" )]( const QString& s ) { QObject::connect( &r,
cb( s.toStdString() ); &decltype( r )::output,
} ); [ cb = callback.attr( "append" ) ]( const QString& s ) { cb( s.toStdString() ); } );
} }
else else
{ {
QObject::connect( 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(); r.enableOutputProcessing();
} }

View File

@ -290,7 +290,7 @@ Settings::reconcileInstancesAndSequence()
// Since moduleFinder captures targetKey by reference, we can // Since moduleFinder captures targetKey by reference, we can
// update targetKey to change what the finder lambda looks for. // update targetKey to change what the finder lambda looks for.
Calamares::ModuleSystem::InstanceKey targetKey; 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) // Check the sequence against the existing instances (which so far are only custom)
for ( const auto& step : m_modulesSequence ) for ( const auto& step : m_modulesSequence )

View File

@ -425,9 +425,8 @@ sequence:
// Make a lambda where we can adjust what it looks for from the outside, // Make a lambda where we can adjust what it looks for from the outside,
// by capturing a reference. // by capturing a reference.
QString moduleKey = QString( "welcome" ); QString moduleKey = QString( "welcome" );
auto moduleFinder = [&moduleKey]( const Calamares::InstanceDescription& d ) { auto moduleFinder = [ &moduleKey ]( const Calamares::InstanceDescription& d )
return d.isValid() && d.key().module() == moduleKey; { return d.isValid() && d.key().module() == moduleKey; };
};
const auto it0 = std::find_if( s.moduleInstances().constBegin(), s.moduleInstances().constEnd(), moduleFinder ); const auto it0 = std::find_if( s.moduleInstances().constBegin(), s.moduleInstances().constEnd(), moduleFinder );
QVERIFY( it0 != s.moduleInstances().constEnd() ); QVERIFY( it0 != s.moduleInstances().constEnd() );

View File

@ -150,7 +150,7 @@ Handler::query() const
QString url = m_url; QString url = m_url;
QString selector = m_selector; QString selector = m_selector;
return QtConcurrent::run( [=] { return do_query( type, url, selector ); } ); return QtConcurrent::run( [ = ] { return do_query( type, url, selector ); } );
} }
QString QString
@ -171,7 +171,7 @@ Handler::queryRaw() const
QString url = m_url; QString url = m_url;
QString selector = m_selector; 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 } // namespace GeoIP

View File

@ -43,9 +43,9 @@ lookup( TwoChar c )
} }
const CountryData* p const CountryData* p
= std::find_if( country_data_table, country_data_table + country_data_size, [c = c]( const CountryData& d ) { = std::find_if( country_data_table,
return ( d.cc1 == c.cc1 ) && ( d.cc2 == c.cc2 ); 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 ) if ( p == country_data_table + country_data_size )
{ {
return nullptr; return nullptr;
@ -86,7 +86,7 @@ languageForCountry( QLocale::Country country )
{ {
const CountryData* p = std::find_if( country_data_table, const CountryData* p = std::find_if( country_data_table,
country_data_table + country_data_size, 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 ) if ( p == country_data_table + country_data_size )
{ {
return QLocale::Language::AnyLanguage; return QLocale::Language::AnyLanguage;

View File

@ -224,16 +224,19 @@ public:
loadTZData( m_regions, m_altZones, in ); loadTZData( m_regions, m_altZones, in );
} }
std::sort( m_regions.begin(), m_regions.end(), []( const RegionData* lhs, const RegionData* rhs ) { std::sort( m_regions.begin(),
return lhs->key() < rhs->key(); 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 ) { std::sort( m_zones.begin(),
if ( lhs->region() == rhs->region() ) m_zones.end(),
{ []( const TimeZoneData* lhs, const TimeZoneData* rhs )
return lhs->zone() < rhs->zone(); {
} if ( lhs->region() == rhs->region() )
return lhs->region() < rhs->region(); {
} ); return lhs->zone() < rhs->zone();
}
return lhs->region() < rhs->region();
} );
for ( auto* z : m_zones ) 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 * either N/S or E/W equal to any other; this obviously
* falls apart at the poles. * 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 // Latitude doesn't wrap around: there is nothing north of 90
double latitudeDifference = abs( zone->latitude() - latitude ); 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(); 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 ) if ( *this )
{ {

View File

@ -47,7 +47,7 @@ Presets::Presets( const QVariantMap& configurationMap, const QStringList& recogn
{ {
reserve( recognizedKeys.size() ); reserve( recognizedKeys.size() );
loadPresets( loadPresets(
*this, configurationMap, [&recognizedKeys]( const QString& s ) { return recognizedKeys.contains( s ); } ); *this, configurationMap, [ &recognizedKeys ]( const QString& s ) { return recognizedKeys.contains( s ); } );
} }
bool bool

View File

@ -63,9 +63,9 @@ RequirementsChecker::finished()
static QMutex finishedMutex; static QMutex finishedMutex;
QMutexLocker lock( &finishedMutex ); QMutexLocker lock( &finishedMutex );
if ( m_progressTimer && std::all_of( m_watchers.cbegin(), m_watchers.cend(), []( const Watcher* w ) { if ( m_progressTimer
return w && w->isFinished(); && std::all_of(
} ) ) m_watchers.cbegin(), m_watchers.cend(), []( const Watcher* w ) { return w && w->isFinished(); } ) )
{ {
cDebug() << "All requirements have been checked."; cDebug() << "All requirements have been checked.";
if ( m_progressTimer ) if ( m_progressTimer )
@ -100,14 +100,17 @@ RequirementsChecker::reportProgress()
m_progressTimeouts++; m_progressTimeouts++;
QStringList remainingNames; QStringList remainingNames;
auto remaining = std::count_if( m_watchers.cbegin(), m_watchers.cend(), [&]( const Watcher* w ) { auto remaining = std::count_if( m_watchers.cbegin(),
if ( w && !w->isFinished() ) m_watchers.cend(),
{ [ & ]( const Watcher* w )
remainingNames << w->objectName(); {
return true; if ( w && !w->isFinished() )
} {
return false; remainingNames << w->objectName();
} ); return true;
}
return false;
} );
if ( remaining > 0 ) if ( remaining > 0 )
{ {
cDebug() << "Remaining modules:" << remaining << Logger::DebugList( remainingNames ); cDebug() << "Remaining modules:" << remaining << Logger::DebugList( remainingNames );

View File

@ -140,7 +140,7 @@ PackagesTests::testAdd()
{ {
// This is the "original" instance, so it's missing extraEditor // This is the "original" instance, so it's missing extraEditor
auto op = action[ "install" ].toList(); 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 ) ); QVERIFY( !op.contains( extraEditor ) );
} }
} }

View File

@ -102,9 +102,7 @@ KPMManager::KPMManager()
{ {
} }
KPMManager::~KPMManager() KPMManager::~KPMManager() {}
{
}
KPMManager::operator bool() const KPMManager::operator bool() const
{ {

View File

@ -29,7 +29,8 @@ PartitionIterator::PartitionIterator( PartitionTable* table )
{ {
} }
Partition* PartitionIterator::operator*() const Partition*
PartitionIterator::operator*() const
{ {
return m_current; return m_current;
} }

View File

@ -108,5 +108,5 @@ struct cScopedAssignment
}; };
template < typename T > template < typename T >
cScopedAssignment( T p )->cScopedAssignment< decltype( *p ) >; cScopedAssignment( T p ) -> cScopedAssignment< decltype( *p ) >;
#endif #endif

View File

@ -116,7 +116,7 @@ private:
* immediately after setting up the connection. This allows * immediately after setting up the connection. This allows
* setup and translation code to be mixed together. * 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 /** @brief Call code for the given object (widget) when language changes
* *
* This is identical to CALAMARES_RETRANSLATE, except the @p body is called * 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 * immediately after setting up the connection. This allows
* setup and translation code to be mixed together. * 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 /** @brief Call a slot in this object when language changes
* *
* Given a slot (in method-function-pointer notation), call that slot when the * Given a slot (in method-function-pointer notation), call that slot when the

View File

@ -151,16 +151,19 @@ Calamares::Utils::Runner::run()
if ( m_output ) if ( m_output )
{ {
connect( &process, &QProcess::readyReadStandardOutput, [this, &process]() { connect( &process,
do &QProcess::readyReadStandardOutput,
{ [ this, &process ]()
QString s = process.readLine(); {
if ( !s.isEmpty() ) do
{ {
Q_EMIT this->output( s ); QString s = process.readLine();
} if ( !s.isEmpty() )
} while ( process.canReadLine() ); {
} ); Q_EMIT this->output( s );
}
} while ( process.canReadLine() );
} );
} }
cDebug() << Logger::SubEntry << "Running" << Logger::RedactedCommand( m_command ); cDebug() << Logger::SubEntry << "Running" << Logger::RedactedCommand( m_command );

View File

@ -993,7 +993,7 @@ LibCalamaresTests::testRunnerOutput()
Calamares::Utils::Runner r( { "cat" } ); Calamares::Utils::Runner r( { "cat" } );
r.enableOutputProcessing().setInput( QStringLiteral( "hello\nworld\n\n!\n" ) ); 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(); auto result = r.run();

View File

@ -97,12 +97,12 @@ PythonQtViewModule::loadSelf()
cala.addVariable( "configuration", m_configurationMap ); cala.addVariable( "configuration", m_configurationMap );
// Basic stdout/stderr handling // Basic stdout/stderr handling
QObject::connect( PythonQt::self(), &PythonQt::pythonStdOut, []( const QString& message ) { QObject::connect( PythonQt::self(),
cDebug() << "PythonQt OUT>" << message; &PythonQt::pythonStdOut,
} ); []( const QString& message ) { cDebug() << "PythonQt OUT>" << message; } );
QObject::connect( PythonQt::self(), &PythonQt::pythonStdErr, []( const QString& message ) { QObject::connect( PythonQt::self(),
cDebug() << "PythonQt ERR>" << message; &PythonQt::pythonStdErr,
} ); []( const QString& message ) { cDebug() << "PythonQt ERR>" << message; } );
} }
QDir workingDir( m_workingPath ); QDir workingDir( m_workingPath );

View File

@ -135,14 +135,14 @@ addExpansions( QmlSearch method, QStringList& candidates, const QStringList& nam
std::transform( names.constBegin(), std::transform( names.constBegin(),
names.constEnd(), names.constEnd(),
std::back_inserter( candidates ), 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 ) ) if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::QrcOnly ) )
{ {
std::transform( names.constBegin(), std::transform( names.constBegin(),
names.constEnd(), names.constEnd(),
std::back_inserter( candidates ), 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 // Because branding and viewmanager have a parent (CalamaresApplication
// and CalamaresWindow), they will not be deleted by QmlEngine. // and CalamaresWindow), they will not be deleted by QmlEngine.
// https://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership // https://doc.qt.io/qt-5/qtqml-cppintegration-data.html#data-ownership
qmlRegisterSingletonType< Calamares::Branding >( qmlRegisterSingletonType< Calamares::Branding >( "io.calamares.ui",
"io.calamares.ui", 1, 0, "Branding", []( QQmlEngine*, QJSEngine* ) -> QObject* { 1,
return Calamares::Branding::instance(); 0,
} ); "Branding",
qmlRegisterSingletonType< Calamares::ViewManager >( []( QQmlEngine*, QJSEngine* ) -> QObject*
"io.calamares.ui", 1, 0, "ViewManager", []( QQmlEngine*, QJSEngine* ) -> QObject* { { return Calamares::Branding::instance(); } );
return Calamares::ViewManager::instance(); qmlRegisterSingletonType< Calamares::ViewManager >( "io.calamares.ui",
} ); 1,
0,
"ViewManager",
[]( QQmlEngine*, QJSEngine* ) -> QObject*
{ return Calamares::ViewManager::instance(); } );
qmlRegisterSingletonType< Calamares::GlobalStorage >( qmlRegisterSingletonType< Calamares::GlobalStorage >(
"io.calamares.core", 1, 0, "Global", []( QQmlEngine*, QJSEngine* ) -> QObject* { "io.calamares.core",
return Calamares::JobQueue::instance()->globalStorage(); 1,
} ); 0,
"Global",
[]( QQmlEngine*, QJSEngine* ) -> QObject* { return Calamares::JobQueue::instance()->globalStorage(); } );
qmlRegisterSingletonType< CalamaresUtils::Network::Manager >( qmlRegisterSingletonType< CalamaresUtils::Network::Manager >(
"io.calamares.core", 1, 0, "Network", []( QQmlEngine*, QJSEngine* ) -> QObject* { "io.calamares.core",
return &CalamaresUtils::Network::Manager::instance(); 1,
} ); 0,
"Network",
[]( QQmlEngine*, QJSEngine* ) -> QObject* { return &CalamaresUtils::Network::Manager::instance(); } );
} }
} }

View File

@ -31,16 +31,19 @@ FinishedPage::FinishedPage( Config* config, QWidget* parent )
ui->mainText->setWordWrap( true ); ui->mainText->setWordWrap( true );
ui->mainText->setOpenExternalLinks( true ); ui->mainText->setOpenExternalLinks( true );
connect( config, &Config::restartModeChanged, [this]( Config::RestartMode mode ) { connect( config,
using Mode = Config::RestartMode; &Config::restartModeChanged,
[ this ]( Config::RestartMode mode )
{
using Mode = Config::RestartMode;
ui->restartCheckBox->setVisible( mode != Mode::Never ); ui->restartCheckBox->setVisible( mode != Mode::Never );
ui->restartCheckBox->setEnabled( mode != Mode::Always ); ui->restartCheckBox->setEnabled( mode != Mode::Always );
} ); } );
connect( config, &Config::restartNowWantedChanged, ui->restartCheckBox, &QCheckBox::setChecked ); connect( config, &Config::restartNowWantedChanged, ui->restartCheckBox, &QCheckBox::setChecked );
connect( ui->restartCheckBox, &QCheckBox::stateChanged, [config]( int state ) { connect( ui->restartCheckBox,
config->setRestartNowWanted( state != 0 ); &QCheckBox::stateChanged,
} ); [ config ]( int state ) { config->setRestartNowWanted( state != 0 ); } );
CALAMARES_RETRANSLATE_SLOT( &FinishedPage::retranslate ); CALAMARES_RETRANSLATE_SLOT( &FinishedPage::retranslate );
} }

View File

@ -156,18 +156,24 @@ Config::Config( QObject* parent )
m_setxkbmapTimer.setSingleShot( true ); m_setxkbmapTimer.setSingleShot( true );
// Connect signals and slots // Connect signals and slots
connect( m_keyboardModelsModel, &KeyboardModelsModel::currentIndexChanged, [&]( int index ) { connect( m_keyboardModelsModel,
// Set Xorg keyboard model &KeyboardModelsModel::currentIndexChanged,
m_selectedModel = m_keyboardModelsModel->key( index ); [ & ]( int index )
QProcess::execute( "setxkbmap", xkbmap_model_args( m_selectedModel ) ); {
emit prettyStatusChanged(); // 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 ) { connect( m_keyboardLayoutsModel,
m_selectedLayout = m_keyboardLayoutsModel->item( index ).first; &KeyboardLayoutModel::currentIndexChanged,
updateVariants( QPersistentModelIndex( m_keyboardLayoutsModel->index( index ) ) ); [ & ]( int index )
emit prettyStatusChanged(); {
} ); m_selectedLayout = m_keyboardLayoutsModel->item( index ).first;
updateVariants( QPersistentModelIndex( m_keyboardLayoutsModel->index( index ) ) );
emit prettyStatusChanged();
} );
connect( m_keyboardVariantsModel, &KeyboardVariantsModel::currentIndexChanged, this, &Config::xkbChanged ); connect( m_keyboardVariantsModel, &KeyboardVariantsModel::currentIndexChanged, this, &Config::xkbChanged );

View File

@ -27,7 +27,8 @@ retranslateKeyboardModels()
{ {
s_kbtranslator = new QTranslator; 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(), std::stable_sort( m_layouts.begin(),
m_layouts.end(), m_layouts.end(),
[]( const QPair< QString, KeyboardGlobal::KeyboardInfo >& a, []( const QPair< QString, KeyboardGlobal::KeyboardInfo >& a,
const QPair< QString, KeyboardGlobal::KeyboardInfo >& b ) { const QPair< QString, KeyboardGlobal::KeyboardInfo >& b )
return a.second.description < b.second.description; { return a.second.description < b.second.description; } );
} );
} }
QHash< int, QByteArray > QHash< int, QByteArray >

View File

@ -69,8 +69,9 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent )
cDebug() << "Variants now total=" << model->rowCount() << "selected=" << model->currentIndex(); cDebug() << "Variants now total=" << model->rowCount() << "selected=" << model->currentIndex();
} }
connect( connect( ui->buttonRestore,
ui->buttonRestore, &QPushButton::clicked, [config = config] { config->keyboardModels()->setCurrentIndex(); } ); &QPushButton::clicked,
[ config = config ] { config->keyboardModels()->setCurrentIndex(); } );
connect( ui->physicalModelSelector, connect( ui->physicalModelSelector,
QOverload< int >::of( &QComboBox::currentIndexChanged ), QOverload< int >::of( &QComboBox::currentIndexChanged ),
@ -83,21 +84,29 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent )
connect( ui->layoutSelector->selectionModel(), connect( ui->layoutSelector->selectionModel(),
&QItemSelectionModel::currentChanged, &QItemSelectionModel::currentChanged,
[this]( const QModelIndex& current ) { m_config->keyboardLayouts()->setCurrentIndex( current.row() ); } ); [ this ]( const QModelIndex& current )
connect( config->keyboardLayouts(), &KeyboardLayoutModel::currentIndexChanged, [this]( int index ) { { m_config->keyboardLayouts()->setCurrentIndex( current.row() ); } );
ui->layoutSelector->setCurrentIndex( m_config->keyboardLayouts()->index( index ) ); connect( config->keyboardLayouts(),
m_keyboardPreview->setLayout( m_config->keyboardLayouts()->key( index ) ); &KeyboardLayoutModel::currentIndexChanged,
m_keyboardPreview->setVariant( [ this ]( int index )
m_config->keyboardVariants()->key( m_config->keyboardVariants()->currentIndex() ) ); {
} ); 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(), connect( ui->variantSelector->selectionModel(),
&QItemSelectionModel::currentChanged, &QItemSelectionModel::currentChanged,
[this]( const QModelIndex& current ) { m_config->keyboardVariants()->setCurrentIndex( current.row() ); } ); [ this ]( const QModelIndex& current )
connect( config->keyboardVariants(), &KeyboardVariantsModel::currentIndexChanged, [this]( int index ) { { m_config->keyboardVariants()->setCurrentIndex( current.row() ); } );
ui->variantSelector->setCurrentIndex( m_config->keyboardVariants()->index( index ) ); connect( config->keyboardVariants(),
m_keyboardPreview->setVariant( m_config->keyboardVariants()->key( index ) ); &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 );
} }

View File

@ -118,15 +118,15 @@ loadLocales( const QString& localeGenPath )
// Assuming we have a list of supported locales, we usually only want UTF-8 ones // Assuming we have a list of supported locales, we usually only want UTF-8 ones
// because it's not 1995. // because it's not 1995.
auto notUtf8 = []( const QString& s ) { auto notUtf8 = []( const QString& s )
return !s.contains( "UTF-8", Qt::CaseInsensitive ) && !s.contains( "utf8", Qt::CaseInsensitive ); { return !s.contains( "UTF-8", Qt::CaseInsensitive ) && !s.contains( "utf8", Qt::CaseInsensitive ); };
};
auto it = std::remove_if( localeGenLines.begin(), localeGenLines.end(), notUtf8 ); auto it = std::remove_if( localeGenLines.begin(), localeGenLines.end(), notUtf8 );
localeGenLines.erase( it, localeGenLines.end() ); localeGenLines.erase( it, localeGenLines.end() );
// We strip " UTF-8" from "en_US.UTF-8 UTF-8" because it's redundant redundant. // We strip " UTF-8" from "en_US.UTF-8 UTF-8" because it's redundant redundant.
// Also simplify whitespace. // Also simplify whitespace.
auto unredundant = []( QString& s ) { auto unredundant = []( QString& s )
{
if ( s.endsWith( " UTF-8" ) ) if ( s.endsWith( " UTF-8" ) )
{ {
s.chop( 6 ); 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 // 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 // update-thing-and-GS method. And everywhere where we **do** change
// language or location, we already emit the signal. // language or location, we already emit the signal.
connect( this, &Config::currentLanguageCodeChanged, [&]() { connect( this,
auto* gs = Calamares::JobQueue::instance()->globalStorage(); &Config::currentLanguageCodeChanged,
gs->insert( "locale", m_selectedLocaleConfiguration.toBcp47() ); [ & ]()
} ); {
auto* gs = Calamares::JobQueue::instance()->globalStorage();
gs->insert( "locale", m_selectedLocaleConfiguration.toBcp47() );
} );
connect( this, &Config::currentLCCodeChanged, [&]() { connect( this,
updateGSLocale( Calamares::JobQueue::instance()->globalStorage(), localeConfiguration() ); &Config::currentLCCodeChanged,
} ); [ & ]() { updateGSLocale( Calamares::JobQueue::instance()->globalStorage(), localeConfiguration() ); } );
connect( this, &Config::currentLocationChanged, [&]() { connect( this,
const bool locationChanged &Config::currentLocationChanged,
= updateGSLocation( Calamares::JobQueue::instance()->globalStorage(), currentLocation() ); [ & ]()
{
const bool locationChanged
= updateGSLocation( Calamares::JobQueue::instance()->globalStorage(), currentLocation() );
if ( locationChanged && m_adjustLiveTimezone ) if ( locationChanged && m_adjustLiveTimezone )
{ {
QProcess::execute( "timedatectl", // depends on systemd QProcess::execute( "timedatectl", // depends on systemd
{ "set-timezone", currentTimezoneCode() } ); { "set-timezone", currentTimezoneCode() } );
} }
emit currentTimezoneCodeChanged( currentTimezoneCode() ); emit currentTimezoneCodeChanged( currentTimezoneCode() );
emit currentTimezoneNameChanged( currentTimezoneName() ); emit currentTimezoneNameChanged( currentTimezoneName() );
} ); } );
auto prettyStatusNotify = [&]() { emit prettyStatusChanged( prettyStatus() ); }; auto prettyStatusNotify = [ & ]() { emit prettyStatusChanged( prettyStatus() ); };
connect( this, &Config::currentLanguageStatusChanged, prettyStatusNotify ); connect( this, &Config::currentLanguageStatusChanged, prettyStatusNotify );
connect( this, &Config::currentLCStatusChanged, prettyStatusNotify ); connect( this, &Config::currentLCStatusChanged, prettyStatusNotify );
connect( this, &Config::currentLocationStatusChanged, prettyStatusNotify ); connect( this, &Config::currentLocationStatusChanged, prettyStatusNotify );

View File

@ -60,16 +60,19 @@ LCLocaleDialog::LCLocaleDialog( const QString& guessedLCLocale, const QStringLis
connect( dbb->button( QDialogButtonBox::Cancel ), &QPushButton::clicked, this, &QDialog::reject ); connect( dbb->button( QDialogButtonBox::Cancel ), &QPushButton::clicked, this, &QDialog::reject );
connect( m_localesWidget, &QListWidget::itemDoubleClicked, this, &QDialog::accept ); connect( m_localesWidget, &QListWidget::itemDoubleClicked, this, &QDialog::accept );
connect( m_localesWidget, &QListWidget::itemSelectionChanged, [this, dbb]() { connect( m_localesWidget,
if ( m_localesWidget->selectedItems().isEmpty() ) &QListWidget::itemSelectionChanged,
{ [ this, dbb ]()
dbb->button( QDialogButtonBox::Ok )->setEnabled( false ); {
} if ( m_localesWidget->selectedItems().isEmpty() )
else {
{ dbb->button( QDialogButtonBox::Ok )->setEnabled( false );
dbb->button( QDialogButtonBox::Ok )->setEnabled( true ); }
} else
} ); {
dbb->button( QDialogButtonBox::Ok )->setEnabled( true );
}
} );
if ( selected > -1 ) if ( selected > -1 )
{ {

View File

@ -140,9 +140,9 @@ TimeZoneWidget::paintEvent( QPaintEvent* )
// .. the lambda manages deprecations: the old one works in Qt 5.9 and Qt 5.10, // .. 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. // while the new one avoids deprecation messages in Qt 5.13 and later.
#if QT_VERSION >= QT_VERSION_CHECK( 5, 11, 0 ) #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 #else
auto textwidth = [&]( const QString& s ) { return fontMetrics.width( s ); }; auto textwidth = [ & ]( const QString& s ) { return fontMetrics.width( s ); };
#endif #endif
const int textWidth = textwidth( m_currentLocation ? m_currentLocation->tr() : QString() ); const int textWidth = textwidth( m_currentLocation ? m_currentLocation->tr() : QString() );
const int textHeight = fontMetrics.height(); const int textHeight = fontMetrics.height();
@ -185,7 +185,8 @@ TimeZoneWidget::mousePressEvent( QMouseEvent* event )
int mX = event->pos().x(); int mX = event->pos().x();
int mY = event->pos().y(); 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() ); QPoint locPos = TimeZoneImageList::getLocationPosition( zone->longitude(), zone->latitude() );
return double( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) ); return double( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) );
}; };

View File

@ -35,10 +35,13 @@ NetInstallPage::NetInstallPage( Config* c, QWidget* parent )
ui->groupswidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents ); ui->groupswidget->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
ui->groupswidget->setModel( c->model() ); ui->groupswidget->setModel( c->model() );
connect( c, &Config::statusChanged, ui->netinst_status, &QLabel::setText ); connect( c, &Config::statusChanged, ui->netinst_status, &QLabel::setText );
connect( c, &Config::titleLabelChanged, [ui = this->ui]( const QString title ) { connect( c,
ui->label->setVisible( !title.isEmpty() ); &Config::titleLabelChanged,
ui->label->setText( title ); [ ui = this->ui ]( const QString title )
} ); {
ui->label->setVisible( !title.isEmpty() );
ui->label->setText( title );
} );
connect( c, &Config::statusReady, this, &NetInstallPage::expandGroups ); connect( c, &Config::statusReady, this, &NetInstallPage::expandGroups );
} }

View File

@ -12,19 +12,20 @@
#include <QPainter> #include <QPainter>
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, // Empty names are handled specially: don't draw them as items,
// so the "branch" seems to just pass them by. // so the "branch" seems to just pass them by.
const QString s = index.data().toString(); const QString s = index.data().toString();
if (s.isEmpty()) if ( s.isEmpty() )
{ {
QStyleOptionViewItem opt = viewOptions(); QStyleOptionViewItem opt = viewOptions();
opt.state = QStyle::State_Sibling; opt.state = QStyle::State_Sibling;
opt.rect = QRect (!isRightToLeft() ? rect.left() : rect.right() + 1, rect.top(), indentation(), rect.height()); opt.rect = QRect( !isRightToLeft() ? rect.left() : rect.right() + 1, rect.top(), indentation(), rect.height() );
painter->eraseRect(opt.rect); painter->eraseRect( opt.rect );
style()->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this); style()->drawPrimitive( QStyle::PE_IndicatorBranch, &opt, painter, this );
} }
} }

View File

@ -14,5 +14,5 @@ public:
using QTreeView::QTreeView; using QTreeView::QTreeView;
protected: 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;
}; };

View File

@ -56,9 +56,9 @@ PackageChooserViewStep::widget()
if ( !m_widget ) if ( !m_widget )
{ {
m_widget = new PackageChooserPage( m_config->mode(), nullptr ); m_widget = new PackageChooserPage( m_config->mode(), nullptr );
connect( m_widget, &PackageChooserPage::selectionChanged, [=]() { connect( m_widget,
emit nextStatusChanged( this->isNextEnabled() ); &PackageChooserPage::selectionChanged,
} ); [ = ]() { emit nextStatusChanged( this->isNextEnabled() ); } );
hookupModel(); hookupModel();
} }
return m_widget; return m_widget;

View File

@ -96,7 +96,8 @@ PlasmaLnfPage::PlasmaLnfPage( Config* config, QWidget* parent )
connect( view->selectionModel(), connect( view->selectionModel(),
&QItemSelectionModel::selectionChanged, &QItemSelectionModel::selectionChanged,
[this]( const QItemSelection& selected, const QItemSelection& ) { [ this ]( const QItemSelection& selected, const QItemSelection& )
{
auto i = selected.indexes(); auto i = selected.indexes();
if ( !i.isEmpty() ) if ( !i.isEmpty() )
{ {

View File

@ -45,16 +45,22 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent )
&QCheckBox::stateChanged, \ &QCheckBox::stateChanged, \
config->x##Tracking(), \ config->x##Tracking(), \
QOverload< bool >::of( &TrackingStyleConfig::setTracking ) ); \ QOverload< bool >::of( &TrackingStyleConfig::setTracking ) ); \
connect( config->x##Tracking(), &TrackingStyleConfig::trackingChanged, this, [this, config]() { \ connect( config->x##Tracking(), \
this->trackerChanged( config->x##Tracking(), this->ui->x##Group, this->ui->x##CheckBox ); \ &TrackingStyleConfig::trackingChanged, \
} ); \ this, \
connect( ui->x##PolicyButton, &QAbstractButton::clicked, config, [config] { \ [ this, config ]() \
QString url( config->x##Tracking()->policy() ); \ { this->trackerChanged( config->x##Tracking(), this->ui->x##Group, this->ui->x##CheckBox ); } ); \
if ( !url.isEmpty() ) \ connect( ui->x##PolicyButton, \
{ \ &QAbstractButton::clicked, \
QDesktopServices::openUrl( url ); \ config, \
} \ [ config ] \
} ); \ { \
QString url( config->x##Tracking()->policy() ); \
if ( !url.isEmpty() ) \
{ \
QDesktopServices::openUrl( url ); \
} \
} ); \
} while ( false ) } while ( false )
trackingSetup( install ); trackingSetup( install );
@ -63,16 +69,19 @@ TrackingPage::TrackingPage( Config* config, QWidget* parent )
#undef trackingSetup #undef trackingSetup
connect( config, &Config::generalPolicyChanged, [this]( const QString& url ) { connect( config,
this->ui->generalPolicyLabel->setVisible( !url.isEmpty() ); &Config::generalPolicyChanged,
} ); [ this ]( const QString& url ) { this->ui->generalPolicyLabel->setVisible( !url.isEmpty() ); } );
connect( ui->generalPolicyLabel, &QLabel::linkActivated, [config] { connect( ui->generalPolicyLabel,
QString url( config->generalPolicy() ); &QLabel::linkActivated,
if ( !url.isEmpty() ) [ config ]
{ {
QDesktopServices::openUrl( url ); QString url( config->generalPolicy() );
} if ( !url.isEmpty() )
} ); {
QDesktopServices::openUrl( url );
}
} );
retranslate(); retranslate();
} }

View File

@ -49,7 +49,7 @@ DEFINE_CHECK_FUNC( minLength )
{ {
cDebug() << Logger::SubEntry << "minLength set to" << minLength; cDebug() << Logger::SubEntry << "minLength set to" << minLength;
checks.push_back( PasswordCheck( []() { return QCoreApplication::translate( "PWQ", "Password is too short" ); }, 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 ) ) ); PasswordCheck::Weight( 10 ) ) );
} }
} }
@ -65,7 +65,7 @@ DEFINE_CHECK_FUNC( maxLength )
{ {
cDebug() << Logger::SubEntry << "maxLength set to" << maxLength; cDebug() << Logger::SubEntry << "maxLength set to" << maxLength;
checks.push_back( PasswordCheck( []() { return QCoreApplication::translate( "PWQ", "Password is too long" ); }, 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 ) ) ); PasswordCheck::Weight( 10 ) ) );
} }
} }
@ -378,8 +378,9 @@ DEFINE_CHECK_FUNC( libpwquality )
/* Something actually added? */ /* Something actually added? */
if ( requirement_count ) if ( requirement_count )
{ {
checks.push_back( PasswordCheck( [settings]() { return settings->explanation(); }, checks.push_back( PasswordCheck( [ settings ]() { return settings->explanation(); },
[settings]( const QString& s ) { [ settings ]( const QString& s )
{
int r = settings->check( s ); int r = settings->check( s );
if ( r < 0 ) if ( r < 0 )
{ {

View File

@ -165,7 +165,7 @@ WelcomePage::setupButton( Button role, const QString& url )
{ {
auto size = 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ); auto size = 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() );
button->setIcon( CalamaresUtils::defaultPixmap( icon, CalamaresUtils::Original, size ) ); 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 else
{ {

View File

@ -152,10 +152,10 @@ GeneralRequirements::checkRequirements()
{ {
checkEntries.append( checkEntries.append(
{ entry, { entry,
[req = m_requiredStorageGiB] { return tr( "has at least %1 GiB available drive space" ).arg( req ); }, [ req = m_requiredStorageGiB ]
[req = m_requiredStorageGiB] { { return tr( "has at least %1 GiB available drive space" ).arg( req ); },
return tr( "There is not enough drive space. At least %1 GiB is required." ).arg( req ); [ req = m_requiredStorageGiB ]
}, { return tr( "There is not enough drive space. At least %1 GiB is required." ).arg( req ); },
enoughStorage, enoughStorage,
m_entriesToRequire.contains( entry ) } ); m_entriesToRequire.contains( entry ) } );
} }
@ -163,8 +163,8 @@ GeneralRequirements::checkRequirements()
{ {
checkEntries.append( checkEntries.append(
{ entry, { entry,
[req = m_requiredRamGiB] { return tr( "has at least %1 GiB working memory" ).arg( req ); }, [ req = m_requiredRamGiB ] { return tr( "has at least %1 GiB working memory" ).arg( req ); },
[req = m_requiredRamGiB] { [ req = m_requiredRamGiB ] {
return tr( "The system does not have enough working memory. At least %1 GiB is required." ) return tr( "The system does not have enough working memory. At least %1 GiB is required." )
.arg( req ); .arg( req );
}, },
@ -191,7 +191,8 @@ GeneralRequirements::checkRequirements()
{ {
checkEntries.append( { entry, checkEntries.append( { entry,
[] { return tr( "is running the installer as an administrator (root)" ); }, [] { return tr( "is running the installer as an administrator (root)" ); },
[] { []
{
return Calamares::Settings::instance()->isSetupMode() return Calamares::Settings::instance()->isSetupMode()
? tr( "The setup program is not running with administrator rights." ) ? tr( "The setup program is not running with administrator rights." )
: tr( "The installer is not running with administrator rights." ); : tr( "The installer is not running with administrator rights." );
@ -203,7 +204,8 @@ GeneralRequirements::checkRequirements()
{ {
checkEntries.append( { entry, checkEntries.append( { entry,
[] { return tr( "has a screen large enough to show the whole installer" ); }, [] { return tr( "has a screen large enough to show the whole installer" ); },
[] { []
{
return Calamares::Settings::instance()->isSetupMode() 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 setup program." )
: tr( "The screen is too small to display the installer." ); : tr( "The screen is too small to display the installer." );

View File

@ -110,10 +110,11 @@ ResultsListDialog::ResultsListDialog( const Calamares::RequirementsModel& model,
m_title = new QLabel( this ); m_title = new QLabel( this );
m_title->setObjectName( "resultDialogTitle" ); m_title->setObjectName( "resultDialogTitle" );
createResultWidgets( createResultWidgets( entriesLayout,
entriesLayout, m_resultWidgets, model, []( const Calamares::RequirementsModel& m, QModelIndex i ) { m_resultWidgets,
return m.data( i, Calamares::RequirementsModel::HasDetails ).toBool(); model,
} ); []( const Calamares::RequirementsModel& m, QModelIndex i )
{ return m.data( i, Calamares::RequirementsModel::HasDetails ).toBool(); } );
QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close, Qt::Horizontal, this ); QDialogButtonBox* buttonBox = new QDialogButtonBox( QDialogButtonBox::Close, Qt::Horizontal, this );
buttonBox->setObjectName( "resultDialogButtons" ); buttonBox->setObjectName( "resultDialogButtons" );
@ -182,9 +183,8 @@ ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent )
// all *mandatory* entries are satisfied (gives errors if not). // all *mandatory* entries are satisfied (gives errors if not).
const bool requirementsSatisfied = config->requirementsModel()->satisfiedRequirements(); const bool requirementsSatisfied = config->requirementsModel()->satisfiedRequirements();
auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i ) { auto isUnSatisfied = []( const Calamares::RequirementsModel& m, QModelIndex i )
return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool(); { return !m.data( i, Calamares::RequirementsModel::Satisfied ).toBool(); };
};
createResultWidgets( entriesLayout, m_resultWidgets, *( config->requirementsModel() ), isUnSatisfied ); createResultWidgets( entriesLayout, m_resultWidgets, *( config->requirementsModel() ), isUnSatisfied );