From 7937cd625d977cd67c3c468ff69fb749d13a0e11 Mon Sep 17 00:00:00 2001 From: demmm Date: Fri, 13 May 2022 13:17:19 +0200 Subject: [PATCH 01/23] [localeq]Map.qml needed fixes esri has several bugs, not showing for all locations, zooming on Americas broken use osm as default, set preferred, so esri can be fallback remove Label section for mouse movement, showing coordinates not really useful, issue with mouse grabbing is back with it --- src/modules/localeq/Map.qml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/modules/localeq/Map.qml b/src/modules/localeq/Map.qml index 5972b5c15..ab0a01a58 100644 --- a/src/modules/localeq/Map.qml +++ b/src/modules/localeq/Map.qml @@ -1,6 +1,6 @@ /* === This file is part of Calamares - === * - * SPDX-FileCopyrightText: 2020 Anke Boersma + * SPDX-FileCopyrightText: 2020 - 2022 Anke Boersma * SPDX-License-Identifier: GPL-3.0-or-later * * Calamares is Free Software: see the License-Identifier above. @@ -112,7 +112,7 @@ Column { Plugin { id: mapPlugin - name: "esri" // "esri", "here", "itemsoverlay", "mapbox", "mapboxgl", "osm" + preferred: ["osm", "esri"] // "esri", "here", "itemsoverlay", "mapbox", "mapboxgl", "osm" } Map { @@ -121,7 +121,7 @@ Column { plugin: mapPlugin activeMapType: supportedMapTypes[0] //might be desirable to set zoom level configurable? - zoomLevel: 5 + zoomLevel: 7 bearing: 0 tilt: 0 copyrightsVisible : true @@ -167,12 +167,6 @@ Column { anchors.fill: map hoverEnabled: true property var coordinate: map.toCoordinate(Qt.point(mouseX, mouseY)) - Label { - x: parent.mouseX - width -5 - y: parent.mouseY - height - 5 - text: "%1, %2".arg( - parent.coordinate.latitude).arg(parent.coordinate.longitude) - } onClicked: { marker.coordinate = coordinate From 42841a217c8722420d7d51bfdb59acb59ca3abbd Mon Sep 17 00:00:00 2001 From: dalto Date: Fri, 13 May 2022 16:24:15 -0500 Subject: [PATCH 02/23] [partition] Don't offer whole disk encryption when zfs is selected --- src/modules/partition/gui/ChoicePage.cpp | 10 +++++++++- src/modules/partition/gui/EncryptWidget.cpp | 5 +++++ src/modules/partition/gui/EncryptWidget.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index c0845da7f..3076df61b 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -457,7 +457,6 @@ ChoicePage::continueApplyDeviceChoice() Q_EMIT deviceChosen(); } - void ChoicePage::onActionChanged() { @@ -466,6 +465,15 @@ ChoicePage::onActionChanged() { applyActionChoice( m_config->installChoice() ); } + + // Whole disk encryption isn't implemented for zfs so disable the option for now + if ( m_eraseFsTypesChoiceComboBox != nullptr && m_enableEncryptionWidget ) { + if ( m_eraseFsTypesChoiceComboBox->currentText() == "zfs" ) { + m_encryptWidget->hide(); + } else { + m_encryptWidget->show(); + } + } } void diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index fe7623050..f059e90b6 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -85,6 +85,11 @@ EncryptWidget::state() const return m_state; } +void EncryptWidget::setChecked(bool checked) +{ + m_ui->m_encryptCheckBox->setChecked(checked); +} + void EncryptWidget::setText( const QString& text ) diff --git a/src/modules/partition/gui/EncryptWidget.h b/src/modules/partition/gui/EncryptWidget.h index 5c24d68e6..88a6c93e1 100644 --- a/src/modules/partition/gui/EncryptWidget.h +++ b/src/modules/partition/gui/EncryptWidget.h @@ -36,6 +36,7 @@ public: void reset(); Encryption state() const; + void setChecked( bool checked ); void setText( const QString& text ); QString passphrase() const; From 152f99fb07e51fd126b1a7155f820454619b8736 Mon Sep 17 00:00:00 2001 From: dalto Date: Fri, 13 May 2022 17:24:07 -0500 Subject: [PATCH 03/23] Remove useless emits --- src/libcalamares/modulesystem/RequirementsModel.cpp | 4 ++-- src/modules/netinstall/PackageModel.cpp | 8 ++++---- src/modules/summary/Config.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcalamares/modulesystem/RequirementsModel.cpp b/src/libcalamares/modulesystem/RequirementsModel.cpp index 6a7e0a5b4..3a0c85ccd 100644 --- a/src/libcalamares/modulesystem/RequirementsModel.cpp +++ b/src/libcalamares/modulesystem/RequirementsModel.cpp @@ -19,10 +19,10 @@ void RequirementsModel::addRequirementsList( const Calamares::RequirementsList& requirements ) { QMutexLocker l( &m_addLock ); - emit beginResetModel(); + beginResetModel(); m_requirements.append( requirements ); changeRequirementsList(); - emit endResetModel(); + endResetModel(); } void diff --git a/src/modules/netinstall/PackageModel.cpp b/src/modules/netinstall/PackageModel.cpp index 256a77afd..d5bae1c89 100644 --- a/src/modules/netinstall/PackageModel.cpp +++ b/src/modules/netinstall/PackageModel.cpp @@ -349,11 +349,11 @@ PackageModel::setupModelData( const QVariantList& groupList, PackageTreeItem* pa void PackageModel::setupModelData( const QVariantList& l ) { - Q_EMIT beginResetModel(); + beginResetModel(); delete m_rootItem; m_rootItem = new PackageTreeItem(); setupModelData( l, m_rootItem ); - Q_EMIT endResetModel(); + endResetModel(); } void @@ -361,7 +361,7 @@ PackageModel::appendModelData( const QVariantList& groupList ) { if ( m_rootItem ) { - Q_EMIT beginResetModel(); + beginResetModel(); const QStringList sources = collectSources( groupList ); @@ -386,6 +386,6 @@ PackageModel::appendModelData( const QVariantList& groupList ) // Add the new data to the model setupModelData( groupList, m_rootItem ); - Q_EMIT endResetModel(); + endResetModel(); } } diff --git a/src/modules/summary/Config.cpp b/src/modules/summary/Config.cpp index 9038f786f..6eddfa3f7 100644 --- a/src/modules/summary/Config.cpp +++ b/src/modules/summary/Config.cpp @@ -61,7 +61,7 @@ SummaryModel::rowCount( const QModelIndex& ) const void SummaryModel::setSummaryList( const Calamares::ViewStepList& steps, bool withWidgets ) { - Q_EMIT beginResetModel(); + beginResetModel(); m_summary.clear(); for ( Calamares::ViewStep* step : steps ) @@ -76,7 +76,7 @@ SummaryModel::setSummaryList( const Calamares::ViewStepList& steps, bool withWid m_summary << StepSummary { step->prettyName(), text, widget }; } - Q_EMIT endResetModel(); + endResetModel(); } Config::Config( QObject* parent ) From 31c812367726d2692feaa7dc6379e05a9f42f0b5 Mon Sep 17 00:00:00 2001 From: dalto Date: Sat, 14 May 2022 10:38:27 -0500 Subject: [PATCH 04/23] [partition] Remove no longer needed setChecked() in the encryption widget --- src/modules/partition/gui/EncryptWidget.cpp | 5 ----- src/modules/partition/gui/EncryptWidget.h | 1 - 2 files changed, 6 deletions(-) diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index f059e90b6..fe7623050 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -85,11 +85,6 @@ EncryptWidget::state() const return m_state; } -void EncryptWidget::setChecked(bool checked) -{ - m_ui->m_encryptCheckBox->setChecked(checked); -} - void EncryptWidget::setText( const QString& text ) diff --git a/src/modules/partition/gui/EncryptWidget.h b/src/modules/partition/gui/EncryptWidget.h index 88a6c93e1..5c24d68e6 100644 --- a/src/modules/partition/gui/EncryptWidget.h +++ b/src/modules/partition/gui/EncryptWidget.h @@ -36,7 +36,6 @@ public: void reset(); Encryption state() const; - void setChecked( bool checked ); void setText( const QString& text ); QString passphrase() const; From cd4b8d4179cce5465918c594952c8a7e440c5e98 Mon Sep 17 00:00:00 2001 From: abalfoort Date: Mon, 16 May 2022 15:06:33 +0200 Subject: [PATCH 05/23] Reuse luks partitions --- src/modules/partition/core/KPMHelpers.cpp | 296 +++++++++++------- src/modules/partition/core/KPMHelpers.h | 90 +++--- .../gui/EditExistingPartitionDialog.cpp | 77 ++++- .../gui/EditExistingPartitionDialog.h | 6 + .../gui/EditExistingPartitionDialog.ui | 43 ++- src/modules/partition/gui/EncryptWidget.cpp | 9 +- src/modules/partition/gui/EncryptWidget.h | 2 +- 7 files changed, 352 insertions(+), 171 deletions(-) diff --git a/src/modules/partition/core/KPMHelpers.cpp b/src/modules/partition/core/KPMHelpers.cpp index d5086ef21..003d47088 100644 --- a/src/modules/partition/core/KPMHelpers.cpp +++ b/src/modules/partition/core/KPMHelpers.cpp @@ -22,128 +22,210 @@ #include #include #include +#include +#include using CalamaresUtils::Partition::PartitionIterator; namespace KPMHelpers { -Partition* -findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ) -{ - for ( auto device : devices ) - for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) - if ( PartitionInfo::mountPoint( *it ) == mountPoint ) - { - return *it; - } - return nullptr; -} - - -Partition* -createNewPartition( PartitionNode* parent, - const Device& device, - const PartitionRole& role, - FileSystem::Type fsType, - const QString& fsLabel, - qint64 firstSector, - qint64 lastSector, - PartitionTable::Flags flags ) -{ - FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() ); - fs->setLabel( fsLabel ); - return new Partition( parent, - device, - role, - fs, - fs->firstSector(), - fs->lastSector(), - QString() /* path */, - KPM_PARTITION_FLAG( None ) /* availableFlags */, - QString() /* mountPoint */, - false /* mounted */, - flags /* activeFlags */, - KPM_PARTITION_STATE( New ) ); -} - - -Partition* -createNewEncryptedPartition( PartitionNode* parent, - const Device& device, - const PartitionRole& role, - FileSystem::Type fsType, - const QString& fsLabel, - qint64 firstSector, - qint64 lastSector, - const QString& passphrase, - PartitionTable::Flags flags ) -{ - PartitionRole::Roles newRoles = role.roles(); - if ( !role.has( PartitionRole::Luks ) ) + Partition* + findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ) { - newRoles |= PartitionRole::Luks; - } - - FS::luks* fs = dynamic_cast< FS::luks* >( - FileSystemFactory::create( FileSystem::Luks, firstSector, lastSector, device.logicalSize() ) ); - if ( !fs ) - { - cError() << "cannot create LUKS filesystem. Giving up."; + for ( auto device : devices ) + for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) + if ( PartitionInfo::mountPoint( *it ) == mountPoint ) + { + return *it; + } return nullptr; } - fs->createInnerFileSystem( fsType ); - fs->setPassphrase( passphrase ); - fs->setLabel( fsLabel ); - Partition* p = new Partition( parent, - device, - PartitionRole( newRoles ), - fs, - fs->firstSector(), - fs->lastSector(), - QString() /* path */, - KPM_PARTITION_FLAG( None ) /* availableFlags */, - QString() /* mountPoint */, - false /* mounted */, - flags /* activeFlags */, - KPM_PARTITION_STATE( New ) ); - return p; -} - -Partition* -clonePartition( Device* device, Partition* partition ) -{ - FileSystem* fs = FileSystemFactory::create( - partition->fileSystem().type(), partition->firstSector(), partition->lastSector(), device->logicalSize() ); - return new Partition( partition->parent(), - *device, - partition->roles(), - fs, - fs->firstSector(), - fs->lastSector(), - partition->partitionPath(), - partition->activeFlags() ); -} - -Calamares::JobResult -execute( Operation& operation, const QString& failureMessage ) -{ - operation.setStatus( Operation::StatusRunning ); - - Report report( nullptr ); - if ( operation.execute( report ) ) + Partition* + createNewPartition( PartitionNode* parent, + const Device& device, + const PartitionRole& role, + FileSystem::Type fsType, + const QString& fsLabel, + qint64 firstSector, + qint64 lastSector, + PartitionTable::Flags flags ) { - return Calamares::JobResult::ok(); + FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() ); + fs->setLabel( fsLabel ); + return new Partition( parent, + device, + role, + fs, + fs->firstSector(), + fs->lastSector(), + QString() /* path */, + KPM_PARTITION_FLAG( None ) /* availableFlags */, + QString() /* mountPoint */, + false /* mounted */, + flags /* activeFlags */, + KPM_PARTITION_STATE( New ) ); } - // Remove the === lines from the report by trimming them to empty - QStringList l = report.toText().split( '\n' ); - std::for_each( l.begin(), l.end(), []( QString& s ) { CalamaresUtils::removeLeading( s, '=' ); } ); - return Calamares::JobResult::error( failureMessage, l.join( '\n' ) ); -} + Partition* + createNewEncryptedPartition( PartitionNode* parent, + const Device& device, + const PartitionRole& role, + FileSystem::Type fsType, + const QString& fsLabel, + qint64 firstSector, + qint64 lastSector, + const QString& passphrase, + PartitionTable::Flags flags ) + { + PartitionRole::Roles newRoles = role.roles(); + if ( !role.has( PartitionRole::Luks ) ) + { + newRoles |= PartitionRole::Luks; + } + + FS::luks* fs = dynamic_cast< FS::luks* >( + FileSystemFactory::create( FileSystem::Luks, firstSector, lastSector, device.logicalSize() ) ); + if ( !fs ) + { + cError() << "cannot create LUKS filesystem. Giving up."; + return nullptr; + } + + fs->createInnerFileSystem( fsType ); + fs->setPassphrase( passphrase ); + fs->setLabel( fsLabel ); + Partition* p = new Partition( parent, + device, + PartitionRole( newRoles ), + fs, + fs->firstSector(), + fs->lastSector(), + QString() /* path */, + KPM_PARTITION_FLAG( None ) /* availableFlags */, + QString() /* mountPoint */, + false /* mounted */, + flags /* activeFlags */, + KPM_PARTITION_STATE( New ) ); + return p; + } + + + Partition* + clonePartition( Device* device, Partition* partition ) + { + FileSystem* fs = FileSystemFactory::create( + partition->fileSystem().type(), partition->firstSector(), partition->lastSector(), device->logicalSize() ); + return new Partition( partition->parent(), + *device, + partition->roles(), + fs, + fs->firstSector(), + fs->lastSector(), + partition->partitionPath(), + partition->activeFlags() ); + } + + // Adapted from luks cryptOpen which always opens a dialog to ask for a passphrase + int + updateLuksDevice( Partition* partition, const QString& passphrase ) + { + const QString deviceNode = partition->partitionPath(); + + cDebug() << "Update Luks device: " << deviceNode; + + if ( passphrase.isEmpty() ) + { + cWarning() << Logger::SubEntry << "#1: Passphrase is empty"; + return 1; + } + + if ( partition->fileSystem().type() != FileSystem::Luks ) + { + cWarning() << Logger::SubEntry << "#2: Not a luks encrypted device"; + return 2; + } + + // Cast partition fs to luks fs + FS::luks* luksFs = dynamic_cast< FS::luks* >( &partition->fileSystem() ); + + // Test the given passphrase + if ( !luksFs->testPassphrase( deviceNode, passphrase ) ) + { + cWarning() << Logger::SubEntry << "#3: Passphrase incorrect"; + return 3; + } + + if ( luksFs->isCryptOpen() ) + { + if ( !luksFs->mapperName().isEmpty()) + { + cWarning() << Logger::SubEntry << "#4: Device already decrypted"; + return 4; + } + else + { + cDebug() << Logger::SubEntry << "No mapper node found"; + luksFs->setCryptOpen( false ); + } + } + + ExternalCommand openCmd( QStringLiteral( "cryptsetup" ), + { QStringLiteral( "open" ), + deviceNode, + luksFs->suggestedMapperName( deviceNode ) } ); + + if ( !( openCmd.write( passphrase.toLocal8Bit() + '\n' ) && + openCmd.start( -1 ) && + openCmd.exitCode() == 0 ) ) + { + cWarning() << Logger::SubEntry << openCmd.exitCode() << ": cryptsetup command failed"; + return openCmd.exitCode(); + } + + // Save the existing passphrase + luksFs->setPassphrase( passphrase ); + + luksFs->scan( deviceNode ); + + if ( luksFs->mapperName().isEmpty() ) + { + cWarning() << Logger::SubEntry << "#5: No mapper node found"; + return 5; + } + + luksFs->loadInnerFileSystem( luksFs->mapperName() ); + luksFs->setCryptOpen( luksFs->innerFS() != nullptr ); + + if ( !luksFs->isCryptOpen() ) + { + cWarning() << Logger::SubEntry << "#6: Device could not be decrypted"; + return 6; + } + + return 0; + } + + Calamares::JobResult + execute( Operation& operation, const QString& failureMessage ) + { + operation.setStatus( Operation::StatusRunning ); + + Report report( nullptr ); + if ( operation.execute( report ) ) + { + return Calamares::JobResult::ok(); + } + + // Remove the === lines from the report by trimming them to empty + QStringList l = report.toText().split( '\n' ); + std::for_each( l.begin(), l.end(), []( QString& s ) { CalamaresUtils::removeLeading( s, '=' ); } ); + + return Calamares::JobResult::error( failureMessage, l.join( '\n' ) ); + } } // namespace KPMHelpers diff --git a/src/modules/partition/core/KPMHelpers.h b/src/modules/partition/core/KPMHelpers.h index 2f867bc25..b958b3866 100644 --- a/src/modules/partition/core/KPMHelpers.h +++ b/src/modules/partition/core/KPMHelpers.h @@ -43,54 +43,56 @@ class PartitionRole; namespace KPMHelpers { -/** - * Iterates on all devices and return the first partition which is associated - * with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint() - */ -Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ); + /** + * Iterates on all devices and return the first partition which is associated + * with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint() + */ + Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ); -/** - * Helper function to create a new Partition object (does not create anything - * on the disk) associated with a FileSystem. - */ -Partition* createNewPartition( PartitionNode* parent, - const Device& device, - const PartitionRole& role, - FileSystem::Type fsType, - const QString& fsLabel, - qint64 firstSector, - qint64 lastSector, - PartitionTable::Flags flags ); + /** + * Helper function to create a new Partition object (does not create anything + * on the disk) associated with a FileSystem. + */ + Partition* createNewPartition( PartitionNode* parent, + const Device& device, + const PartitionRole& role, + FileSystem::Type fsType, + const QString& fsLabel, + qint64 firstSector, + qint64 lastSector, + PartitionTable::Flags flags ); -Partition* createNewEncryptedPartition( PartitionNode* parent, - const Device& device, - const PartitionRole& role, - FileSystem::Type fsType, - const QString& fsLabel, - qint64 firstSector, - qint64 lastSector, - const QString& passphrase, - PartitionTable::Flags flags ); + Partition* createNewEncryptedPartition( PartitionNode* parent, + const Device& device, + const PartitionRole& role, + FileSystem::Type fsType, + const QString& fsLabel, + qint64 firstSector, + qint64 lastSector, + const QString& passphrase, + PartitionTable::Flags flags ); -Partition* clonePartition( Device* device, Partition* partition ); + Partition* clonePartition( Device* device, Partition* partition ); -/** @brief Return a result for an @p operation - * - * Executes the operation, and if successful, returns a success result. - * Otherwise returns an error using @p failureMessage as the primary part - * of the error, and details obtained from the operation. - */ -Calamares::JobResult execute( Operation& operation, const QString& failureMessage ); -/** @brief Return a result for an @p operation - * - * It's acceptable to use an rvalue: the operation-running is the effect - * you're interested in, rather than keeping the temporary around. - */ -static inline Calamares::JobResult -execute( Operation&& operation, const QString& failureMessage ) -{ - return execute( operation, failureMessage ); -} + int updateLuksDevice( Partition* partition, const QString& passphrase ); + + /** @brief Return a result for an @p operation + * + * Executes the operation, and if successful, returns a success result. + * Otherwise returns an error using @p failureMessage as the primary part + * of the error, and details obtained from the operation. + */ + Calamares::JobResult execute( Operation& operation, const QString& failureMessage ); + /** @brief Return a result for an @p operation + * + * It's acceptable to use an rvalue: the operation-running is the effect + * you're interested in, rather than keeping the temporary around. + */ + static inline Calamares::JobResult + execute( Operation&& operation, const QString& failureMessage ) + { + return execute( operation, failureMessage ); + } } // namespace KPMHelpers diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index 0bc35cabe..4883edd76 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -20,6 +20,7 @@ #include "core/PartUtils.h" #include "core/PartitionCoreModule.h" #include "core/PartitionInfo.h" +#include "core/KPMHelpers.h" #include "gui/PartitionDialogHelpers.h" #include "gui/PartitionSizeController.h" @@ -28,14 +29,18 @@ #include "Settings.h" #include "partition/FileSystem.h" #include "utils/Logger.h" +#include "widgets/TranslationFix.h" #include #include #include +#include #include #include #include +#include +#include using CalamaresUtils::Partition::untranslatedFS; using CalamaresUtils::Partition::userVisibleFS; @@ -52,6 +57,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, , m_usedMountPoints( usedMountPoints ) { m_ui->setupUi( this ); + m_ui->encryptWidget->hide(); standardMountPoints( *( m_ui->mountPointComboBox ), PartitionInfo::mountPoint( partition ) ); QColor color = ColorUtils::colorForPartition( m_partition ); @@ -132,10 +138,8 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, setFlagList( *( m_ui->m_listFlags ), m_partition->availableFlags(), PartitionInfo::flags( m_partition ) ); } - EditExistingPartitionDialog::~EditExistingPartitionDialog() {} - PartitionTable::Flags EditExistingPartitionDialog::newFlags() const { @@ -242,8 +246,31 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core ) { core->setFilesystemLabel( m_device, m_partition, fsLabel ); } + core->refreshPartition( m_device, m_partition ); } + + // Update the existing luks partition + const QString passphrase = m_ui->encryptWidget->passphrase(); + if ( !passphrase.isEmpty() ) + { + int retCode = KPMHelpers::updateLuksDevice( m_partition, passphrase ); + if ( retCode != 0 ) + { + QString message = tr( "Passphrase for existing partition" ); + QString description = tr( "Partition %1 could not be decrypted " + "with the given passphrase." + "

" + "Edit the partition again and give the correct passphrase" + "or delete and create a new encrypted partition." ) + .arg( m_partition->partitionPath() ); + + QMessageBox mb( QMessageBox::Information, message, description, + QMessageBox::Ok, this->parentWidget() ); + Calamares::fixButtonLabels( &mb ); + mb.exec(); + } + } } } @@ -266,7 +293,6 @@ EditExistingPartitionDialog::replacePartResizerWidget() m_partitionSizeController->setPartResizerWidget( widget, m_ui->formatRadioButton->isChecked() ); } - void EditExistingPartitionDialog::updateMountPointPicker() { @@ -293,13 +319,50 @@ EditExistingPartitionDialog::updateMountPointPicker() { setSelectedMountPoint( m_ui->mountPointComboBox, QString() ); } + + toggleEncryptWidget(); + } void EditExistingPartitionDialog::checkMountPointSelection() { - validateMountPoint( selectedMountPoint( m_ui->mountPointComboBox ), - m_usedMountPoints, - m_ui->mountPointExplanation, - m_ui->buttonBox->button( QDialogButtonBox::Ok ) ); + if ( validateMountPoint( selectedMountPoint( m_ui->mountPointComboBox ), + m_usedMountPoints, + m_ui->mountPointExplanation, + m_ui->buttonBox->button( QDialogButtonBox::Ok ) ) ) + { + toggleEncryptWidget(); + } +} + +void +EditExistingPartitionDialog::toggleEncryptWidget() +{ + // Show/hide encryptWidget: + // check if partition is a previously luks formatted partition + // and not currently formatted + // and its mount point not a standard mount point except when it's /home + QString mp = selectedMountPoint( m_ui->mountPointComboBox ); + if ( !mp.isEmpty() + && m_partition->fileSystem().type() == FileSystem::Luks + && !m_ui->formatRadioButton->isChecked() + && ( !standardMountPoints().contains(mp) || mp == "/home" ) ) + { + m_ui->encryptWidget->show(); + m_ui->encryptWidget->reset( false ); + } + // TODO: When formatting a partition user must be able to encrypt that partition + // Probably need to delete this partition and create a new one + // else if ( m_ui->formatRadioButton->isChecked() + // && !mp.isEmpty()) + // { + // m_ui->encryptWidget->show(); + // m_ui->encryptWidget->reset(); + // } + else + { + m_ui->encryptWidget->reset(); + m_ui->encryptWidget->hide(); + } } diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.h b/src/modules/partition/gui/EditExistingPartitionDialog.h index 89b5b55e4..a912c577d 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.h +++ b/src/modules/partition/gui/EditExistingPartitionDialog.h @@ -32,6 +32,11 @@ class EditExistingPartitionDialog : public QDialog { Q_OBJECT public: + struct FreeSpace + { + Partition* p; + }; + EditExistingPartitionDialog( Device* device, Partition* partition, const QStringList& usedMountPoints, @@ -53,6 +58,7 @@ private: PartitionTable::Flags newFlags() const; void replacePartResizerWidget(); void updateMountPointPicker(); + void toggleEncryptWidget(); }; #endif /* EDITEXISTINGPARTITIONDIALOG_H */ diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.ui b/src/modules/partition/gui/EditExistingPartitionDialog.ui index 4a9982656..ff9cc33c5 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.ui +++ b/src/modules/partition/gui/EditExistingPartitionDialog.ui @@ -10,8 +10,8 @@ SPDX-License-Identifier: GPL-3.0-or-later 0 0 - 450 - 615 + 570 + 689 @@ -97,7 +97,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - + &Mount Point: @@ -107,7 +107,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - + @@ -153,14 +153,14 @@ SPDX-License-Identifier: GPL-3.0-or-later - + Flags: - + true @@ -173,7 +173,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - + Label for the filesystem @@ -183,20 +183,39 @@ SPDX-License-Identifier: GPL-3.0-or-later - + FS Label: - + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 13 + + + + @@ -218,6 +237,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
kpmcore/gui/partresizerwidget.h
1 + + EncryptWidget + QWidget +
gui/EncryptWidget.h
+ 1 +
sizeSpinBox diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index fe7623050..7efe0ea1a 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -70,14 +70,17 @@ EncryptWidget::EncryptWidget( QWidget* parent ) void -EncryptWidget::reset() +EncryptWidget::reset( bool checkVisible ) { m_ui->m_passphraseLineEdit->clear(); m_ui->m_confirmLineEdit->clear(); m_ui->m_encryptCheckBox->setChecked( false ); -} + m_ui->m_encryptCheckBox->setVisible( checkVisible ); + m_ui->m_passphraseLineEdit->setVisible( !checkVisible ); + m_ui->m_confirmLineEdit->setVisible( !checkVisible ); +} EncryptWidget::Encryption EncryptWidget::state() const @@ -146,7 +149,7 @@ EncryptWidget::updateState() } Encryption newState; - if ( m_ui->m_encryptCheckBox->isChecked() ) + if ( m_ui->m_encryptCheckBox->isChecked() || !m_ui->m_encryptCheckBox->isVisible()) { if ( !m_ui->m_passphraseLineEdit->text().isEmpty() && m_ui->m_passphraseLineEdit->text() == m_ui->m_confirmLineEdit->text() ) diff --git a/src/modules/partition/gui/EncryptWidget.h b/src/modules/partition/gui/EncryptWidget.h index 5c24d68e6..704365817 100644 --- a/src/modules/partition/gui/EncryptWidget.h +++ b/src/modules/partition/gui/EncryptWidget.h @@ -33,7 +33,7 @@ public: explicit EncryptWidget( QWidget* parent = nullptr ); - void reset(); + void reset( bool checkVisible = true ); Encryption state() const; void setText( const QString& text ); From 25a6a5ee53e99229ceb93fe6a7c9b01c6fa6498e Mon Sep 17 00:00:00 2001 From: abalfoort Date: Mon, 16 May 2022 15:06:59 +0200 Subject: [PATCH 06/23] Fix crypttab --- src/modules/fstab/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py index 1cfb5e660..95f10a643 100755 --- a/src/modules/fstab/main.py +++ b/src/modules/fstab/main.py @@ -162,13 +162,18 @@ class FstabGenerator(object): crypttab_options = self.crypttab_options # Set crypttab password for partition to none and remove crypttab options + # if crypto_keyfile.bin was not generated + if not os.path.exists(os.path.join(self.root_mount_point, "crypto_keyfile.bin")): + password = "none" + crypttab_options = "" # on root partition when /boot is unencrypted - if partition["mountPoint"] == "/": + elif partition["mountPoint"] == "/": if any([p["mountPoint"] == "/boot" and "luksMapperName" not in p for p in self.partitions]): password = "none" crypttab_options = "" + return dict( name=mapper_name, From f67df577db886d387800ee88815a1cc2a1d2f3ac Mon Sep 17 00:00:00 2001 From: abalfoort Date: Mon, 16 May 2022 15:08:11 +0200 Subject: [PATCH 07/23] Fix compilation warning --- src/modules/partition/Config.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/Config.cpp b/src/modules/partition/Config.cpp index 550e17460..367c4ee38 100644 --- a/src/modules/partition/Config.cpp +++ b/src/modules/partition/Config.cpp @@ -251,7 +251,9 @@ fillGSConfigurationEFI( Calamares::GlobalStorage* gs, const QVariantMap& configu gs->insert( "efiSystemPartitionSize", sizeString ); gs->insert( "efiSystemPartitionSize_i", part_size.toBytes() ); - if ( part_size.toBytes() != PartUtils::efiFilesystemMinimumSize() ) + // Assign long long int to long unsigned int to prevent compilation warning + size_t unsigned_part_size = part_size.toBytes(); + if ( unsigned_part_size != PartUtils::efiFilesystemMinimumSize() ) { cWarning() << "EFI partition size" << sizeString << "has been adjusted to" << PartUtils::efiFilesystemMinimumSize() << "bytes"; From 4a4d872bb077462c0d8e032e7ec10ddf30fca778 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 17 May 2022 10:51:36 +0200 Subject: [PATCH 08/23] Docs: offer alternative Matrix webchat link --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e79d9a72..b9aed79c8 100644 --- a/README.md +++ b/README.md @@ -65,5 +65,6 @@ that chat window open because it can easily take a few hours for someone to notice a message. Matrix is persistent, and we'll see your message eventually. -* [![Join us on Matrix](https://img.shields.io/badge/Matrix-%23calamares:kde.org-blue)](https://webchat.kde.org/#/room/%23calamares:kde.org) +* [![Join us on Matrix](https://img.shields.io/badge/Matrix-%23calamares:kde.org-blue)](https://webchat.kde.org/#/room/%23calamares:kde.org) (KDE webchat, may need an account) +* [![Join us on Matrix](https://img.shields.io/badge/Matrix-%23calamares:kde.org-blue)](https://app.element.io/#/room/%23calamares:kde.org) (Element webchat) * [![Chat on IRC](https://img.shields.io/badge/IRC-Libera.Chat%20%23calamares-green)](https://kiwiirc.com/client/irc.libera.chat/#calamares) From 67ad12c2d0a842de9a04b629db7539ab38e0f618 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 17 May 2022 11:01:06 +0200 Subject: [PATCH 09/23] Docs: suggest IRC for non-account chat --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b9aed79c8..570adf575 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,5 @@ that chat window open because it can easily take a few hours for someone to notice a message. Matrix is persistent, and we'll see your message eventually. -* [![Join us on Matrix](https://img.shields.io/badge/Matrix-%23calamares:kde.org-blue)](https://webchat.kde.org/#/room/%23calamares:kde.org) (KDE webchat, may need an account) -* [![Join us on Matrix](https://img.shields.io/badge/Matrix-%23calamares:kde.org-blue)](https://app.element.io/#/room/%23calamares:kde.org) (Element webchat) -* [![Chat on IRC](https://img.shields.io/badge/IRC-Libera.Chat%20%23calamares-green)](https://kiwiirc.com/client/irc.libera.chat/#calamares) +* [![Join us on Matrix](https://img.shields.io/badge/Matrix-%23calamares:kde.org-blue)](https://webchat.kde.org/#/room/%23calamares:kde.org) (needs a Matrix account) +* [![Chat on IRC](https://img.shields.io/badge/IRC-Libera.Chat%20%23calamares-green)](https://kiwiirc.com/client/irc.libera.chat/#calamares) (IRC supports guest accounts) From 6bf710bed371be07ef798f0631557b08d6988c82 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 17 May 2022 14:38:44 +0200 Subject: [PATCH 10/23] [netinstall] Introduce a custom class for the Tree Widget --- src/modules/netinstall/groupstreeview.h | 3 +++ src/modules/netinstall/page_netinst.ui | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/modules/netinstall/groupstreeview.h diff --git a/src/modules/netinstall/groupstreeview.h b/src/modules/netinstall/groupstreeview.h new file mode 100644 index 000000000..50ed82bcf --- /dev/null +++ b/src/modules/netinstall/groupstreeview.h @@ -0,0 +1,3 @@ +#include + +using GroupsTreeView = QTreeView; diff --git a/src/modules/netinstall/page_netinst.ui b/src/modules/netinstall/page_netinst.ui index f17e939cd..dd87ef7c4 100644 --- a/src/modules/netinstall/page_netinst.ui +++ b/src/modules/netinstall/page_netinst.ui @@ -36,13 +36,13 @@ SPDX-License-Identifier: GPL-3.0-or-later true - + 0 0 981 - 407 + 410 @@ -63,6 +63,13 @@ SPDX-License-Identifier: GPL-3.0-or-later
+ + + GroupsTreeView + QTreeView +
groupstreeview.h
+
+
From 9e2728bcb726a08186ac7af4b6ec4a2c751dcc91 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 17 May 2022 14:40:36 +0200 Subject: [PATCH 11/23] [netinstall] Polish up SPDX headers --- src/modules/netinstall/NetInstallPage.h | 3 ++- src/modules/netinstall/NetInstallViewStep.cpp | 3 ++- src/modules/netinstall/PackageModel.h | 1 - src/modules/netinstall/groupstreeview.h | 8 ++++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/netinstall/NetInstallPage.h b/src/modules/netinstall/NetInstallPage.h index 72375d0f0..94ce6d4ba 100644 --- a/src/modules/netinstall/NetInstallPage.h +++ b/src/modules/netinstall/NetInstallPage.h @@ -1,4 +1,5 @@ -/* +/* === This file is part of Calamares - === + * * SPDX-FileCopyrightText: 2016 Luca Giambonini * SPDX-FileCopyrightText: 2016 Lisa Vitolo * SPDX-FileCopyrightText: 2017 Kyle Robbertze diff --git a/src/modules/netinstall/NetInstallViewStep.cpp b/src/modules/netinstall/NetInstallViewStep.cpp index 2ac0e73c9..99d51af9e 100644 --- a/src/modules/netinstall/NetInstallViewStep.cpp +++ b/src/modules/netinstall/NetInstallViewStep.cpp @@ -1,4 +1,5 @@ -/* +/* === This file is part of Calamares - === + * * SPDX-FileCopyrightText: 2016 Luca Giambonini * SPDX-FileCopyrightText: 2016 Lisa Vitolo * SPDX-FileCopyrightText: 2017 Kyle Robbertze diff --git a/src/modules/netinstall/PackageModel.h b/src/modules/netinstall/PackageModel.h index e97359a46..cc8668b2f 100644 --- a/src/modules/netinstall/PackageModel.h +++ b/src/modules/netinstall/PackageModel.h @@ -1,4 +1,3 @@ - /* === This file is part of Calamares - === * * SPDX-FileCopyrightText: 2017 Kyle Robbertze diff --git a/src/modules/netinstall/groupstreeview.h b/src/modules/netinstall/groupstreeview.h index 50ed82bcf..a22ea7016 100644 --- a/src/modules/netinstall/groupstreeview.h +++ b/src/modules/netinstall/groupstreeview.h @@ -1,3 +1,11 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2022 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ #include using GroupsTreeView = QTreeView; From 542aa5c08389b5a86de492f13e4efc9b44f32a13 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 17 May 2022 23:29:37 +0200 Subject: [PATCH 12/23] SPDX: tag the ignore-revs file, too --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index cbf236645..f9955e460 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1 +1,4 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# 18fef8dfe5d926ec0bc979562553adf4db8db2e9 From 62f3055e5a7ca6fc0a55060857e5ea8760b803df Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 00:25:04 +0200 Subject: [PATCH 13/23] [netinstall] Implement a special "blank" item - If the name of an item is empty, treat it as a "separator line", do not paint it like a regular item. The branches of the tree just pass it by. --- src/modules/netinstall/CMakeLists.txt | 1 + src/modules/netinstall/groupstreeview.cpp | 30 +++++++++++++++++++++++ src/modules/netinstall/groupstreeview.h | 9 ++++++- 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/modules/netinstall/groupstreeview.cpp diff --git a/src/modules/netinstall/CMakeLists.txt b/src/modules/netinstall/CMakeLists.txt index f31ac6d79..13c6fa0ce 100644 --- a/src/modules/netinstall/CMakeLists.txt +++ b/src/modules/netinstall/CMakeLists.txt @@ -8,6 +8,7 @@ calamares_add_plugin( netinstall EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES Config.cpp + groupstreeview.cpp LoaderQueue.cpp NetInstallViewStep.cpp NetInstallPage.cpp diff --git a/src/modules/netinstall/groupstreeview.cpp b/src/modules/netinstall/groupstreeview.cpp new file mode 100644 index 000000000..226fccc7e --- /dev/null +++ b/src/modules/netinstall/groupstreeview.cpp @@ -0,0 +1,30 @@ +/* === This file is part of Calamares - === + * + * SPDX-FileCopyrightText: 2022 Adriaan de Groot + * SPDX-License-Identifier: GPL-3.0-or-later + * + * Calamares is Free Software: see the License-Identifier above. + * + */ +#include "groupstreeview.h" + +#include "utils/Logger.h" + +#include + +void GroupsTreeView::drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const +{ + 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()) + { + 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); + } +} diff --git a/src/modules/netinstall/groupstreeview.h b/src/modules/netinstall/groupstreeview.h index a22ea7016..fb096db58 100644 --- a/src/modules/netinstall/groupstreeview.h +++ b/src/modules/netinstall/groupstreeview.h @@ -8,4 +8,11 @@ */ #include -using GroupsTreeView = QTreeView; +class GroupsTreeView : public QTreeView +{ +public: + using QTreeView::QTreeView; + +protected: + virtual void drawBranches(QPainter*painter, const QRect& rect, const QModelIndex& index) const override; +}; From cf5f0e1caa088465743653ba17c4b99eef074731 Mon Sep 17 00:00:00 2001 From: Calamares CI Date: Wed, 18 May 2022 11:52:43 +0200 Subject: [PATCH 14/23] i18n: [calamares] Automatic merge of Transifex translations --- lang/calamares_oc.ts | 253 ++++++++++++++++++++++--------------------- lang/calamares_pl.ts | 84 +++++++------- 2 files changed, 169 insertions(+), 168 deletions(-) diff --git a/lang/calamares_oc.ts b/lang/calamares_oc.ts index 924a4444e..ad8d41b3a 100644 --- a/lang/calamares_oc.ts +++ b/lang/calamares_oc.ts @@ -37,17 +37,17 @@ Boot Partition - + Particion d’aviada System Partition - + Particion sistèma Do not install a boot loader - + Installar pas lo gestionari d'aviada @@ -83,12 +83,12 @@ Modules - + Moduls Type: - + Tipe : @@ -124,7 +124,7 @@ Reload Stylesheet - + Recargar fuèlh d’estil @@ -139,7 +139,7 @@ Debug information - + Informacions de desbugatge @@ -194,12 +194,12 @@ Run command '%1'. - + Executar la comanda « %1 ». Running command %1 %2 - + Execucion de la comanda %1 %2 @@ -207,7 +207,7 @@ Running %1 operation. - + Execucion de l’operacion %1 @@ -250,7 +250,7 @@ Loading failed. - + Fracàs del cargament. @@ -336,7 +336,7 @@ Link copied to clipboard Calamares Initialization Failed - + Lançament de Calamares fracassat @@ -396,22 +396,22 @@ Link copied to clipboard Setup is complete. Close the setup program. - + Configuracion acabada. Tampatz lo programa de configuracion. The installation is complete. Close the installer. - + L’installacion es acabada. Tampatz l’installador. Cancel setup without changing the system. - + Anullar la configuracion sens cambiar lo sistèma. Cancel installation without changing the system. - + Anullar l’installacion sens cambiar lo sistèma. @@ -436,12 +436,12 @@ Link copied to clipboard Cancel setup? - + Anullar la configuracion ? Cancel installation? - + Anullar l’installacion ? @@ -489,7 +489,7 @@ The installer will quit and all changes will be lost. %1 Installer - + Installador de %1 @@ -536,12 +536,12 @@ The installer will quit and all changes will be lost. Current: - + Actual : After: - + Aprèp : @@ -566,12 +566,12 @@ The installer will quit and all changes will be lost. Boot loader location: - + Emplaçament del gestionari d'aviada : <strong>Select a partition to install on</strong> - + <strong>Seleccionar una particion ont installar</strong> @@ -586,7 +586,7 @@ The installer will quit and all changes will be lost. EFI system partition: - + Particion sistèma EFI : @@ -803,7 +803,7 @@ The installer will quit and all changes will be lost. Package selection - + Seleccion dels paquets @@ -838,72 +838,72 @@ The installer will quit and all changes will be lost. <h1>Welcome to the Calamares setup program for %1</h1> - + <h1>La benvenguda al programa d’installacion de Calamares per %1</h1> <h1>Welcome to %1 setup</h1> - + <h1>La benvenguda a la configuracion de %1</h1> <h1>Welcome to the Calamares installer for %1</h1> - + <h1>La benvenguda a l’installador de Calamares per %1</h1> <h1>Welcome to the %1 installer</h1> - + <h1>La benvenguda a l’installador de %1</h1> Your username is too long. - + Vòstre nom d’utilizaire es tròp long. '%1' is not allowed as username. - + « %1 » es pas permés coma nom d’utilizaire. Your username must start with a lowercase letter or underscore. - + Vòstre nom d’utilizaire deu començar per una minuscula o un jonhent bas. Only lowercase letters, numbers, underscore and hyphen are allowed. - + Son solament permeses las letras minusculas, nombres, jonhents basses e los tirets. Your hostname is too short. - + Vòstre nom d’òste es tròp cort. Your hostname is too long. - + Vòstre nom d’òste es tròp long. '%1' is not allowed as hostname. - + « %1 » es pas permés coma nom d’òste. Only letters, numbers, underscore and hyphen are allowed. - + Son solament permeses las letras, nombres, jonhents basses e los tirets. Your passwords do not match! - + Los senhals correspondon pas ! OK! - + D’acòrd ! @@ -928,27 +928,27 @@ The installer will quit and all changes will be lost. Setup Complete - + Configuracion acabada Installation Complete - + Installacion acabada The setup of %1 is complete. - + La configuracion de %1 es acabada. The installation of %1 is complete. - + L’installacion de %1 es acabada. Package Selection - + Seleccion dels paquets @@ -999,7 +999,7 @@ The installer will quit and all changes will be lost. Si&ze: - + Ta&lha : @@ -1009,7 +1009,7 @@ The installer will quit and all changes will be lost. Partition &Type: - + &Tipe de particion : @@ -1019,12 +1019,12 @@ The installer will quit and all changes will be lost. E&xtended - + E&spandida Fi&le System: - + Sistèma de fic&hièr : @@ -1034,7 +1034,7 @@ The installer will quit and all changes will be lost. &Mount Point: - + Punt de &montatge : @@ -1182,17 +1182,17 @@ The installer will quit and all changes will be lost. Create user %1 - + Crear l’utilizaire %1 Create user <strong>%1</strong>. - + Crear utilizaire <strong>%1</strong>. Preserving home directory - + Servar lo repertòri home @@ -1266,7 +1266,7 @@ The installer will quit and all changes will be lost. Delete partition %1. - + Suprimir la particion %1. @@ -1276,7 +1276,7 @@ The installer will quit and all changes will be lost. Deleting partition %1. - + Supression de la particion %1. @@ -1388,12 +1388,12 @@ The installer will quit and all changes will be lost. &Mount Point: - + Punt de &montatge : Si&ze: - + Ta&lha : @@ -1403,7 +1403,7 @@ The installer will quit and all changes will be lost. Fi&le System: - + Sistèma de fic&hièr : @@ -1460,7 +1460,7 @@ The installer will quit and all changes will be lost. Details: - + Detalhs : @@ -1633,22 +1633,22 @@ The installer will quit and all changes will be lost. is plugged in to a power source - + es brancat a una alimentacion electrica The system is not plugged in to a power source. - + Lo sistèma es pas brancat a una alimentacion electrica. is connected to the Internet - + es connectat a l’Internet The system is not connected to the Internet. - + Lo sistèma es pas connectat a l’Internet. @@ -1736,7 +1736,7 @@ The installer will quit and all changes will be lost. Konsole not installed - + Konsole pas installada @@ -1778,7 +1778,7 @@ The installer will quit and all changes will be lost. System locale setting - + Paramètres de regionalizacion del sistèma @@ -1829,12 +1829,12 @@ The installer will quit and all changes will be lost. <h1>License Agreement</h1> - + <h1>Acòrd de licéncia</h1> I accept the terms and conditions above. - + Accèpti los tèrmes e las condicion aquí dessús. @@ -1875,7 +1875,7 @@ The installer will quit and all changes will be lost. URL: %1 - + URL : %1 @@ -1912,22 +1912,22 @@ The installer will quit and all changes will be lost. File: %1 - + Fichièr : %1 Hide license text - + Amagar lo tèxte de licéncia Show the license text - + Mostrar lo tèxte de licéncia Open license agreement in browser. - + Dobrir l’acòrd de licéncia dins lo navegador. @@ -1935,18 +1935,18 @@ The installer will quit and all changes will be lost. Region: - + Region : Zone: - + Zòna ; &Change... - + &Cambiar... @@ -2032,7 +2032,7 @@ The installer will quit and all changes will be lost. Timezone: %1 - + Fus orari : %1 @@ -2047,7 +2047,7 @@ The installer will quit and all changes will be lost. Package selection - + Seleccion dels paquets @@ -2067,17 +2067,17 @@ The installer will quit and all changes will be lost. Browser package - + Percórrer lo paquet Web browser - + Navegador web Kernel - + Nuclèu @@ -2087,7 +2087,7 @@ The installer will quit and all changes will be lost. Login - + Connexion @@ -2127,7 +2127,7 @@ The installer will quit and all changes will be lost. Theming - + Personalizacion @@ -2171,7 +2171,7 @@ The installer will quit and all changes will be lost. OEM Configuration - + Configuracion OEM @@ -2191,7 +2191,7 @@ The installer will quit and all changes will be lost. Timezone: %1 - + Fus orari : %1 @@ -2214,17 +2214,17 @@ The installer will quit and all changes will be lost. Password is too short - + Lo senhal es tròp cort Password is too long - + Lo senhal es tròp long Password is too weak - + Lo senhal es tròp feble @@ -2302,7 +2302,7 @@ The installer will quit and all changes will be lost. The password is too short - + Lo senhal es tròp cort @@ -2421,7 +2421,7 @@ The installer will quit and all changes will be lost. Unknown setting - %1 - + Paramètre desconegut - %1 @@ -2436,7 +2436,7 @@ The installer will quit and all changes will be lost. Bad integer value - + Marrida valor d’entièr @@ -2476,7 +2476,7 @@ The installer will quit and all changes will be lost. Unknown error - + Error desconeguda @@ -2509,7 +2509,7 @@ The installer will quit and all changes will be lost. Package Selection - + Seleccion dels paquets @@ -2522,7 +2522,7 @@ The installer will quit and all changes will be lost. Packages - + Paquets @@ -2530,7 +2530,7 @@ The installer will quit and all changes will be lost. Packages - + Paquets @@ -2556,7 +2556,7 @@ The installer will quit and all changes will be lost. Keyboard Model: - + Modèl de clavièr : @@ -2574,27 +2574,27 @@ The installer will quit and all changes will be lost. What is your name? - + Cossí vos dison ? Your Full Name - + Vòstre nom complèt What name do you want to use to log in? - + Qual nom volètz utilizar per vos connectar ? login - + identificant What is the name of this computer? - + Cossí s’apèla aqueste ordenador ? @@ -2604,7 +2604,7 @@ The installer will quit and all changes will be lost. Computer Name - + Nom de l’ordenador @@ -2671,17 +2671,17 @@ The installer will quit and all changes will be lost. Home - + Home Boot - + Boot EFI system - + Sistèma EFI @@ -2696,13 +2696,13 @@ The installer will quit and all changes will be lost. New partition - + Particion novèla %1 %2 size[number] filesystem[name] - + %1 %2 @@ -2711,13 +2711,13 @@ The installer will quit and all changes will be lost. Free Space - + Espaci disponible New partition - + Particion novèla @@ -2737,7 +2737,7 @@ The installer will quit and all changes will be lost. Mount Point - + Punt de montatge @@ -2853,12 +2853,12 @@ The installer will quit and all changes will be lost. Current: - + Actual : After: - + Aprèp : @@ -3241,7 +3241,7 @@ Output: EFI system partition: - + Particion sistèma EFI : @@ -3425,7 +3425,7 @@ Output: Internal Error - + Error intèrna @@ -4018,22 +4018,22 @@ Output: <h1>Welcome to the Calamares setup program for %1.</h1> - + <h1>La benvenguda al programa d’installacion de Calamares per %1.</h1> <h1>Welcome to %1 setup.</h1> - + <h1>La benvenguda a la configuracion de %1.</h1> <h1>Welcome to the Calamares installer for %1.</h1> - + <h1>La benvenguda a l’installador de Calamares per %1.</h1> <h1>Welcome to the %1 installer.</h1> - + <h1>La benvenguda a l’installador de %1.</h1> @@ -4164,12 +4164,12 @@ Output: Close Installer - + Tampar l’installador Restart System - + Reaviar lo sistèma @@ -4208,7 +4208,8 @@ Output: <h1>Languages</h1> </br> The system locale setting affects the language and character set for some command line user interface elements. The current setting is <strong>%1</strong>. - + <h1>Lengas</h1> </br> + Los paramètres de lingüistics del sistèma afèctan la lenga, lo jòc de caractèrs per d’unes elements d’interfàcias de linha de comanda. Lo parametratge actual es <strong>%1</strong>. @@ -4232,7 +4233,7 @@ Output: Keyboard Model: - + Modèl de clavièr : @@ -4349,17 +4350,17 @@ Output: What is your name? - + Cossí vos dison ? Your Full Name - + Vòstre nom complèt What name do you want to use to log in? - + Qual nom volètz utilizar per vos connectar ? @@ -4374,7 +4375,7 @@ Output: Only lowercase letters, numbers, underscore and hyphen are allowed. - + Son solament permeses las letras, nombres, jonhents basses e los tirets. @@ -4384,12 +4385,12 @@ Output: What is the name of this computer? - + Cossí s’apèla aqueste ordenador ? Computer Name - + Nom de l’ordenador diff --git a/lang/calamares_pl.ts b/lang/calamares_pl.ts index 08c9435f8..d959b2e67 100644 --- a/lang/calamares_pl.ts +++ b/lang/calamares_pl.ts @@ -240,7 +240,7 @@ Loading ... - + Ładowanie... @@ -360,7 +360,7 @@ Link copied to clipboard Continue with installation? - + Kontynuować instalację? @@ -502,7 +502,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Set filesystem label on %1. - + Ustaw etykietę systemu plików na %1. @@ -683,7 +683,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Successfully unmounted %1. - + Pomyślnie odmontowano %1. @@ -868,7 +868,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. '%1' is not allowed as username. - + '%1' nie może zostać użyte jako nazwa użytkownika. @@ -908,7 +908,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. OK! - + OK! @@ -953,7 +953,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Package Selection - + Wybór Pakietów @@ -1049,7 +1049,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Label for the filesystem - + Etykieta dla systemu plików @@ -1084,7 +1084,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Mountpoint must start with a <tt>/</tt>. - + Punkt montowania musi się zaczynać od <tt>/</tt>. @@ -1418,7 +1418,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Label for the filesystem - + Etykieta dla systemu plików @@ -2037,7 +2037,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Timezone: %1 - + Strefa czasowa: %1 @@ -2196,7 +2196,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Timezone: %1 - + Strefa czasowa: %1 @@ -2289,11 +2289,11 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. The password contains fewer than %n lowercase letters - - - - - + + Hasło składa się z mniej niż %1 małej litery + Hasło składa się z mniej niż %1 małych liter + Hasło składa się z mniej niż %1 małych liter + Hasło składa się z mniej niż %1 małych liter @@ -2504,7 +2504,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Password is empty - + Hasło jest puste @@ -2532,7 +2532,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Package Selection - + Wybór Pakietów @@ -2545,7 +2545,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Packages - + Pakiety @@ -2553,7 +2553,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Packages - + Pakiety @@ -2602,7 +2602,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Your Full Name - + Twoja Pełne Imię @@ -2612,7 +2612,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. login - + login @@ -2627,7 +2627,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Computer Name - + Nazwa Komputera @@ -2644,13 +2644,13 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Password - + Hasło Repeat Password - + Powtórz Hasło @@ -2755,7 +2755,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. File System Label - + Etykieta Systemu Plików @@ -2901,7 +2901,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. The filesystem must be mounted on <strong>%1</strong>. - + System plików musi zostać zamontowany w <strong>%1</strong>. @@ -3120,7 +3120,7 @@ Wyjście: File not found - + Plik nie został znaleziony @@ -3130,7 +3130,7 @@ Wyjście: Directory not found - + Katalog nie został znaleziony @@ -3922,7 +3922,7 @@ i nie uruchomi się Key Column header for key/value - + Klucz @@ -4164,7 +4164,7 @@ i nie uruchomi się Back - + Wstecz @@ -4180,7 +4180,7 @@ i nie uruchomi się Installation Completed - + Instalacja została zakończona @@ -4191,12 +4191,12 @@ i nie uruchomi się Close Installer - + Zamknij instalator Restart System - + Uruchom ponownie system @@ -4210,7 +4210,7 @@ i nie uruchomi się Installation Completed - + Instalacja została zakończona @@ -4246,7 +4246,7 @@ i nie uruchomi się Back - + Wstecz @@ -4363,7 +4363,7 @@ i nie uruchomi się Back - + Wstecz @@ -4381,7 +4381,7 @@ i nie uruchomi się Your Full Name - + Twoja Pełne Imię @@ -4416,7 +4416,7 @@ i nie uruchomi się Computer Name - + Nazwa Komputera @@ -4436,12 +4436,12 @@ i nie uruchomi się Password - + Hasło Repeat Password - + Powtórz Hasło From 9e664d7165c1bb21cd0c8dd6e72934d222589521 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 11:47:28 +0200 Subject: [PATCH 15/23] Changes: pre-release housekeeping --- CHANGES-3.2 | 12 +++++++++++- CMakeLists.txt | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGES-3.2 b/CHANGES-3.2 index d5dbe04a5..2c5e0bdcd 100644 --- a/CHANGES-3.2 +++ b/CHANGES-3.2 @@ -8,10 +8,13 @@ contributors are listed. Note that Calamares does not have a historical changelog -- this log starts with version 3.2.0. The release notes on the website will have to do for older versions. -# 3.2.58 (unreleased) # +# 3.2.58 (2022-05-18) # This release contains contributions from (alphabetically by first name): + - Anke Boersma + - Arjen Balfoort - Enrique Medina Gremaldos + - Evan James ## Core ## - Internal improvements to translations-setup means that Catalan (in the @@ -19,6 +22,13 @@ This release contains contributions from (alphabetically by first name): are all better supported. Thanks Enrique. ## Modules ## + - *netinstall* Now displays entries with an empty name slightly differently. + An empty name is not generally useful, but in combination with + *immutable:true* and *selected:false* can be used to introduce separators + or descriptive comments into the list of packages. + - *partition* does not offer full-disk encryption when using ZFS. ZFS and the + way Calamares sets up FDE don't mix well. (Thanks Evan) + - *partition* Various bugs related to LUKS have been fixed. (Thanks Arjen) - *users* module now has a structured *user* key with settings specific to the user (shell, in particular). This maintains backwards compatibility with the *userShell* key. diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e2863d6d..13f63ecc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ project( CALAMARES LANGUAGES C CXX ) -set( CALAMARES_VERSION_RC 1 ) # Set to 0 during release cycle, 1 during development +set( CALAMARES_VERSION_RC 0 ) # Set to 0 during release cycle, 1 during development if( CALAMARES_VERSION_RC EQUAL 1 AND CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) message( FATAL_ERROR "Do not build development versions in the source-directory." ) endif() From 56071c40166f3cfce9353d0a31883600d51970f0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 12:22:51 +0200 Subject: [PATCH 16/23] CI: acceptable clang-format versions --- ci/calamaresstyle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/calamaresstyle b/ci/calamaresstyle index 52fe30737..f29b217c5 100755 --- a/ci/calamaresstyle +++ b/ci/calamaresstyle @@ -24,7 +24,7 @@ test -f "$TOPDIR/.clang-format" || { echo "! No .clang-format support files in $ AS=$( which astyle ) # Allow specifying CF_VERSIONS outside already -CF_VERSIONS="$CF_VERSIONS clang-format13 clang-format-13 clang-format12 clang-format-12 clang-format" +CF_VERSIONS="$CF_VERSIONS clang-format14 clang-format-14 clang-format13 clang-format-13 clang-format12 clang-format-12 clang-format" for _cf in $CF_VERSIONS do # Not an error if this particular clang-format isn't found @@ -45,11 +45,11 @@ test -x "$CF" || { echo "! $CF is not executable."; exit 1 ; } format_version=`"$CF" --version | tr -dc '[^.0-9]' | cut -d . -f 1` case "$format_version" in - 12|13 ) + 12|13|14 ) : ;; * ) - echo "! Clang-format version '$format_version' unsupported, version 12 required." + echo "! Clang-format version '$format_version' unsupported, versions 12 through 14 are ok." exit 1 ;; esac From 8fea6f71ab0d979d26bb30f3389e888ed73c76c7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 12:07:20 +0200 Subject: [PATCH 17/23] [partition] Apply coding style --- src/modules/partition/core/KPMHelpers.cpp | 342 +++++++++--------- src/modules/partition/core/KPMHelpers.h | 90 ++--- src/modules/partition/gui/ChoicePage.cpp | 10 +- .../gui/EditExistingPartitionDialog.cpp | 24 +- .../gui/EditExistingPartitionDialog.h | 2 +- src/modules/partition/gui/EncryptWidget.cpp | 2 +- 6 files changed, 233 insertions(+), 237 deletions(-) diff --git a/src/modules/partition/core/KPMHelpers.cpp b/src/modules/partition/core/KPMHelpers.cpp index 003d47088..6b4b5d28d 100644 --- a/src/modules/partition/core/KPMHelpers.cpp +++ b/src/modules/partition/core/KPMHelpers.cpp @@ -20,9 +20,9 @@ #include #include #include +#include #include #include -#include #include using CalamaresUtils::Partition::PartitionIterator; @@ -30,202 +30,198 @@ using CalamaresUtils::Partition::PartitionIterator; namespace KPMHelpers { - Partition* - findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ) +Partition* +findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ) +{ + for ( auto device : devices ) + for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) + if ( PartitionInfo::mountPoint( *it ) == mountPoint ) + { + return *it; + } + return nullptr; +} + + +Partition* +createNewPartition( PartitionNode* parent, + const Device& device, + const PartitionRole& role, + FileSystem::Type fsType, + const QString& fsLabel, + qint64 firstSector, + qint64 lastSector, + PartitionTable::Flags flags ) +{ + FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() ); + fs->setLabel( fsLabel ); + return new Partition( parent, + device, + role, + fs, + fs->firstSector(), + fs->lastSector(), + QString() /* path */, + KPM_PARTITION_FLAG( None ) /* availableFlags */, + QString() /* mountPoint */, + false /* mounted */, + flags /* activeFlags */, + KPM_PARTITION_STATE( New ) ); +} + + +Partition* +createNewEncryptedPartition( PartitionNode* parent, + const Device& device, + const PartitionRole& role, + FileSystem::Type fsType, + const QString& fsLabel, + qint64 firstSector, + qint64 lastSector, + const QString& passphrase, + PartitionTable::Flags flags ) +{ + PartitionRole::Roles newRoles = role.roles(); + if ( !role.has( PartitionRole::Luks ) ) { - for ( auto device : devices ) - for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) - if ( PartitionInfo::mountPoint( *it ) == mountPoint ) - { - return *it; - } + newRoles |= PartitionRole::Luks; + } + + FS::luks* fs = dynamic_cast< FS::luks* >( + FileSystemFactory::create( FileSystem::Luks, firstSector, lastSector, device.logicalSize() ) ); + if ( !fs ) + { + cError() << "cannot create LUKS filesystem. Giving up."; return nullptr; } + fs->createInnerFileSystem( fsType ); + fs->setPassphrase( passphrase ); + fs->setLabel( fsLabel ); + Partition* p = new Partition( parent, + device, + PartitionRole( newRoles ), + fs, + fs->firstSector(), + fs->lastSector(), + QString() /* path */, + KPM_PARTITION_FLAG( None ) /* availableFlags */, + QString() /* mountPoint */, + false /* mounted */, + flags /* activeFlags */, + KPM_PARTITION_STATE( New ) ); + return p; +} - Partition* - createNewPartition( PartitionNode* parent, - const Device& device, - const PartitionRole& role, - FileSystem::Type fsType, - const QString& fsLabel, - qint64 firstSector, - qint64 lastSector, - PartitionTable::Flags flags ) + +Partition* +clonePartition( Device* device, Partition* partition ) +{ + FileSystem* fs = FileSystemFactory::create( + partition->fileSystem().type(), partition->firstSector(), partition->lastSector(), device->logicalSize() ); + return new Partition( partition->parent(), + *device, + partition->roles(), + fs, + fs->firstSector(), + fs->lastSector(), + partition->partitionPath(), + partition->activeFlags() ); +} + +// Adapted from luks cryptOpen which always opens a dialog to ask for a passphrase +int +updateLuksDevice( Partition* partition, const QString& passphrase ) +{ + const QString deviceNode = partition->partitionPath(); + + cDebug() << "Update Luks device: " << deviceNode; + + if ( passphrase.isEmpty() ) { - FileSystem* fs = FileSystemFactory::create( fsType, firstSector, lastSector, device.logicalSize() ); - fs->setLabel( fsLabel ); - return new Partition( parent, - device, - role, - fs, - fs->firstSector(), - fs->lastSector(), - QString() /* path */, - KPM_PARTITION_FLAG( None ) /* availableFlags */, - QString() /* mountPoint */, - false /* mounted */, - flags /* activeFlags */, - KPM_PARTITION_STATE( New ) ); + cWarning() << Logger::SubEntry << "#1: Passphrase is empty"; + return 1; } - - Partition* - createNewEncryptedPartition( PartitionNode* parent, - const Device& device, - const PartitionRole& role, - FileSystem::Type fsType, - const QString& fsLabel, - qint64 firstSector, - qint64 lastSector, - const QString& passphrase, - PartitionTable::Flags flags ) + if ( partition->fileSystem().type() != FileSystem::Luks ) { - PartitionRole::Roles newRoles = role.roles(); - if ( !role.has( PartitionRole::Luks ) ) - { - newRoles |= PartitionRole::Luks; - } - - FS::luks* fs = dynamic_cast< FS::luks* >( - FileSystemFactory::create( FileSystem::Luks, firstSector, lastSector, device.logicalSize() ) ); - if ( !fs ) - { - cError() << "cannot create LUKS filesystem. Giving up."; - return nullptr; - } - - fs->createInnerFileSystem( fsType ); - fs->setPassphrase( passphrase ); - fs->setLabel( fsLabel ); - Partition* p = new Partition( parent, - device, - PartitionRole( newRoles ), - fs, - fs->firstSector(), - fs->lastSector(), - QString() /* path */, - KPM_PARTITION_FLAG( None ) /* availableFlags */, - QString() /* mountPoint */, - false /* mounted */, - flags /* activeFlags */, - KPM_PARTITION_STATE( New ) ); - return p; + cWarning() << Logger::SubEntry << "#2: Not a luks encrypted device"; + return 2; } + // Cast partition fs to luks fs + FS::luks* luksFs = dynamic_cast< FS::luks* >( &partition->fileSystem() ); - Partition* - clonePartition( Device* device, Partition* partition ) + // Test the given passphrase + if ( !luksFs->testPassphrase( deviceNode, passphrase ) ) { - FileSystem* fs = FileSystemFactory::create( - partition->fileSystem().type(), partition->firstSector(), partition->lastSector(), device->logicalSize() ); - return new Partition( partition->parent(), - *device, - partition->roles(), - fs, - fs->firstSector(), - fs->lastSector(), - partition->partitionPath(), - partition->activeFlags() ); + cWarning() << Logger::SubEntry << "#3: Passphrase incorrect"; + return 3; } - // Adapted from luks cryptOpen which always opens a dialog to ask for a passphrase - int - updateLuksDevice( Partition* partition, const QString& passphrase ) + if ( luksFs->isCryptOpen() ) { - const QString deviceNode = partition->partitionPath(); - - cDebug() << "Update Luks device: " << deviceNode; - - if ( passphrase.isEmpty() ) + if ( !luksFs->mapperName().isEmpty() ) { - cWarning() << Logger::SubEntry << "#1: Passphrase is empty"; - return 1; + cWarning() << Logger::SubEntry << "#4: Device already decrypted"; + return 4; } - - if ( partition->fileSystem().type() != FileSystem::Luks ) + else { - cWarning() << Logger::SubEntry << "#2: Not a luks encrypted device"; - return 2; + cDebug() << Logger::SubEntry << "No mapper node found"; + luksFs->setCryptOpen( false ); } - - // Cast partition fs to luks fs - FS::luks* luksFs = dynamic_cast< FS::luks* >( &partition->fileSystem() ); - - // Test the given passphrase - if ( !luksFs->testPassphrase( deviceNode, passphrase ) ) - { - cWarning() << Logger::SubEntry << "#3: Passphrase incorrect"; - return 3; - } - - if ( luksFs->isCryptOpen() ) - { - if ( !luksFs->mapperName().isEmpty()) - { - cWarning() << Logger::SubEntry << "#4: Device already decrypted"; - return 4; - } - else - { - cDebug() << Logger::SubEntry << "No mapper node found"; - luksFs->setCryptOpen( false ); - } - } - - ExternalCommand openCmd( QStringLiteral( "cryptsetup" ), - { QStringLiteral( "open" ), - deviceNode, - luksFs->suggestedMapperName( deviceNode ) } ); - - if ( !( openCmd.write( passphrase.toLocal8Bit() + '\n' ) && - openCmd.start( -1 ) && - openCmd.exitCode() == 0 ) ) - { - cWarning() << Logger::SubEntry << openCmd.exitCode() << ": cryptsetup command failed"; - return openCmd.exitCode(); - } - - // Save the existing passphrase - luksFs->setPassphrase( passphrase ); - - luksFs->scan( deviceNode ); - - if ( luksFs->mapperName().isEmpty() ) - { - cWarning() << Logger::SubEntry << "#5: No mapper node found"; - return 5; - } - - luksFs->loadInnerFileSystem( luksFs->mapperName() ); - luksFs->setCryptOpen( luksFs->innerFS() != nullptr ); - - if ( !luksFs->isCryptOpen() ) - { - cWarning() << Logger::SubEntry << "#6: Device could not be decrypted"; - return 6; - } - - return 0; } - Calamares::JobResult - execute( Operation& operation, const QString& failureMessage ) + ExternalCommand openCmd( QStringLiteral( "cryptsetup" ), + { QStringLiteral( "open" ), deviceNode, luksFs->suggestedMapperName( deviceNode ) } ); + + if ( !( openCmd.write( passphrase.toLocal8Bit() + '\n' ) && openCmd.start( -1 ) && openCmd.exitCode() == 0 ) ) { - operation.setStatus( Operation::StatusRunning ); - - Report report( nullptr ); - if ( operation.execute( report ) ) - { - return Calamares::JobResult::ok(); - } - - // Remove the === lines from the report by trimming them to empty - QStringList l = report.toText().split( '\n' ); - std::for_each( l.begin(), l.end(), []( QString& s ) { CalamaresUtils::removeLeading( s, '=' ); } ); - - return Calamares::JobResult::error( failureMessage, l.join( '\n' ) ); + cWarning() << Logger::SubEntry << openCmd.exitCode() << ": cryptsetup command failed"; + return openCmd.exitCode(); } + // Save the existing passphrase + luksFs->setPassphrase( passphrase ); + + luksFs->scan( deviceNode ); + + if ( luksFs->mapperName().isEmpty() ) + { + cWarning() << Logger::SubEntry << "#5: No mapper node found"; + return 5; + } + + luksFs->loadInnerFileSystem( luksFs->mapperName() ); + luksFs->setCryptOpen( luksFs->innerFS() != nullptr ); + + if ( !luksFs->isCryptOpen() ) + { + cWarning() << Logger::SubEntry << "#6: Device could not be decrypted"; + return 6; + } + + return 0; +} + +Calamares::JobResult +execute( Operation& operation, const QString& failureMessage ) +{ + operation.setStatus( Operation::StatusRunning ); + + Report report( nullptr ); + if ( operation.execute( report ) ) + { + return Calamares::JobResult::ok(); + } + + // Remove the === lines from the report by trimming them to empty + QStringList l = report.toText().split( '\n' ); + std::for_each( l.begin(), l.end(), []( QString& s ) { CalamaresUtils::removeLeading( s, '=' ); } ); + + return Calamares::JobResult::error( failureMessage, l.join( '\n' ) ); +} + } // namespace KPMHelpers diff --git a/src/modules/partition/core/KPMHelpers.h b/src/modules/partition/core/KPMHelpers.h index b958b3866..261bd7b39 100644 --- a/src/modules/partition/core/KPMHelpers.h +++ b/src/modules/partition/core/KPMHelpers.h @@ -43,56 +43,56 @@ class PartitionRole; namespace KPMHelpers { - /** - * Iterates on all devices and return the first partition which is associated - * with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint() - */ - Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ); +/** + * Iterates on all devices and return the first partition which is associated + * with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint() + */ +Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ); - /** - * Helper function to create a new Partition object (does not create anything - * on the disk) associated with a FileSystem. - */ - Partition* createNewPartition( PartitionNode* parent, - const Device& device, - const PartitionRole& role, - FileSystem::Type fsType, - const QString& fsLabel, - qint64 firstSector, - qint64 lastSector, - PartitionTable::Flags flags ); +/** + * Helper function to create a new Partition object (does not create anything + * on the disk) associated with a FileSystem. + */ +Partition* createNewPartition( PartitionNode* parent, + const Device& device, + const PartitionRole& role, + FileSystem::Type fsType, + const QString& fsLabel, + qint64 firstSector, + qint64 lastSector, + PartitionTable::Flags flags ); - Partition* createNewEncryptedPartition( PartitionNode* parent, - const Device& device, - const PartitionRole& role, - FileSystem::Type fsType, - const QString& fsLabel, - qint64 firstSector, - qint64 lastSector, - const QString& passphrase, - PartitionTable::Flags flags ); +Partition* createNewEncryptedPartition( PartitionNode* parent, + const Device& device, + const PartitionRole& role, + FileSystem::Type fsType, + const QString& fsLabel, + qint64 firstSector, + qint64 lastSector, + const QString& passphrase, + PartitionTable::Flags flags ); - Partition* clonePartition( Device* device, Partition* partition ); +Partition* clonePartition( Device* device, Partition* partition ); - int updateLuksDevice( Partition* partition, const QString& passphrase ); +int updateLuksDevice( Partition* partition, const QString& passphrase ); - /** @brief Return a result for an @p operation - * - * Executes the operation, and if successful, returns a success result. - * Otherwise returns an error using @p failureMessage as the primary part - * of the error, and details obtained from the operation. - */ - Calamares::JobResult execute( Operation& operation, const QString& failureMessage ); - /** @brief Return a result for an @p operation - * - * It's acceptable to use an rvalue: the operation-running is the effect - * you're interested in, rather than keeping the temporary around. - */ - static inline Calamares::JobResult - execute( Operation&& operation, const QString& failureMessage ) - { - return execute( operation, failureMessage ); - } +/** @brief Return a result for an @p operation + * + * Executes the operation, and if successful, returns a success result. + * Otherwise returns an error using @p failureMessage as the primary part + * of the error, and details obtained from the operation. + */ +Calamares::JobResult execute( Operation& operation, const QString& failureMessage ); +/** @brief Return a result for an @p operation + * + * It's acceptable to use an rvalue: the operation-running is the effect + * you're interested in, rather than keeping the temporary around. + */ +static inline Calamares::JobResult +execute( Operation&& operation, const QString& failureMessage ) +{ + return execute( operation, failureMessage ); +} } // namespace KPMHelpers diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 3076df61b..781cef325 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -467,10 +467,14 @@ ChoicePage::onActionChanged() } // Whole disk encryption isn't implemented for zfs so disable the option for now - if ( m_eraseFsTypesChoiceComboBox != nullptr && m_enableEncryptionWidget ) { - if ( m_eraseFsTypesChoiceComboBox->currentText() == "zfs" ) { + if ( m_eraseFsTypesChoiceComboBox != nullptr && m_enableEncryptionWidget ) + { + if ( m_eraseFsTypesChoiceComboBox->currentText() == "zfs" ) + { m_encryptWidget->hide(); - } else { + } + else + { m_encryptWidget->show(); } } diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index 4883edd76..eeb548ba1 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -17,10 +17,10 @@ #include "ui_EditExistingPartitionDialog.h" #include "core/ColorUtils.h" +#include "core/KPMHelpers.h" #include "core/PartUtils.h" #include "core/PartitionCoreModule.h" #include "core/PartitionInfo.h" -#include "core/KPMHelpers.h" #include "gui/PartitionDialogHelpers.h" #include "gui/PartitionSizeController.h" @@ -38,9 +38,9 @@ #include #include -#include -#include #include +#include +#include using CalamaresUtils::Partition::untranslatedFS; using CalamaresUtils::Partition::userVisibleFS; @@ -265,8 +265,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core ) "or delete and create a new encrypted partition." ) .arg( m_partition->partitionPath() ); - QMessageBox mb( QMessageBox::Information, message, description, - QMessageBox::Ok, this->parentWidget() ); + QMessageBox mb( QMessageBox::Information, message, description, QMessageBox::Ok, this->parentWidget() ); Calamares::fixButtonLabels( &mb ); mb.exec(); } @@ -321,16 +320,15 @@ EditExistingPartitionDialog::updateMountPointPicker() } toggleEncryptWidget(); - } void EditExistingPartitionDialog::checkMountPointSelection() { if ( validateMountPoint( selectedMountPoint( m_ui->mountPointComboBox ), - m_usedMountPoints, - m_ui->mountPointExplanation, - m_ui->buttonBox->button( QDialogButtonBox::Ok ) ) ) + m_usedMountPoints, + m_ui->mountPointExplanation, + m_ui->buttonBox->button( QDialogButtonBox::Ok ) ) ) { toggleEncryptWidget(); } @@ -344,17 +342,15 @@ EditExistingPartitionDialog::toggleEncryptWidget() // and not currently formatted // and its mount point not a standard mount point except when it's /home QString mp = selectedMountPoint( m_ui->mountPointComboBox ); - if ( !mp.isEmpty() - && m_partition->fileSystem().type() == FileSystem::Luks - && !m_ui->formatRadioButton->isChecked() - && ( !standardMountPoints().contains(mp) || mp == "/home" ) ) + if ( !mp.isEmpty() && m_partition->fileSystem().type() == FileSystem::Luks && !m_ui->formatRadioButton->isChecked() + && ( !standardMountPoints().contains( mp ) || mp == "/home" ) ) { m_ui->encryptWidget->show(); m_ui->encryptWidget->reset( false ); } // TODO: When formatting a partition user must be able to encrypt that partition // Probably need to delete this partition and create a new one - // else if ( m_ui->formatRadioButton->isChecked() + // else if ( m_ui->formatRadioButton->isChecked() // && !mp.isEmpty()) // { // m_ui->encryptWidget->show(); diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.h b/src/modules/partition/gui/EditExistingPartitionDialog.h index a912c577d..5d1e7fd65 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.h +++ b/src/modules/partition/gui/EditExistingPartitionDialog.h @@ -36,7 +36,7 @@ public: { Partition* p; }; - + EditExistingPartitionDialog( Device* device, Partition* partition, const QStringList& usedMountPoints, diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index 7efe0ea1a..41272bc4b 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -149,7 +149,7 @@ EncryptWidget::updateState() } Encryption newState; - if ( m_ui->m_encryptCheckBox->isChecked() || !m_ui->m_encryptCheckBox->isVisible()) + if ( m_ui->m_encryptCheckBox->isChecked() || !m_ui->m_encryptCheckBox->isVisible() ) { if ( !m_ui->m_passphraseLineEdit->text().isEmpty() && m_ui->m_passphraseLineEdit->text() == m_ui->m_confirmLineEdit->text() ) From 874a0c1f38b0da4e5bc83083b13a63b1c7eed935 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 12:44:55 +0200 Subject: [PATCH 18/23] 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 ); From f352740aba0c38ad3ab64f265a83f58401f2257c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 12:45:32 +0200 Subject: [PATCH 19/23] Git: update blame-ignore --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index f9955e460..9fc9f1940 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -2,3 +2,4 @@ # SPDX-License-Identifier: CC0-1.0 # 18fef8dfe5d926ec0bc979562553adf4db8db2e9 +874a0c1f38b0da4e5bc83083b13a63b1c7eed935 From fc8e5fb5c74c0841d1f4fb93aa8f55efd5741676 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 12:55:15 +0200 Subject: [PATCH 20/23] CI: forbid clang-format-14 --- ci/calamaresstyle | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ci/calamaresstyle b/ci/calamaresstyle index f29b217c5..058468b91 100755 --- a/ci/calamaresstyle +++ b/ci/calamaresstyle @@ -24,7 +24,7 @@ test -f "$TOPDIR/.clang-format" || { echo "! No .clang-format support files in $ AS=$( which astyle ) # Allow specifying CF_VERSIONS outside already -CF_VERSIONS="$CF_VERSIONS clang-format14 clang-format-14 clang-format13 clang-format-13 clang-format12 clang-format-12 clang-format" +CF_VERSIONS="$CF_VERSIONS clang-format13 clang-format-13 clang-format-13.0.1 clang-format12 clang-format-12 clang-format" for _cf in $CF_VERSIONS do # Not an error if this particular clang-format isn't found @@ -42,14 +42,17 @@ test -x "$CF" || { echo "! $CF is not executable."; exit 1 ; } # Version 7 and earlier doesn't understand all the options we would like # Version 12 handles lambdas nicely, so use that. # Version 13 is also ok. +# Version 14 behaves differently with short-functions-in-class, +# spreading functions out that 13 keeps on one line. To avoid +# ping-pong commits, forbid 14. format_version=`"$CF" --version | tr -dc '[^.0-9]' | cut -d . -f 1` case "$format_version" in - 12|13|14 ) + 12|13 ) : ;; * ) - echo "! Clang-format version '$format_version' unsupported, versions 12 through 14 are ok." + echo "! Clang-format version '$format_version' unsupported, versions 12 or 13 are ok." exit 1 ;; esac From 7d5a4eafa297933e18a3c4d7f6f3a0fd68bcce20 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 14:06:00 +0200 Subject: [PATCH 21/23] [partition] Support KPMCore3 API (no testPassphrase in FS::luks) --- src/modules/partition/core/KPMHelpers.cpp | 40 ++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/core/KPMHelpers.cpp b/src/modules/partition/core/KPMHelpers.cpp index 6b4b5d28d..92c9edb22 100644 --- a/src/modules/partition/core/KPMHelpers.cpp +++ b/src/modules/partition/core/KPMHelpers.cpp @@ -129,6 +129,44 @@ clonePartition( Device* device, Partition* partition ) partition->activeFlags() ); } +#ifndef WITH_KPMCORE4API +// This function was added in KPMCore 4, implementation copied from src/fs/luks.cpp +/* + SPDX-FileCopyrightText: 2010 Volker Lanz + SPDX-FileCopyrightText: 2012-2019 Andrius Štikonas + SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac + SPDX-FileCopyrightText: 2016 Chantara Tith + SPDX-FileCopyrightText: 2017 Christian Morlok + SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho + SPDX-FileCopyrightText: 2020 Arnaud Ferraris + SPDX-FileCopyrightText: 2020 Gaël PORTAY + + SPDX-License-Identifier: GPL-3.0-or-later +*/ +static bool +testPassphrase( FS::luks* fs, const QString& deviceNode, const QString& passphrase ) +{ + ExternalCommand cmd( QStringLiteral( "cryptsetup" ), + { QStringLiteral( "open" ), + QStringLiteral( "--tries" ), + QStringLiteral( "1" ), + QStringLiteral( "--test-passphrase" ), + deviceNode } ); + if ( cmd.write( passphrase.toLocal8Bit() + '\n' ) && cmd.start( -1 ) && cmd.exitCode() == 0 ) + { + return true; + } + + return false; +} +#else +static bool +testPassphrase( FS::luks* fs, const QString& deviceNode, const QString& passphrase ) +{ + return fs->testPassphrase( deviceNode, passphrase ); +} +#endif + // Adapted from luks cryptOpen which always opens a dialog to ask for a passphrase int updateLuksDevice( Partition* partition, const QString& passphrase ) @@ -153,7 +191,7 @@ updateLuksDevice( Partition* partition, const QString& passphrase ) FS::luks* luksFs = dynamic_cast< FS::luks* >( &partition->fileSystem() ); // Test the given passphrase - if ( !luksFs->testPassphrase( deviceNode, passphrase ) ) + if ( !testPassphrase( luksFs, deviceNode, passphrase ) ) { cWarning() << Logger::SubEntry << "#3: Passphrase incorrect"; return 3; From cebafcf86933848a8b95719efbf37ea552174613 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 14:37:02 +0200 Subject: [PATCH 22/23] [users] Make test more expressive --- src/modules/users/Tests.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/users/Tests.cpp b/src/modules/users/Tests.cpp index b6badbe91..b7835251f 100644 --- a/src/modules/users/Tests.cpp +++ b/src/modules/users/Tests.cpp @@ -120,6 +120,11 @@ UserTests::testGetSet() QVERIFY( c.loginNameStatus().isEmpty() ); // now it's still ok QCOMPARE( c.loginName(), lg ); QCOMPARE( c.fullName(), ful ); + } + // Test forbidden login names + { + QVERIFY( c.forbiddenLoginNames().contains( QStringLiteral( "root" ) ) ); + QVERIFY( c.loginNameStatus().isEmpty() ); // it's ok now c.setLoginName( "root" ); QVERIFY( !c.loginNameStatus().isEmpty() ); // can't be root } From 17814410e973d51090c0ccab7a0a816ccf35debb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 18 May 2022 14:40:35 +0200 Subject: [PATCH 23/23] [users] always-forbidden-names should be set in the Config constructor --- src/modules/users/Config.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/modules/users/Config.cpp b/src/modules/users/Config.cpp index 78782aef0..c75e8a6e7 100644 --- a/src/modules/users/Config.cpp +++ b/src/modules/users/Config.cpp @@ -78,6 +78,20 @@ updateGSAutoLogin( bool doAutoLogin, const QString& login ) } } +static const QStringList& +alwaysForbiddenLoginNames() +{ + static QStringList s { QStringLiteral( "root" ), QStringLiteral( "nobody" ) }; + return s; +} + +static const QStringList& +alwaysForbiddenHostNames() +{ + static QStringList s { QStringLiteral( "localhost" ) }; + return s; +} + const NamedEnumTable< HostNameAction >& hostnameActionNames() { @@ -98,6 +112,8 @@ hostnameActionNames() Config::Config( QObject* parent ) : Calamares::ModuleSystem::Config( parent ) + , m_forbiddenHostNames( alwaysForbiddenHostNames() ) + , m_forbiddenLoginNames( alwaysForbiddenLoginNames() ) { emit readyChanged( m_isReady ); // false @@ -909,7 +925,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) setUserShell( shell ); m_forbiddenLoginNames = CalamaresUtils::getStringList( userSettings, "forbidden_names" ); - m_forbiddenLoginNames << QStringLiteral( "root" ) << QStringLiteral( "nobody" ); + m_forbiddenLoginNames << alwaysForbiddenLoginNames(); tidy( m_forbiddenLoginNames ); } @@ -934,7 +950,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) = CalamaresUtils::getString( hostnameSettings, "template", QStringLiteral( "${first}-${product}" ) ); m_forbiddenHostNames = CalamaresUtils::getStringList( hostnameSettings, "forbidden_names" ); - m_forbiddenHostNames << QStringLiteral( "localhost" ); + m_forbiddenHostNames << alwaysForbiddenHostNames(); tidy( m_forbiddenHostNames ); }