Check mountpoints when editing a partition too.
This commit is contained in:
parent
8c1199df2d
commit
349470ae71
@ -43,13 +43,15 @@
|
||||
// Qt
|
||||
#include <QComboBox>
|
||||
#include <QDir>
|
||||
#include <QPushButton>
|
||||
|
||||
EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partition* partition, QWidget* parentWidget )
|
||||
EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partition* partition, const QStringList& usedMountPoints, QWidget* parentWidget )
|
||||
: QDialog( parentWidget )
|
||||
, m_ui( new Ui_EditExistingPartitionDialog )
|
||||
, m_device( device )
|
||||
, m_partition( partition )
|
||||
, m_partitionSizeController( new PartitionSizeController( this ) )
|
||||
, m_usedMountPoints( usedMountPoints )
|
||||
{
|
||||
m_ui->setupUi( this );
|
||||
|
||||
@ -60,11 +62,14 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
|
||||
mountPoints.sort();
|
||||
m_ui->mountPointComboBox->addItems( mountPoints );
|
||||
|
||||
m_usedMountPoints.removeOne( PartitionInfo::mountPoint( partition ) );
|
||||
|
||||
QColor color = ColorUtils::colorForPartition( m_partition );
|
||||
m_partitionSizeController->init( m_device, m_partition, color );
|
||||
m_partitionSizeController->setSpinBox( m_ui->sizeSpinBox );
|
||||
|
||||
m_ui->mountPointComboBox->setCurrentText( PartitionInfo::mountPoint( partition ) );
|
||||
connect( m_ui->mountPointComboBox, &QComboBox::currentTextChanged, this, &EditExistingPartitionDialog::checkMountPointSelection );
|
||||
|
||||
replacePartResizerWidget();
|
||||
|
||||
@ -291,3 +296,17 @@ EditExistingPartitionDialog::updateMountPointPicker()
|
||||
if ( !canMount )
|
||||
m_ui->mountPointComboBox->setCurrentText( QString() );
|
||||
}
|
||||
|
||||
void
|
||||
EditExistingPartitionDialog::checkMountPointSelection()
|
||||
{
|
||||
const QString& selection = m_ui->mountPointComboBox->currentText();
|
||||
|
||||
if (m_usedMountPoints.contains(selection)) {
|
||||
m_ui->labelMountPoint->setText("Mountpoint already in use. Please select another one.");
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
} else {
|
||||
m_ui->labelMountPoint->setText( QString() );
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -40,16 +40,20 @@ class EditExistingPartitionDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
EditExistingPartitionDialog( Device* device, Partition* partition, QWidget* parentWidget = nullptr );
|
||||
EditExistingPartitionDialog( Device* device, Partition* partition, const QStringList& usedMountPoints, QWidget* parentWidget = nullptr );
|
||||
~EditExistingPartitionDialog();
|
||||
|
||||
void applyChanges( PartitionCoreModule* module );
|
||||
|
||||
private slots:
|
||||
void checkMountPointSelection();
|
||||
|
||||
private:
|
||||
QScopedPointer< Ui_EditExistingPartitionDialog > m_ui;
|
||||
Device* m_device;
|
||||
Partition* m_partition;
|
||||
PartitionSizeController* m_partitionSizeController;
|
||||
QStringList m_usedMountPoints;
|
||||
|
||||
PartitionTable::Flags newFlags() const;
|
||||
void setupFlagsList();
|
||||
|
@ -139,14 +139,14 @@
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="fileSystemComboBox"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Flags:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QListWidget" name="m_listFlags">
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
@ -159,6 +159,18 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="labelMountPoint">
|
||||
<property name="font">
|
||||
<font>
|
||||
<italic>true</italic>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -280,7 +280,7 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition )
|
||||
void
|
||||
PartitionPage::editExistingPartition( Device* device, Partition* partition )
|
||||
{
|
||||
QPointer<EditExistingPartitionDialog> dlg = new EditExistingPartitionDialog( device, partition, this );
|
||||
QPointer<EditExistingPartitionDialog> dlg = new EditExistingPartitionDialog( device, partition, getCurrentUsedMountpoints(), this );
|
||||
if ( dlg->exec() == QDialog::Accepted )
|
||||
dlg->applyChanges( m_core );
|
||||
delete dlg;
|
||||
|
Loading…
Reference in New Issue
Block a user