From a2b21ee0873bdbf9cde18d1537286a1a855ca78f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 17 Feb 2024 14:18:24 +0100 Subject: [PATCH 01/10] [partition] Improve readability in edit-existing-partition Pick out the condition and give it a name. The logic is the same -- and is made worse because of the if() which looks redundant at this point. --- .../gui/EditExistingPartitionDialog.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index 55303d06d..9636799a9 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -130,10 +130,18 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() ); // Force a format if the existing device is a zfs device since reusing a zpool isn't currently supported - m_ui->formatRadioButton->setChecked( m_partition->fileSystem().type() == FileSystem::Type::Zfs ); - m_ui->formatRadioButton->setEnabled( !( m_partition->fileSystem().type() == FileSystem::Type::Zfs ) ); - m_ui->keepRadioButton->setChecked( !( m_partition->fileSystem().type() == FileSystem::Type::Zfs ) ); - m_ui->keepRadioButton->setEnabled( !( m_partition->fileSystem().type() == FileSystem::Type::Zfs ) ); + const bool partitionIsZFS = m_partition->fileSystem().type() == FileSystem::Type::Zfs; + if ( partitionIsZFS ) + { + m_ui->formatRadioButton->setChecked( true ); + } + else + { + m_ui->formatRadioButton->setChecked( false ); + } + m_ui->formatRadioButton->setEnabled( !partitionIsZFS ); + m_ui->keepRadioButton->setChecked( !partitionIsZFS ); + m_ui->keepRadioButton->setEnabled( !partitionIsZFS ); setFlagList( *( m_ui->m_listFlags ), m_partition->availableFlags(), PartitionInfo::flags( m_partition ) ); } From ecd8839ac922ba965c99c4cb263ea3d12ebad36e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 17 Feb 2024 14:26:39 +0100 Subject: [PATCH 02/10] [partition] Set up label checkbox later If the update-fs-label checkbox and drop-down depend on the state of the format button, then set that up only once we're done deciding on the format button. --- src/modules/partition/gui/EditExistingPartitionDialog.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index 9636799a9..4c02e2d0b 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -126,9 +126,6 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, m_ui->fileSystemComboBox->setCurrentText( FileSystem::nameForType( defaultFSType ) ); } - m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() ); - m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() ); - // Force a format if the existing device is a zfs device since reusing a zpool isn't currently supported const bool partitionIsZFS = m_partition->fileSystem().type() == FileSystem::Type::Zfs; if ( partitionIsZFS ) @@ -143,6 +140,9 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, m_ui->keepRadioButton->setChecked( !partitionIsZFS ); m_ui->keepRadioButton->setEnabled( !partitionIsZFS ); + m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() ); + m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() ); + setFlagList( *( m_ui->m_listFlags ), m_partition->availableFlags(), PartitionInfo::flags( m_partition ) ); } From f23b4ff2671712e5d7746a7bf983885364a13d85 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 17 Feb 2024 15:40:42 +0100 Subject: [PATCH 03/10] [partition] Preserve the will-it-be-formatted flag of the partition --- .../partition/gui/EditExistingPartitionDialog.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index 4c02e2d0b..a76bee289 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -128,14 +128,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, // Force a format if the existing device is a zfs device since reusing a zpool isn't currently supported const bool partitionIsZFS = m_partition->fileSystem().type() == FileSystem::Type::Zfs; - if ( partitionIsZFS ) - { - m_ui->formatRadioButton->setChecked( true ); - } - else - { - m_ui->formatRadioButton->setChecked( false ); - } + m_ui->formatRadioButton->setChecked( partitionIsZFS || PartitionInfo::format( m_partition ) ); m_ui->formatRadioButton->setEnabled( !partitionIsZFS ); m_ui->keepRadioButton->setChecked( !partitionIsZFS ); m_ui->keepRadioButton->setEnabled( !partitionIsZFS ); @@ -205,6 +198,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core ) { core->setPartitionFlags( m_device, m_partition, resultFlags ); } + PartitionInfo::setFormat( m_partition, false ); } } else @@ -221,6 +215,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core ) core->setPartitionFlags( m_device, m_partition, resultFlags ); } core->setFilesystemLabel( m_device, m_partition, fsLabel ); + PartitionInfo::setFormat( m_partition, true ); } else // otherwise, we delete and recreate the partition with new fs type { @@ -254,6 +249,7 @@ EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core ) { core->setFilesystemLabel( m_device, m_partition, fsLabel ); } + PartitionInfo::setFormat( m_partition, false ); core->refreshPartition( m_device, m_partition ); } From d5f32be5e3ce162b19bb2871b87ae3b178478167 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 17 Feb 2024 17:03:27 +0100 Subject: [PATCH 04/10] [partition] Repair enable/disable status of FS label The entry field was always enabled, but the label of the FS-label entry field depended on the format button. --- src/modules/partition/gui/EditExistingPartitionDialog.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index a76bee289..9c8d543e7 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -69,9 +69,10 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, this, &EditExistingPartitionDialog::checkMountPointSelection ); - // The filesystem label dialog is always enabled, because we may want to change + // The filesystem label field 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() ); + m_ui->fileSystemLabel->setEnabled(true); replacePartResizerWidget(); @@ -81,7 +82,6 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, { replacePartResizerWidget(); - m_ui->fileSystemLabel->setEnabled( doFormat ); m_ui->fileSystemComboBox->setEnabled( doFormat ); if ( !doFormat ) @@ -133,7 +133,6 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, m_ui->keepRadioButton->setChecked( !partitionIsZFS ); m_ui->keepRadioButton->setEnabled( !partitionIsZFS ); - m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() ); m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() ); setFlagList( *( m_ui->m_listFlags ), m_partition->availableFlags(), PartitionInfo::flags( m_partition ) ); From fc2bb1ede0ecc7e8af703c14429042730a7b74a8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 17 Feb 2024 17:33:37 +0100 Subject: [PATCH 05/10] [partition] Add a helper for intended FS labels The KPMCore partition label returns what **is**, not what is intended. While here, fix some typo's in comments. --- src/modules/partition/README.md | 8 +++---- src/modules/partition/core/PartitionInfo.cpp | 22 ++++++++++++++++++++ src/modules/partition/core/PartitionInfo.h | 8 ++++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/modules/partition/README.md b/src/modules/partition/README.md index cbebd589e..d9d0d87d9 100644 --- a/src/modules/partition/README.md +++ b/src/modules/partition/README.md @@ -1,4 +1,4 @@ -# Architecture +#Architecture