Merge branch 'calamares' into fixfsreplace

This commit is contained in:
dalto 2023-02-18 15:20:51 -06:00
commit ab51a2ea03
19 changed files with 94 additions and 660 deletions

View File

@ -88,7 +88,6 @@ if(KPMcore_FOUND)
gui/PartitionSplitterWidget.cpp
gui/ResizeVolumeGroupDialog.cpp
gui/ScanningDialog.cpp
gui/ReplaceWidget.cpp
gui/VolumeGroupBaseDialog.cpp
jobs/AutoMountManagementJob.cpp
jobs/ChangeFilesystemLabelJob.cpp
@ -113,7 +112,6 @@ if(KPMcore_FOUND)
gui/EditExistingPartitionDialog.ui
gui/EncryptWidget.ui
gui/PartitionPage.ui
gui/ReplaceWidget.ui
gui/VolumeGroupBaseDialog.ui
LINK_PRIVATE_LIBRARIES
calamares::kpmcore

View File

@ -25,23 +25,36 @@ Config::Config( QObject* parent )
const NamedEnumTable< Config::InstallChoice >&
Config::installChoiceNames()
{
static const NamedEnumTable< InstallChoice > names { { QStringLiteral( "none" ), InstallChoice::NoChoice },
{ QStringLiteral( "nochoice" ), InstallChoice::NoChoice },
{ QStringLiteral( "alongside" ), InstallChoice::Alongside },
{ QStringLiteral( "erase" ), InstallChoice::Erase },
{ QStringLiteral( "replace" ), InstallChoice::Replace },
{ QStringLiteral( "manual" ), InstallChoice::Manual } };
// *INDENT-OFF*
// clang-format off
static const NamedEnumTable< InstallChoice > names {
{ QStringLiteral( "none" ), InstallChoice::NoChoice },
{ QStringLiteral( "nochoice" ), InstallChoice::NoChoice },
{ QStringLiteral( "alongside" ), InstallChoice::Alongside },
{ QStringLiteral( "erase" ), InstallChoice::Erase },
{ QStringLiteral( "replace" ), InstallChoice::Replace },
{ QStringLiteral( "manual" ), InstallChoice::Manual },
};
// clang-format on
// *INDENT-ON*
return names;
}
const NamedEnumTable< Config::SwapChoice >&
Config::swapChoiceNames()
{
static const NamedEnumTable< SwapChoice > names { { QStringLiteral( "none" ), SwapChoice::NoSwap },
{ QStringLiteral( "small" ), SwapChoice::SmallSwap },
{ QStringLiteral( "suspend" ), SwapChoice::FullSwap },
{ QStringLiteral( "reuse" ), SwapChoice::ReuseSwap },
{ QStringLiteral( "file" ), SwapChoice::SwapFile } };
// *INDENT-OFF*
// clang-format off
static const NamedEnumTable< SwapChoice > names {
{ QStringLiteral( "none" ), SwapChoice::NoSwap },
{ QStringLiteral( "small" ), SwapChoice::SmallSwap },
{ QStringLiteral( "suspend" ), SwapChoice::FullSwap },
{ QStringLiteral( "reuse" ), SwapChoice::ReuseSwap },
{ QStringLiteral( "file" ), SwapChoice::SwapFile },
};
// clang-format on
// *INDENT-ON*
return names;
}
@ -49,29 +62,19 @@ Config::swapChoiceNames()
const NamedEnumTable< Config::LuksGeneration >&
Config::luksGenerationNames()
{
static const NamedEnumTable< LuksGeneration > names { { QStringLiteral( "luks1" ), LuksGeneration::Luks1 },
{ QStringLiteral( "luks2" ), LuksGeneration::Luks2 } };
// *INDENT-OFF*
// clang-format off
static const NamedEnumTable< LuksGeneration > names {
{ QStringLiteral( "luks1" ), LuksGeneration::Luks1 },
{ QStringLiteral( "luks" ), LuksGeneration::Luks1 },
{ QStringLiteral( "luks2" ), LuksGeneration::Luks2 },
};
// clang-format on
// *INDENT-ON*
return names;
}
const QString
Config::luksGenerationToFSName( Config::LuksGeneration luksGeneration )
{
// Convert luksGenerationChoice from partition.conf into its
// corresponding file system type from KPMCore.
switch ( luksGeneration )
{
case Config::LuksGeneration::Luks2:
return QStringLiteral( "luks2" );
case Config::LuksGeneration::Luks1:
return QStringLiteral( "luks" );
default:
cWarning() << "luksGeneration not supported, defaulting to \"luks\"";
return QStringLiteral( "luks" );
}
}
Config::SwapChoice
pickOne( const Config::SwapChoiceSet& s )
{
@ -369,8 +372,8 @@ Config::fillConfigurationFSTypes( const QVariantMap& configurationMap )
cWarning() << "Partition-module setting *luksGeneration* not found or invalid. Defaulting to luks1.";
luksGeneration = Config::LuksGeneration::Luks1;
}
m_luksFileSystemType = Config::luksGenerationToFSName( luksGeneration );
gs->insert( "luksFileSystemType", m_luksFileSystemType );
m_luksFileSystemType = luksGeneration;
gs->insert( "luksFileSystemType", luksGenerationNames().find(luksGeneration) );
Q_ASSERT( !m_eraseFsTypes.isEmpty() );
Q_ASSERT( m_eraseFsTypes.contains( fsRealName ) );

View File

@ -67,14 +67,13 @@ public:
using EraseFsTypesSet = QStringList;
/** @brief Choice of LUKS disk encryption generation */
enum LuksGeneration
enum class LuksGeneration
{
Luks1, // First generation of LUKS
Luks2, // Second generation of LUKS, default since cryptsetup >= 2.1.0
};
Q_ENUM( LuksGeneration )
static const NamedEnumTable< LuksGeneration >& luksGenerationNames();
static const QString luksGenerationToFSName( LuksGeneration choice );
void setConfigurationMap( const QVariantMap& );
/** @brief Set GS values where other modules configuration has priority
@ -125,15 +124,6 @@ public:
*/
SwapChoice swapChoice() const { return m_swapChoice; }
/** @brief The conversion of the luksGeneration into its FS type.
*
* Will convert Luks1 into "luks" and Luks2 into "luks2" for KPMCore
* partitionning functions.
*
* @return The LUKS FS type (default @c "luks" )
*/
QString luksFileSystemType() const { return m_luksFileSystemType; }
/** @brief Get the list of configured FS types to use with *erase* mode
*
* This list is not empty.
@ -165,6 +155,10 @@ public:
/// @brief Returns list of acceptable types. May be empty.
QStringList partitionTableTypes() const { return m_requiredPartitionTableType; }
/** @brief The configured LUKS generation (1 or 2)
*/
LuksGeneration luksFileSystemType() const { return m_luksFileSystemType; }
public Q_SLOTS:
void setInstallChoice( int ); ///< Translates a button ID or so to InstallChoice
void setInstallChoice( InstallChoice );
@ -190,7 +184,7 @@ private:
SwapChoiceSet m_swapChoices;
SwapChoice m_initialSwapChoice = NoSwap;
SwapChoice m_swapChoice = NoSwap;
QString m_luksFileSystemType;
LuksGeneration m_luksFileSystemType = LuksGeneration::Luks1;
InstallChoice m_initialInstallChoice = NoChoice;
InstallChoice m_installChoice = NoChoice;
qreal m_requiredStorageGiB = 0.0; // May duplicate setting in the welcome module

View File

@ -447,7 +447,6 @@ PartitionViewStep::onActivate()
{
m_choicePage->applyActionChoice( Config::InstallChoice::Alongside );
// m_choicePage->reset();
//FIXME: ReplaceWidget should be reset maybe?
}
}

View File

@ -84,7 +84,7 @@ createNewEncryptedPartition( PartitionNode* parent,
const QString& fsLabel,
qint64 firstSector,
qint64 lastSector,
const QString& luksFsType, // "luks" or "luks2"
Config::LuksGeneration luksFsType,
const QString& passphrase,
PartitionTable::Flags flags )
{
@ -94,7 +94,7 @@ createNewEncryptedPartition( PartitionNode* parent,
newRoles |= PartitionRole::Luks;
}
FileSystem::Type luksType = FileSystem::typeForName( luksFsType );
FileSystem::Type luksType = luksGenerationToFSName( luksFsType );
FS::luks* fs = dynamic_cast< FS::luks* >(
FileSystemFactory::create( luksType, firstSector, lastSector, device.logicalSize() ) );
@ -299,6 +299,24 @@ cryptVersion( Partition* partition )
return luksVersion;
}
FileSystem::Type
luksGenerationToFSName( Config::LuksGeneration luksGeneration )
{
// Convert luksGenerationChoice from partition.conf into its
// corresponding file system type from KPMCore.
switch ( luksGeneration )
{
case Config::LuksGeneration::Luks2:
return FileSystem::Type::Luks2;
case Config::LuksGeneration::Luks1:
return FileSystem::Type::Luks;
default:
cWarning() << "luksGeneration not supported, defaulting to \"luks\"";
return FileSystem::Type::Luks;
}
}
Calamares::JobResult
execute( Operation& operation, const QString& failureMessage )
{

View File

@ -11,6 +11,7 @@
#ifndef KPMHELPERS_H
#define KPMHELPERS_H
#include "Config.h"
#include "Job.h"
#include <kpmcore/core/partitiontable.h>
@ -83,7 +84,7 @@ Partition* createNewEncryptedPartition( PartitionNode* parent,
const QString& fsLabel,
qint64 firstSector,
qint64 lastSector,
const QString& luksFsType,
Config::LuksGeneration luksFsType,
const QString& passphrase,
PartitionTable::Flags flags );
@ -120,6 +121,17 @@ bool cryptLabel( Partition* partition, const QString& label );
*/
int cryptVersion( Partition* partition );
/** @brief Convert a luksGeneration into its FS type for KPMCore.
*
* Will convert Luks1 into FileSystem::Type::luks and Luks2 into
* FileSystem::Type::luks2 for KPMCore partitioning functions.
*
* @return The LUKS FS type (default @c luks )
*/
FileSystem::Type
luksGenerationToFSName( Config::LuksGeneration luksGeneration );
/** @brief Return a result for an @p operation
*
* Executes the operation, and if successful, returns a success result.

View File

@ -31,12 +31,12 @@ struct ReplacePartitionOptions
{
QString defaultPartitionTableType; // e.g. "gpt" or "msdos"
QString defaultFsType; // e.g. "ext4" or "btrfs"
QString luksFsType; // optional ("luks", "luks2")
Config::LuksGeneration luksFsType = Config::LuksGeneration::Luks1; // optional ("luks", "luks2")
QString luksPassphrase; // optional
ReplacePartitionOptions( const QString& pt,
const QString& fs,
const QString& luksFs,
Config::LuksGeneration luksFs,
const QString& luksPassphrase )
: defaultPartitionTableType( pt )
, defaultFsType( fs )
@ -54,7 +54,7 @@ struct AutoPartitionOptions : ReplacePartitionOptions
AutoPartitionOptions( const QString& pt,
const QString& fs,
const QString& luksFs,
Config::LuksGeneration luksFs,
const QString& luksPassphrase,
const QString& efi,
qint64 requiredBytes,

View File

@ -952,12 +952,12 @@ void
PartitionCoreModule::layoutApply( Device* dev,
qint64 firstSector,
qint64 lastSector,
QString luksFsType,
Config::LuksGeneration luksFsType,
QString luksPassphrase,
PartitionNode* parent,
const PartitionRole& role )
{
bool isEfi = PartUtils::isEfiSystem();
const bool isEfi = PartUtils::isEfiSystem();
QList< Partition* > partList
= m_partLayout.createPartitions( dev, firstSector, lastSector, luksFsType, luksPassphrase, parent, role );
@ -1003,7 +1003,7 @@ void
PartitionCoreModule::layoutApply( Device* dev,
qint64 firstSector,
qint64 lastSector,
QString luksFsType,
Config::LuksGeneration luksFsType,
QString luksPassphrase )
{
layoutApply( dev,

View File

@ -12,6 +12,7 @@
#ifndef PARTITIONCOREMODULE_H
#define PARTITIONCOREMODULE_H
#include "Config.h"
#include "core/KPMHelpers.h"
#include "core/PartitionLayout.h"
#include "core/PartitionModel.h"
@ -166,11 +167,11 @@ public:
*/
PartitionLayout& partitionLayout() { return m_partLayout; }
void layoutApply( Device* dev, qint64 firstSector, qint64 lastSector, QString luksFsType, QString luksPassphrase );
void layoutApply( Device* dev, qint64 firstSector, qint64 lastSector, Config::LuksGeneration luksFsType, QString luksPassphrase );
void layoutApply( Device* dev,
qint64 firstSector,
qint64 lastSector,
QString luksFsType,
Config::LuksGeneration luksFsType,
QString luksPassphrase,
PartitionNode* parent,
const PartitionRole& role );

View File

@ -204,7 +204,7 @@ QList< Partition* >
PartitionLayout::createPartitions( Device* dev,
qint64 firstSector,
qint64 lastSector,
QString luksFsType,
Config::LuksGeneration luksFsType,
QString luksPassphrase,
PartitionNode* parent,
const PartitionRole& role )

View File

@ -11,9 +11,9 @@
#ifndef PARTITIONLAYOUT_H
#define PARTITIONLAYOUT_H
#include "partition/PartitionSize.h"
#include "Config.h"
#include "core/PartUtils.h"
#include "partition/PartitionSize.h"
// KPMcore
#include <kpmcore/core/partitiontable.h>
@ -116,7 +116,7 @@ public:
QList< Partition* > createPartitions( Device* dev,
qint64 firstSector,
qint64 lastSector,
QString luksFsType,
Config::LuksGeneration luksFsType,
QString luksPassphrase,
PartitionNode* parent,
const PartitionRole& role );

View File

@ -28,7 +28,6 @@
#include "gui/PartitionBarsView.h"
#include "gui/PartitionLabelsView.h"
#include "gui/PartitionSplitterWidget.h"
#include "gui/ReplaceWidget.h"
#include "gui/ScanningDialog.h"
#include "Branding.h"
@ -500,7 +499,7 @@ ChoicePage::applyActionChoice( InstallChoice choice )
auto gs = Calamares::JobQueue::instance()->globalStorage();
PartitionActions::Choices::AutoPartitionOptions options { gs->value( "defaultPartitionTableType" ).toString(),
m_config->eraseFsType(),
gs->value( "luksFileSystemType" ).toString(),
m_config->luksFileSystemType(),
m_encryptWidget->passphrase(),
gs->value( "efiSystemPartition" ).toString(),
CalamaresUtils::GiBtoBytes(

View File

@ -257,7 +257,7 @@ CreatePartitionDialog::getNewlyCreatedPartition()
fsLabel,
first,
last,
luksFsType,
Config::luksGenerationNames().find(luksFsType, Config::LuksGeneration::Luks1),
luksPassphrase,
PartitionTable::Flags() );
}

View File

@ -1,394 +0,0 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
* SPDX-FileCopyrightText: 2014 Aurélien Gâteau <agateau@kde.org>
* SPDX-FileCopyrightText: 2019-2020 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*/
#include "ReplaceWidget.h"
#include "ui_ReplaceWidget.h"
#include "core/DeviceModel.h"
#include "core/PartitionActions.h"
#include "core/PartitionCoreModule.h"
#include "core/PartitionInfo.h"
#include "Branding.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "partition/FileSystem.h"
#include "utils/CalamaresUtilsGui.h"
#include "utils/Retranslator.h"
#include <kpmcore/core/partition.h>
#include <kpmcore/fs/filesystem.h>
#include <QComboBox>
using CalamaresUtils::Partition::untranslatedFS;
using CalamaresUtils::Partition::userVisibleFS;
ReplaceWidget::ReplaceWidget( PartitionCoreModule* core, QComboBox* devicesComboBox, QWidget* parent )
: QWidget( parent )
, m_ui( new Ui_ReplaceWidget )
, m_core( core )
, m_isEfi( false )
{
m_ui->setupUi( this );
m_ui->bootComboBox->hide();
m_ui->bootComboBox->clear();
m_ui->bootStatusLabel->hide();
m_ui->bootStatusLabel->clear();
updateFromCurrentDevice( devicesComboBox );
connect( devicesComboBox,
&QComboBox::currentTextChanged,
this,
[ = ]( const QString& /* text */ ) { updateFromCurrentDevice( devicesComboBox ); } );
CALAMARES_RETRANSLATE( onPartitionSelected(); );
}
ReplaceWidget::~ReplaceWidget() {}
bool
ReplaceWidget::isNextEnabled() const
{
return m_nextEnabled;
}
void
ReplaceWidget::reset()
{
//moo;
}
void
ReplaceWidget::applyChanges()
{
auto gs = Calamares::JobQueue::instance()->globalStorage();
PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() );
if ( model )
{
Partition* partition = model->partitionForIndex( m_ui->partitionTreeView->currentIndex() );
if ( partition )
{
Device* dev = model->device();
PartitionActions::doReplacePartition( m_core,
dev,
partition,
{ gs->value( "defaultPartitionTableType" ).toString(),
gs->value( "defaultFileSystemType" ).toString(),
gs->value( "luksFileSystemType" ).toString(),
QString() } );
if ( m_isEfi )
{
QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions();
if ( efiSystemPartitions.count() == 1 )
{
PartitionInfo::setMountPoint( efiSystemPartitions.first(),
gs->value( "efiSystemPartition" ).toString() );
}
else if ( efiSystemPartitions.count() > 1 )
{
PartitionInfo::setMountPoint( efiSystemPartitions.at( m_ui->bootComboBox->currentIndex() ),
gs->value( "efiSystemPartition" ).toString() );
}
}
m_core->dumpQueue();
}
}
}
void
ReplaceWidget::onPartitionSelected()
{
if ( Calamares::JobQueue::instance()->globalStorage()->value( "firmwareType" ) == "efi" )
{
m_isEfi = true;
}
const auto* branding = Calamares::Branding::instance();
if ( m_ui->partitionTreeView->currentIndex() == QModelIndex() )
{
updateStatus( CalamaresUtils::PartitionPartition,
tr( "Select where to install %1.<br/>"
"<font color=\"red\">Warning: </font>this will delete all files "
"on the selected partition." )
.arg( branding->versionedName() ) );
setNextEnabled( false );
return;
}
bool ok = false;
double requiredSpaceB
= Calamares::JobQueue::instance()->globalStorage()->value( "requiredStorageGiB" ).toDouble( &ok ) * 1024 * 1024
* 1024;
PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() );
if ( model && ok )
{
const QStringList osproberLines
= Calamares::JobQueue::instance()->globalStorage()->value( "osproberLines" ).toStringList();
Partition* partition = model->partitionForIndex( m_ui->partitionTreeView->currentIndex() );
if ( !partition || partition->state() != KPM_PARTITION_STATE( None ) )
{
updateStatus( CalamaresUtils::Fail, tr( "The selected item does not appear to be a valid partition." ) );
setNextEnabled( false );
return;
}
if ( partition->roles().has( PartitionRole::Unallocated ) )
{
updateStatus( CalamaresUtils::Fail,
tr( "%1 cannot be installed on empty space. Please select an "
"existing partition." )
.arg( branding->versionedName() ) );
setNextEnabled( false );
return;
}
if ( partition->roles().has( PartitionRole::Extended ) )
{
updateStatus( CalamaresUtils::Fail,
tr( "%1 cannot be installed on an extended partition. Please select an "
"existing primary or logical partition." )
.arg( branding->versionedName() ) );
setNextEnabled( false );
return;
}
if ( partition->partitionPath().isEmpty() )
{
updateStatus( CalamaresUtils::Fail,
tr( "%1 cannot be installed on this partition." ).arg( branding->versionedName() ) );
setNextEnabled( false );
return;
}
QString fsNameForUser = userVisibleFS( partition->fileSystem() );
QString prettyName = tr( "Data partition (%1)" ).arg( fsNameForUser );
for ( const auto& line : osproberLines )
{
QStringList lineColumns = line.split( ':' );
QString path = lineColumns.value( 0 ).simplified();
if ( path == partition->partitionPath() )
{
QString osName;
if ( !lineColumns.value( 1 ).simplified().isEmpty() )
{
osName = lineColumns.value( 1 ).simplified();
}
else if ( !lineColumns.value( 2 ).simplified().isEmpty() )
{
osName = lineColumns.value( 2 ).simplified();
}
if ( osName.isEmpty() )
{
prettyName = tr( "Unknown system partition (%1)" ).arg( fsNameForUser );
}
else
{
prettyName = tr( "%1 system partition (%2)" )
.arg( osName.replace( 0, 1, osName.at( 0 ).toUpper() ) )
.arg( fsNameForUser );
}
break;
}
}
// The loss of precision is ok; we're not going to fall over from a single byte
if ( static_cast< double >( partition->capacity() ) < requiredSpaceB )
{
updateStatus( CalamaresUtils::Fail,
tr( "<strong>%4</strong><br/><br/>"
"The partition %1 is too small for %2. Please select a partition "
"with capacity at least %3 GiB." )
.arg( partition->partitionPath() )
.arg( branding->versionedName() )
.arg( requiredSpaceB / ( 1024. * 1024. * 1024. ), 0, 'f', 1 )
.arg( prettyName ) );
setNextEnabled( false );
return;
}
m_ui->bootComboBox->hide();
m_ui->bootComboBox->clear();
m_ui->bootStatusLabel->hide();
m_ui->bootStatusLabel->clear();
if ( m_isEfi )
{
QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions();
if ( efiSystemPartitions.count() == 0 )
{
updateStatus( CalamaresUtils::Fail,
tr( "<strong>%2</strong><br/><br/>"
"An EFI system partition cannot be found anywhere "
"on this system. Please go back and use manual "
"partitioning to set up %1." )
.arg( branding->shortProductName() )
.arg( prettyName ) );
setNextEnabled( false );
}
else if ( efiSystemPartitions.count() == 1 )
{
updateStatus( CalamaresUtils::PartitionPartition,
tr( "<strong>%3</strong><br/><br/>"
"%1 will be installed on %2.<br/>"
"<font color=\"red\">Warning: </font>all data on partition "
"%2 will be lost." )
.arg( branding->versionedName() )
.arg( partition->partitionPath() )
.arg( prettyName ) );
m_ui->bootStatusLabel->show();
m_ui->bootStatusLabel->setText( tr( "The EFI system partition at %1 will be used for starting %2." )
.arg( efiSystemPartitions.first()->partitionPath() )
.arg( branding->shortProductName() ) );
setNextEnabled( true );
}
else
{
updateStatus( CalamaresUtils::PartitionPartition,
tr( "<strong>%3</strong><br/><br/>"
"%1 will be installed on %2.<br/>"
"<font color=\"red\">Warning: </font>all data on partition "
"%2 will be lost." )
.arg( branding->versionedName() )
.arg( partition->partitionPath() )
.arg( prettyName ) );
m_ui->bootStatusLabel->show();
m_ui->bootStatusLabel->setText( tr( "EFI system partition:" ) );
m_ui->bootComboBox->show();
for ( int i = 0; i < efiSystemPartitions.count(); ++i )
{
Partition* efiPartition = efiSystemPartitions.at( i );
m_ui->bootComboBox->addItem( efiPartition->partitionPath(), i );
if ( efiPartition->devicePath() == partition->devicePath() && efiPartition->number() == 1 )
{
m_ui->bootComboBox->setCurrentIndex( i );
}
}
setNextEnabled( true );
}
}
else
{
updateStatus( CalamaresUtils::PartitionPartition,
tr( "<strong>%3</strong><br/><br/>"
"%1 will be installed on %2.<br/>"
"<font color=\"red\">Warning: </font>all data on partition "
"%2 will be lost." )
.arg( branding->versionedName() )
.arg( partition->partitionPath() )
.arg( prettyName ) );
setNextEnabled( true );
}
}
}
void
ReplaceWidget::setNextEnabled( bool enabled )
{
if ( enabled == m_nextEnabled )
{
return;
}
m_nextEnabled = enabled;
Q_EMIT nextStatusChanged( enabled );
}
void
ReplaceWidget::updateStatus( CalamaresUtils::ImageType imageType, const QString& text )
{
int iconSize = CalamaresUtils::defaultFontHeight() * 6;
m_ui->selectedIconLabel->setPixmap(
CalamaresUtils::defaultPixmap( imageType, CalamaresUtils::Original, QSize( iconSize, iconSize ) ) );
m_ui->selectedIconLabel->setFixedHeight( iconSize );
m_ui->selectedStatusLabel->setText( text );
}
void
ReplaceWidget::updateFromCurrentDevice( QComboBox* devicesComboBox )
{
QModelIndex index = m_core->deviceModel()->index( devicesComboBox->currentIndex(), 0 );
if ( !index.isValid() )
{
return;
}
Device* device = m_core->deviceModel()->deviceForIndex( index );
QAbstractItemModel* oldModel = m_ui->partitionTreeView->model();
if ( oldModel )
{
disconnect( oldModel, nullptr, this, nullptr );
}
PartitionModel* model = m_core->partitionModelForDevice( device );
m_ui->partitionTreeView->setModel( model );
m_ui->partitionTreeView->expandAll();
// Must be done here because we need to have a model set to define
// individual column resize mode
QHeaderView* header = m_ui->partitionTreeView->header();
header->setSectionResizeMode( QHeaderView::ResizeToContents );
header->setSectionResizeMode( 0, QHeaderView::Stretch );
//updateButtons();
// Establish connection here because selection model is destroyed when
// model changes
connect( m_ui->partitionTreeView->selectionModel(),
&QItemSelectionModel::currentRowChanged,
this,
&ReplaceWidget::onPartitionViewActivated );
connect( model, &QAbstractItemModel::modelReset, this, &ReplaceWidget::onPartitionModelReset );
}
void
ReplaceWidget::onPartitionViewActivated()
{
QModelIndex index = m_ui->partitionTreeView->currentIndex();
if ( !index.isValid() )
{
return;
}
const PartitionModel* model = static_cast< const PartitionModel* >( index.model() );
Q_ASSERT( model );
Partition* partition = model->partitionForIndex( index );
Q_ASSERT( partition );
onPartitionSelected();
}
void
ReplaceWidget::onPartitionModelReset()
{
m_ui->partitionTreeView->expandAll();
onPartitionSelected();
}

View File

@ -1,61 +0,0 @@
/* === This file is part of Calamares - <https://calamares.io> ===
*
* SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
* SPDX-FileCopyrightText: 2014 Aurélien Gâteau <agateau@kde.org>
* SPDX-FileCopyrightText: 2018 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*
* Calamares is Free Software: see the License-Identifier above.
*
*/
#ifndef REPLACEWIDGET_H
#define REPLACEWIDGET_H
#include "utils/CalamaresUtilsGui.h"
#include <QScopedPointer>
#include <QWidget>
class Ui_ReplaceWidget;
class QComboBox;
class PartitionCoreModule;
class Partition;
class ReplaceWidget : public QWidget
{
Q_OBJECT
public:
explicit ReplaceWidget( PartitionCoreModule* core, QComboBox* devicesComboBox, QWidget* parent = nullptr );
virtual ~ReplaceWidget() override;
bool isNextEnabled() const;
void reset();
void applyChanges();
signals:
void nextStatusChanged( bool );
private slots:
void onPartitionSelected();
private:
QScopedPointer< Ui_ReplaceWidget > m_ui;
void setNextEnabled( bool enabled );
void updateStatus( CalamaresUtils::ImageType imageType, const QString& text );
PartitionCoreModule* m_core;
bool m_nextEnabled;
bool m_isEfi;
void updateFromCurrentDevice( QComboBox* devicesComboBox );
void onPartitionViewActivated();
void onPartitionModelReset();
};
#endif // REPLACEWIDGET_H

View File

@ -1,135 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>
SPDX-FileCopyrightText: 2014 Teo Mrnjavac &lt;teo@kde.org&gt;
SPDX-License-Identifier: GPL-3.0-or-later
</author>
<class>ReplaceWidget</class>
<widget class="QWidget" name="ReplaceWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>643</width>
<height>187</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTreeView" name="partitionTreeView">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
</property>
<property name="expandsOnDoubleClick">
<bool>false</bool>
</property>
<attribute name="headerStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="selectedIconLabel">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="selectedStatusLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="bootStatusLabel">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="bootComboBox"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -72,7 +72,7 @@ userSwapChoices:
# also set to luks2. Also there are some patches for grub and Argon2.
# See: https://aur.archlinux.org/packages/grub-improved-luks2-git
#
# Choices: luks1, luks2
# Choices: luks1, luks2 (in addition, "luks" means "luks1")
#
# The default is luks1
#

View File

@ -20,7 +20,7 @@ properties:
defaultFileSystemType: { type: string }
availableFileSystemTypes: { type: array, items: { type: string } }
luksGeneration: { type: string, enum: [luks1, luks2] }
luksGeneration: { type: string, enum: [luks1, luks2] } # Also allows "luks" as alias of "luks1"
enableLuksAutomatedPartitioning: { type: boolean, default: false }
allowManualPartitioning: { type: boolean, default: true }

View File

@ -64,7 +64,7 @@ CreateLayoutsTests::testFixedSizePartition()
}
partitions = layout.createPartitions(
static_cast< Device* >( &dev ), 0, dev.totalLogical(), nullptr, nullptr, nullptr, role );
static_cast< Device* >( &dev ), 0, dev.totalLogical(), Config::LuksGeneration::Luks1, nullptr, nullptr, role );
QCOMPARE( partitions.count(), 1 );
@ -85,7 +85,7 @@ CreateLayoutsTests::testPercentSizePartition()
}
partitions = layout.createPartitions(
static_cast< Device* >( &dev ), 0, dev.totalLogical(), nullptr, nullptr, nullptr, role );
static_cast< Device* >( &dev ), 0, dev.totalLogical(), Config::LuksGeneration::Luks1, nullptr, nullptr, role );
QCOMPARE( partitions.count(), 1 );
@ -116,7 +116,7 @@ CreateLayoutsTests::testMixedSizePartition()
}
partitions = layout.createPartitions(
static_cast< Device* >( &dev ), 0, dev.totalLogical(), nullptr, nullptr, nullptr, role );
static_cast< Device* >( &dev ), 0, dev.totalLogical(), Config::LuksGeneration::Luks1, nullptr, nullptr, role );
QCOMPARE( partitions.count(), 3 );