diff --git a/src/modules/partition/CreatePartitionDialog.cpp b/src/modules/partition/CreatePartitionDialog.cpp index 73af27e00..8bd51b972 100644 --- a/src/modules/partition/CreatePartitionDialog.cpp +++ b/src/modules/partition/CreatePartitionDialog.cpp @@ -36,6 +36,26 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, Partition* freePar m_ui->setupUi( this ); FileSystemFactory::init(); + + bool hidePartitionType = false; + if ( freePartition->roles().has( PartitionRole::Logical ) ) + { + m_role = PartitionRole( PartitionRole::Logical ); + hidePartitionType = true; + } + else if ( m_device->partitionTable()->hasExtended() ) + { + m_role = PartitionRole( PartitionRole::Primary ); + hidePartitionType = true; + } + + if ( hidePartitionType ) + { + m_ui->partitionTypeLabel->hide(); + m_ui->primaryRadioButton->hide(); + m_ui->extendedRadioButton->hide(); + } + QStringList fsNames; for ( auto fs : FileSystemFactory::map() ) { @@ -58,18 +78,29 @@ CreatePartitionDialog::~CreatePartitionDialog() CreatePartitionJob* CreatePartitionDialog::createJob() { + if ( m_role.roles() == PartitionRole::None ) + { + m_role = PartitionRole( + m_ui->extendedRadioButton->isChecked() + ? PartitionRole::Extended + : PartitionRole::Primary + ); + } + qint64 first = m_freePartition->firstSector(); // FIXME: Check rounding errors here qint64 last = first + qint64( m_ui->sizeSpinBox->value() ) * 1024 * 1024 / m_device->logicalSectorSize(); - FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() ); + FileSystem::Type type = m_role.has( PartitionRole::Extended ) + ? FileSystem::Extended + : FileSystem::typeForName( m_ui->fsComboBox->currentText() ); FileSystem* fs = FileSystemFactory::create( type, first, last ); PartitionNode* parent = m_freePartition->parent(); Partition* partition = new Partition( parent, *m_device, - PartitionRole( PartitionRole::Primary ), // FIXME: Support extended partitions + m_role, fs, first, last, QString() /* path */ ); diff --git a/src/modules/partition/CreatePartitionDialog.h b/src/modules/partition/CreatePartitionDialog.h index f51167d6f..b809cb15a 100644 --- a/src/modules/partition/CreatePartitionDialog.h +++ b/src/modules/partition/CreatePartitionDialog.h @@ -22,6 +22,9 @@ #include #include +// CalaPM +#include + class CreatePartitionJob; class Device; class Partition; @@ -39,6 +42,7 @@ private: QScopedPointer< Ui_CreatePartitionDialog > m_ui; Device* m_device; Partition* m_freePartition; + PartitionRole m_role = PartitionRole( PartitionRole::None ); }; #endif /* CREATEPARTITIONDIALOG_H */ diff --git a/src/modules/partition/CreatePartitionDialog.ui b/src/modules/partition/CreatePartitionDialog.ui index cd03e0743..1fb210ea3 100644 --- a/src/modules/partition/CreatePartitionDialog.ui +++ b/src/modules/partition/CreatePartitionDialog.ui @@ -6,8 +6,8 @@ 0 0 - 186 - 170 + 263 + 179 @@ -16,24 +16,30 @@ - + - File System: + F&ile System: + + + fsComboBox - + - + - Size: + Si&ze: + + + sizeSpinBox - + Qt::Vertical @@ -46,13 +52,40 @@ - + MB + + + + &Primary + + + true + + + + + + + E&xtended + + + + + + + Partition &Type: + + + primaryRadioButton + + + @@ -68,9 +101,10 @@ + primaryRadioButton + extendedRadioButton fsComboBox sizeSpinBox - buttonBox @@ -86,7 +120,7 @@ 157 - 274 + 178 @@ -101,8 +135,24 @@ 165 - 286 - 274 + 262 + 178 + + + + + extendedRadioButton + toggled(bool) + fsComboBox + setDisabled(bool) + + + 131 + 36 + + + 134 + 66