From bd57f1f2f14f1e2da76c6a67836b8ede071b0fb8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 16 May 2018 09:14:50 -0400 Subject: [PATCH] [partition] Fix re-editing a newly created partition - If there is a partition already (newly) created, then pass that to the dialog so that it can use the setings previously applied (e.g. mount point and flags). - This avoids the case where you create or format a partition, then click on it again to edit it and the previous settings are lost. --- src/modules/partition/gui/CreatePartitionDialog.cpp | 6 +++--- src/modules/partition/gui/CreatePartitionDialog.h | 8 +++++++- src/modules/partition/gui/PartitionPage.cpp | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index 7c1f98c0b..439583be9 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -57,7 +57,7 @@ static QSet< FileSystem::Type > s_unmountableFS( FileSystem::Lvm2_PV } ); -CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* parentPartition, const QStringList& usedMountPoints, QWidget* parentWidget ) +CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* parentPartition, Partition* partition, const QStringList& usedMountPoints, QWidget* parentWidget ) : QDialog( parentWidget ) , m_ui( new Ui_CreatePartitionDialog ) , m_partitionSizeController( new PartitionSizeController( this ) ) @@ -82,7 +82,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par m_ui->lvNameLineEdit->setValidator(validator); } - standardMountPoints( *(m_ui->mountPointComboBox) ); + standardMountPoints( *(m_ui->mountPointComboBox), partition ? PartitionInfo::mountPoint( partition ) : QString() ); if ( device->partitionTable()->type() == PartitionTable::msdos || device->partitionTable()->type() == PartitionTable::msdos_sectorbased ) @@ -121,7 +121,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par m_ui->fsComboBox->setCurrentIndex( defaultFsIndex ); updateMountPointUi(); - setFlagList( *(m_ui->m_listFlags), static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int(0) ), PartitionTable::Flags() ); + setFlagList( *(m_ui->m_listFlags), static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int(0) ), partition ? PartitionInfo::flags( partition ) : PartitionTable::Flags() ); // Checks the initial selection. checkMountPointSelection(); diff --git a/src/modules/partition/gui/CreatePartitionDialog.h b/src/modules/partition/gui/CreatePartitionDialog.h index 174d91c88..769edb5de 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.h +++ b/src/modules/partition/gui/CreatePartitionDialog.h @@ -42,7 +42,13 @@ class CreatePartitionDialog : public QDialog { Q_OBJECT public: - CreatePartitionDialog( Device* device, PartitionNode* parentPartition, const QStringList& usedMountPoints, QWidget* parentWidget = nullptr ); + /** + * @brief Dialog for editing a new partition. + * + * For the (unlikely) case that a newly created partition is being re-edited, + * pass a pointer to that @p partition, otherwise pass nullptr. + */ + CreatePartitionDialog( Device* device, PartitionNode* parentPartition, Partition* partition, const QStringList& usedMountPoints, QWidget* parentWidget = nullptr ); ~CreatePartitionDialog(); /** diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index c521604fb..62f82a108 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -190,6 +190,7 @@ PartitionPage::onCreateClicked() QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( model->device(), partition->parent(), + nullptr, getCurrentUsedMountpoints(), this ); dlg->initFromFreeSpace( partition ); @@ -285,6 +286,7 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition ) QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( device, partition->parent(), + partition, mountPoints, this ); dlg->initFromPartitionToCreate( partition );