diff --git a/src/modules/partition/CreatePartitionDialog.cpp b/src/modules/partition/CreatePartitionDialog.cpp index b49aecc18..8c9cfb0ce 100644 --- a/src/modules/partition/CreatePartitionDialog.cpp +++ b/src/modules/partition/CreatePartitionDialog.cpp @@ -29,6 +29,7 @@ // Qt #include +#include CreatePartitionDialog::CreatePartitionDialog( Device* device, Partition* freePartition, QWidget* parent ) : QDialog( parent ) @@ -40,25 +41,31 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, Partition* freePar FileSystemFactory::init(); - bool hidePartitionType = false; + // Partition types + QString fixedPartitionType; if ( freePartition->roles().has( PartitionRole::Logical ) ) { m_role = PartitionRole( PartitionRole::Logical ); - hidePartitionType = true; + fixedPartitionType = tr( "Logical" ); } else if ( m_device->partitionTable()->hasExtended() ) { m_role = PartitionRole( PartitionRole::Primary ); - hidePartitionType = true; + fixedPartitionType = tr( "Primary" ); } - if ( hidePartitionType ) + if ( fixedPartitionType.isEmpty() ) { - m_ui->partitionTypeLabel->hide(); + m_ui->fixedPartitionLabel->hide(); + } + else + { + m_ui->fixedPartitionLabel->setText( fixedPartitionType ); m_ui->primaryRadioButton->hide(); m_ui->extendedRadioButton->hide(); } + // File system QStringList fsNames; for ( auto fs : FileSystemFactory::map() ) { @@ -69,10 +76,15 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, Partition* freePar } m_ui->fsComboBox->addItems( fsNames ); + // Size qint64 maxSize = ( freePartition->lastSector() - freePartition->firstSector() + 1 ) * device->logicalSectorSize(); m_ui->sizeSpinBox->setMaximum( maxSize / 1024 / 1024 ); m_ui->sizeSpinBox->setValue( m_ui->sizeSpinBox->maximum() ); + + // Connections + connect( m_ui->fsComboBox, SIGNAL( activated( int ) ), SLOT( updateMountPointUi() ) ); + connect( m_ui->extendedRadioButton, SIGNAL( toggled( bool ) ), SLOT( updateMountPointUi() ) ); } CreatePartitionDialog::~CreatePartitionDialog() @@ -118,3 +130,18 @@ CreatePartitionDialog::createPartitionInfo() info->format = true; return info; } + +void +CreatePartitionDialog::updateMountPointUi() +{ + static QSet< FileSystem::Type > unmountableFS( { FileSystem::Unformatted, FileSystem::LinuxSwap } ); + + bool enabled = m_ui->primaryRadioButton->isChecked(); + if ( enabled ) + { + FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() ); + enabled = !unmountableFS.contains( type ); + } + m_ui->mountPointLabel->setEnabled( enabled ); + m_ui->mountPointComboBox->setEnabled( enabled ); +} diff --git a/src/modules/partition/CreatePartitionDialog.h b/src/modules/partition/CreatePartitionDialog.h index 131c9110a..c6c7c940c 100644 --- a/src/modules/partition/CreatePartitionDialog.h +++ b/src/modules/partition/CreatePartitionDialog.h @@ -32,12 +32,16 @@ class Ui_CreatePartitionDialog; class CreatePartitionDialog : public QDialog { + Q_OBJECT public: CreatePartitionDialog( Device* device, Partition* freePartition, QWidget* parent = nullptr ); ~CreatePartitionDialog(); PartitionInfo* createPartitionInfo(); +private Q_SLOTS: + void updateMountPointUi(); + private: QScopedPointer< Ui_CreatePartitionDialog > m_ui; Device* m_device; diff --git a/src/modules/partition/CreatePartitionDialog.ui b/src/modules/partition/CreatePartitionDialog.ui index 1e2380e4a..ad79d4338 100644 --- a/src/modules/partition/CreatePartitionDialog.ui +++ b/src/modules/partition/CreatePartitionDialog.ui @@ -7,7 +7,7 @@ 0 0 425 - 321 + 208 @@ -16,6 +16,57 @@ + + + + Partition &Type: + + + primaryRadioButton + + + + + + + + + &Primary + + + true + + + + + + + E&xtended + + + + + + + TextLabel + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -39,19 +90,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -59,35 +97,24 @@ - - - - &Primary + + + + Qt::Vertical - - true + + QSizePolicy::Fixed - + + + 20 + 13 + + + - - - - E&xtended - - - - - - - Partition &Type: - - - primaryRadioButton - - - - - + + &Mount Point: @@ -96,7 +123,7 @@ - + true @@ -136,6 +163,32 @@ + + + + Qt::Vertical + + + + 17 + 13 + + + + + + + + Qt::Vertical + + + + 20 + 12 + + + + @@ -152,7 +205,6 @@ primaryRadioButton - extendedRadioButton fsComboBox sizeSpinBox @@ -165,8 +217,8 @@ accept() - 181 - 165 + 185 + 203 157 @@ -181,11 +233,11 @@ reject() - 181 - 165 + 185 + 203 - 262 + 243 178 @@ -206,5 +258,21 @@ + + extendedRadioButton + toggled(bool) + label_2 + setDisabled(bool) + + + 109 + 43 + + + 79 + 64 + + +