React to reuse home checkbox by setting /home mount point.
Rearranged Replace workflow a bit: onPartitionReplaceSelected is now the on choice slot, which in turn calls doReplaceSelectedPartition. onHomeCheckBoxStateChanged also calls doReplaceSelectedPartition if we need to redo the Replace task with/without a separate home to keep. m_reuseHomeCheckBox is hidden by default.
This commit is contained in:
parent
bc345b3ddc
commit
a17f369cee
@ -128,7 +128,7 @@ ChoicePage::ChoicePage( QWidget* parent )
|
|||||||
m_previewAfterLabel->hide();
|
m_previewAfterLabel->hide();
|
||||||
m_previewAfterFrame->hide();
|
m_previewAfterFrame->hide();
|
||||||
m_encryptWidget->hide();
|
m_encryptWidget->hide();
|
||||||
// end
|
m_reuseHomeCheckBox->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -166,6 +166,8 @@ ChoicePage::init( PartitionCoreModule* core )
|
|||||||
|
|
||||||
connect( m_encryptWidget, &EncryptWidget::stateChanged,
|
connect( m_encryptWidget, &EncryptWidget::stateChanged,
|
||||||
this, &ChoicePage::onEncryptWidgetStateChanged );
|
this, &ChoicePage::onEncryptWidgetStateChanged );
|
||||||
|
connect( m_reuseHomeCheckBox, &QCheckBox::stateChanged,
|
||||||
|
this, &ChoicePage::onHomeCheckBoxStateChanged );
|
||||||
|
|
||||||
ChoicePage::applyDeviceChoice();
|
ChoicePage::applyDeviceChoice();
|
||||||
}
|
}
|
||||||
@ -374,14 +376,18 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice )
|
|||||||
} ),
|
} ),
|
||||||
[ = ]
|
[ = ]
|
||||||
{
|
{
|
||||||
PartitionActions::doAutopartition( m_core, selectedDevice(), m_encryptWidget->passphrase() );
|
PartitionActions::doAutopartition( m_core,
|
||||||
|
selectedDevice(),
|
||||||
|
m_encryptWidget->passphrase() );
|
||||||
emit deviceChosen();
|
emit deviceChosen();
|
||||||
},
|
},
|
||||||
this );
|
this );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PartitionActions::doAutopartition( m_core, selectedDevice(), m_encryptWidget->passphrase() );
|
PartitionActions::doAutopartition( m_core,
|
||||||
|
selectedDevice(),
|
||||||
|
m_encryptWidget->passphrase() );
|
||||||
emit deviceChosen();
|
emit deviceChosen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,7 +406,7 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice )
|
|||||||
updateNextEnabled();
|
updateNextEnabled();
|
||||||
|
|
||||||
connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ),
|
connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ),
|
||||||
this, SLOT( doReplaceSelectedPartition( QModelIndex, QModelIndex ) ),
|
this, SLOT( onPartitionToReplaceSelected( QModelIndex, QModelIndex ) ),
|
||||||
Qt::UniqueConnection );
|
Qt::UniqueConnection );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -500,14 +506,26 @@ ChoicePage::onEncryptWidgetStateChanged()
|
|||||||
{
|
{
|
||||||
doReplaceSelectedPartition( m_beforePartitionBarsView->
|
doReplaceSelectedPartition( m_beforePartitionBarsView->
|
||||||
selectionModel()->
|
selectionModel()->
|
||||||
currentIndex(),
|
currentIndex() );
|
||||||
QModelIndex() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateNextEnabled();
|
updateNextEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ChoicePage::onHomeCheckBoxStateChanged()
|
||||||
|
{
|
||||||
|
if ( currentChoice() == Replace &&
|
||||||
|
m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() )
|
||||||
|
{
|
||||||
|
doReplaceSelectedPartition( m_beforePartitionBarsView->
|
||||||
|
selectionModel()->
|
||||||
|
currentIndex() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ChoicePage::onLeave()
|
ChoicePage::onLeave()
|
||||||
{
|
{
|
||||||
@ -616,14 +634,33 @@ ChoicePage::doAlongsideApply()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ChoicePage::doReplaceSelectedPartition( const QModelIndex& current,
|
ChoicePage::onPartitionToReplaceSelected( const QModelIndex& current,
|
||||||
const QModelIndex& previous )
|
const QModelIndex& previous )
|
||||||
{
|
{
|
||||||
Q_UNUSED( previous );
|
Q_UNUSED( previous );
|
||||||
if ( !current.isValid() )
|
if ( !current.isValid() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ScanningDialog::run( QtConcurrent::run( [ = ]
|
// Reset state on selection regardless of whether this will be used.
|
||||||
|
m_reuseHomeCheckBox->setChecked( false );
|
||||||
|
|
||||||
|
doReplaceSelectedPartition( current );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ChoicePage::doReplaceSelectedPartition( const QModelIndex& current )
|
||||||
|
{
|
||||||
|
if ( !current.isValid() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
QString homePartitionPath;
|
||||||
|
bool doReuseHomePartition = m_reuseHomeCheckBox->isChecked();
|
||||||
|
|
||||||
|
// NOTE: using by-ref captures because we need to write homePartitionPath and
|
||||||
|
// doReuseHomePartition *after* the device revert, for later use.
|
||||||
|
ScanningDialog::run( QtConcurrent::run(
|
||||||
|
[ this, ¤t, &homePartitionPath, &doReuseHomePartition ]
|
||||||
{
|
{
|
||||||
QMutexLocker locker( &m_coreMutex );
|
QMutexLocker locker( &m_coreMutex );
|
||||||
|
|
||||||
@ -632,11 +669,20 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current,
|
|||||||
m_core->revertDevice( selectedDevice() );
|
m_core->revertDevice( selectedDevice() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Find out is the selected partition has a rootfs. If yes, then make the
|
||||||
|
// m_reuseHomeCheckBox visible and set its text to something meaningful.
|
||||||
|
homePartitionPath = current.data( PartitionModel::OsproberHomePartitionPathRole ).toString();
|
||||||
|
if ( homePartitionPath.isEmpty() )
|
||||||
|
doReuseHomePartition = false;
|
||||||
|
|
||||||
// if the partition is unallocated(free space), we don't replace it but create new one
|
// if the partition is unallocated(free space), we don't replace it but create new one
|
||||||
// with the same first and last sector
|
// with the same first and last sector
|
||||||
Partition* selectedPartition = (Partition *)( current.data( PartitionModel::PartitionPtrRole ).value< void* >() );
|
Partition* selectedPartition = (Partition *)( current.data( PartitionModel::PartitionPtrRole ).value< void* >() );
|
||||||
if ( KPMHelpers::isPartitionFreeSpace( selectedPartition ) )
|
if ( KPMHelpers::isPartitionFreeSpace( selectedPartition ) )
|
||||||
{
|
{
|
||||||
|
//NOTE: if the selected partition is free space, we don't deal with
|
||||||
|
// a separate /home partition at all because there's no existing
|
||||||
|
// rootfs to read it from.
|
||||||
PartitionRole newRoles = PartitionRole( PartitionRole::Primary );
|
PartitionRole newRoles = PartitionRole( PartitionRole::Primary );
|
||||||
PartitionNode* newParent = selectedDevice()->partitionTable();
|
PartitionNode* newParent = selectedDevice()->partitionTable();
|
||||||
|
|
||||||
@ -686,14 +732,24 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current,
|
|||||||
selectedPartition = KPMHelpers::findPartitionByPath( { selectedDevice() },
|
selectedPartition = KPMHelpers::findPartitionByPath( { selectedDevice() },
|
||||||
partPath );
|
partPath );
|
||||||
if ( selectedPartition )
|
if ( selectedPartition )
|
||||||
|
{
|
||||||
PartitionActions::doReplacePartition( m_core,
|
PartitionActions::doReplacePartition( m_core,
|
||||||
selectedDevice(),
|
selectedDevice(),
|
||||||
selectedPartition,
|
selectedPartition,
|
||||||
m_encryptWidget->passphrase() );
|
m_encryptWidget->passphrase() );
|
||||||
|
Partition* homePartition = KPMHelpers::findPartitionByPath( { selectedDevice() },
|
||||||
|
homePartitionPath );
|
||||||
|
if ( homePartition )
|
||||||
|
{
|
||||||
|
PartitionInfo::setMountPoint( homePartition, "/home" );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} ),
|
} ),
|
||||||
[=]
|
[&]
|
||||||
{
|
{
|
||||||
|
m_reuseHomeCheckBox->setVisible( !homePartitionPath.isEmpty() );
|
||||||
|
|
||||||
if ( m_isEfi )
|
if ( m_isEfi )
|
||||||
setupEfiSystemPartitionSelector();
|
setupEfiSystemPartitionSelector();
|
||||||
|
|
||||||
|
@ -73,9 +73,11 @@ signals:
|
|||||||
void deviceChosen();
|
void deviceChosen();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void doReplaceSelectedPartition( const QModelIndex& current, const QModelIndex& previous );
|
void onPartitionToReplaceSelected( const QModelIndex& current, const QModelIndex& previous );
|
||||||
|
void doReplaceSelectedPartition( const QModelIndex& current );
|
||||||
void doAlongsideSetupSplitter( const QModelIndex& current, const QModelIndex& previous );
|
void doAlongsideSetupSplitter( const QModelIndex& current, const QModelIndex& previous );
|
||||||
void onEncryptWidgetStateChanged();
|
void onEncryptWidgetStateChanged();
|
||||||
|
void onHomeCheckBoxStateChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateNextEnabled();
|
void updateNextEnabled();
|
||||||
|
Loading…
Reference in New Issue
Block a user