Make sure we always set the filesystem label.

In particular, we need a separate Job class to set the label; this
is invoked after we formatted a partition, and when no other changes
to the partition have been requested in the Edit dialog.
This commit is contained in:
shainer 2016-07-23 19:04:23 +01:00 committed by Adriaan de Groot
parent 3d49379bec
commit c035029f38
6 changed files with 172 additions and 3 deletions

View file

@ -62,6 +62,10 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
this,
&EditExistingPartitionDialog::checkMountPointSelection );
// The filesystem label dialog is always enabled, because we may want to change
// the label on the current filesystem without formatting.
m_ui->fileSystemLabelEdit->setText( m_partition->fileSystem().label() );
replacePartResizerWidget();
connect( m_ui->formatRadioButton, &QAbstractButton::toggled, [this]( bool doFormat ) {
@ -70,9 +74,6 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device,
m_ui->fileSystemLabel->setEnabled( doFormat );
m_ui->fileSystemComboBox->setEnabled( doFormat );
m_ui->fileSystemLabelEdit->setEnabled( doFormat );
m_ui->fileSystemLabelEdit->setText( m_partition->fileSystem().label() );
if ( !doFormat )
{
m_ui->fileSystemComboBox->setCurrentText( userVisibleFS( m_partition->fileSystem() ) );
@ -195,6 +196,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
{
core->setPartitionFlags( m_device, m_partition, resultFlags );
}
core->setFilesystemLabel( m_device, m_partition, fsLabel );
}
else // otherwise, we delete and recreate the partition with new fs type
{
@ -220,6 +222,13 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
{
core->setPartitionFlags( m_device, m_partition, resultFlags );
}
// In this case, we are not formatting the partition, but we are setting the
// label on the current filesystem, if any. We only create the job if the
// label actually changed.
if (m_partition->fileSystem().type() != FileSystem::Type::Unformatted &&
fsLabel != m_partition->fileSystem().label()) {
core->setFilesystemLabel( m_device, m_partition, fsLabel );
}
core->refreshPartition( m_device, m_partition );
}
}