mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-28 09:55:37 -04:00
[partition] Move partitioning options into a class
- As (auto) partitioning grows more options, the parameter list becomes more unwieldy. Add some structure to it.
This commit is contained in:
parent
5136021416
commit
d2f4079a18
4 changed files with 121 additions and 86 deletions
|
@ -42,6 +42,7 @@
|
|||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Retranslator.h"
|
||||
#include "utils/Units.h"
|
||||
|
||||
#include "Branding.h"
|
||||
#include "GlobalStorage.h"
|
||||
|
@ -417,30 +418,37 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
|
|||
switch ( choice )
|
||||
{
|
||||
case Erase:
|
||||
if ( m_core->isDirty() )
|
||||
{
|
||||
ScanningDialog::run( QtConcurrent::run( [ = ]
|
||||
{
|
||||
QMutexLocker locker( &m_coreMutex );
|
||||
m_core->revertDevice( selectedDevice() );
|
||||
} ),
|
||||
[ = ]
|
||||
{
|
||||
PartitionActions::doAutopartition( m_core,
|
||||
selectedDevice(),
|
||||
m_encryptWidget->passphrase() );
|
||||
emit deviceChosen();
|
||||
},
|
||||
this );
|
||||
}
|
||||
else
|
||||
{
|
||||
PartitionActions::doAutopartition( m_core,
|
||||
selectedDevice(),
|
||||
m_encryptWidget->passphrase() );
|
||||
emit deviceChosen();
|
||||
}
|
||||
auto gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
|
||||
PartitionActions::Choices::AutoPartitionOptions options {
|
||||
gs->value( "defaultFileSystemType" ).toString(),
|
||||
m_encryptWidget->passphrase(),
|
||||
gs->value( "efiSystemPartition" ).toString(),
|
||||
CalamaresUtils::GiBtoBytes( gs->value( "requiredStorageGB" ).toDouble() ),
|
||||
static_cast<PartitionActions::Choices::SwapChoice>( m_eraseSwapChoices->currentData().toInt() )
|
||||
};
|
||||
|
||||
if ( m_core->isDirty() )
|
||||
{
|
||||
ScanningDialog::run( QtConcurrent::run( [ = ]
|
||||
{
|
||||
QMutexLocker locker( &m_coreMutex );
|
||||
m_core->revertDevice( selectedDevice() );
|
||||
} ),
|
||||
[ = ]
|
||||
{
|
||||
PartitionActions::doAutopartition( m_core, selectedDevice(), options );
|
||||
emit deviceChosen();
|
||||
},
|
||||
this );
|
||||
}
|
||||
else
|
||||
{
|
||||
PartitionActions::doAutopartition( m_core, selectedDevice(), options );
|
||||
emit deviceChosen();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Replace:
|
||||
if ( m_core->isDirty() )
|
||||
|
@ -518,6 +526,7 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current,
|
|||
->value( "requiredStorageGB" )
|
||||
.toDouble();
|
||||
|
||||
// TODO: make this consistent
|
||||
qint64 requiredStorageB = qRound64( requiredStorageGB + 0.1 + 2.0 ) * 1024 * 1024 * 1024;
|
||||
|
||||
m_afterPartitionSplitterWidget->setSplitPartition(
|
||||
|
@ -802,14 +811,19 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
|
|||
if ( homePartitionPath->isEmpty() )
|
||||
doReuseHomePartition = false;
|
||||
|
||||
PartitionActions::doReplacePartition( m_core,
|
||||
selectedDevice(),
|
||||
selectedPartition,
|
||||
m_encryptWidget->passphrase() );
|
||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
|
||||
PartitionActions::doReplacePartition(
|
||||
m_core,
|
||||
selectedDevice(),
|
||||
selectedPartition,
|
||||
{
|
||||
gs->value( "defaultFileSystemType" ).toString(),
|
||||
m_encryptWidget->passphrase()
|
||||
} );
|
||||
Partition* homePartition = KPMHelpers::findPartitionByPath( { selectedDevice() },
|
||||
*homePartitionPath );
|
||||
|
||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
if ( homePartition && doReuseHomePartition )
|
||||
{
|
||||
PartitionInfo::setMountPoint( homePartition, "/home" );
|
||||
|
|
|
@ -85,6 +85,8 @@ ReplaceWidget::reset()
|
|||
void
|
||||
ReplaceWidget::applyChanges()
|
||||
{
|
||||
auto gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
|
||||
PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() );
|
||||
if ( model )
|
||||
{
|
||||
|
@ -93,7 +95,9 @@ ReplaceWidget::applyChanges()
|
|||
{
|
||||
Device* dev = model->device();
|
||||
|
||||
PartitionActions::doReplacePartition( m_core, dev, partition );
|
||||
PartitionActions::doReplacePartition(
|
||||
m_core, dev, partition,
|
||||
{ gs->value( "defaultFileSystemType" ).toString(), QString() } );
|
||||
|
||||
if ( m_isEfi )
|
||||
{
|
||||
|
@ -102,17 +106,13 @@ ReplaceWidget::applyChanges()
|
|||
{
|
||||
PartitionInfo::setMountPoint(
|
||||
efiSystemPartitions.first(),
|
||||
Calamares::JobQueue::instance()->
|
||||
globalStorage()->
|
||||
value( "efiSystemPartition" ).toString() );
|
||||
gs->value( "efiSystemPartition" ).toString() );
|
||||
}
|
||||
else if ( efiSystemPartitions.count() > 1 )
|
||||
{
|
||||
PartitionInfo::setMountPoint(
|
||||
efiSystemPartitions.at( m_ui->bootComboBox->currentIndex() ),
|
||||
Calamares::JobQueue::instance()->
|
||||
globalStorage()->
|
||||
value( "efiSystemPartition" ).toString() );
|
||||
gs->value( "efiSystemPartition" ).toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue