diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 156ff86f5..cfc5e567e 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -40,6 +40,7 @@ if ( KPMcore_FOUND ) gui/EncryptWidget.cpp gui/PartitionPage.cpp gui/PartitionBarsView.cpp + gui/PartitionDialogHelpers.cpp gui/PartitionLabelsView.cpp gui/PartitionSizeController.cpp gui/PartitionSplitterWidget.cpp diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 775fcee66..2c2944997 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -22,6 +22,7 @@ #include "core/DeviceModel.h" #include "core/KPMHelpers.h" +#include "core/PartitionInfo.h" #include "core/PartitionIterator.h" #include @@ -343,8 +344,10 @@ isEfiSystem() bool isEfiBootable( const Partition* candidate ) { + auto flags = PartitionInfo::flags( candidate ); + /* If bit 17 is set, old-style Esp flag, it's OK */ - if ( candidate->activeFlags().testFlag( PartitionTable::FlagEsp ) ) + if ( flags.testFlag( PartitionTable::FlagEsp ) ) return true; @@ -359,7 +362,7 @@ isEfiBootable( const Partition* candidate ) const PartitionTable* table = dynamic_cast( root ); return table && ( table->type() == PartitionTable::TableType::gpt ) && - candidate->activeFlags().testFlag( PartitionTable::FlagBoot ); + flags.testFlag( PartitionTable::FlagBoot ); } } // nmamespace PartUtils diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 43ba33d7b..f636d15bb 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -258,6 +258,7 @@ PartitionCoreModule::createPartition( Device* device, { SetPartFlagsJob* fJob = new SetPartFlagsJob( device, partition, flags ); deviceInfo->jobs << Calamares::job_ptr( fJob ); + PartitionInfo::setFlags( partition, flags ); } refresh(); @@ -381,8 +382,8 @@ PartitionCoreModule::setPartitionFlags( Device* device, PartitionModel::ResetHelper( partitionModelForDevice( device ) ); SetPartFlagsJob* job = new SetPartFlagsJob( device, partition, flags ); - deviceInfo->jobs << Calamares::job_ptr( job ); + PartitionInfo::setFlags( partition, flags ); refresh(); } diff --git a/src/modules/partition/core/PartitionInfo.cpp b/src/modules/partition/core/PartitionInfo.cpp index 72cca8976..dcd49d2e9 100644 --- a/src/modules/partition/core/PartitionInfo.cpp +++ b/src/modules/partition/core/PartitionInfo.cpp @@ -27,8 +27,9 @@ namespace PartitionInfo { -static const char* MOUNT_POINT_PROPERTY = "_calamares_mountPoint"; -static const char* FORMAT_PROPERTY = "_calamares_format"; +static const char MOUNT_POINT_PROPERTY[] = "_calamares_mountPoint"; +static const char FORMAT_PROPERTY[] = "_calamares_format"; +static const char FLAGS_PROPERTY[] = "_calamares_flags"; QString mountPoint( Partition* partition ) @@ -54,18 +55,33 @@ setFormat( Partition* partition, bool value ) partition->setProperty( FORMAT_PROPERTY, value ); } +PartitionTable::Flags flags(const Partition* partition) +{ + auto v = partition->property( FLAGS_PROPERTY ); + if (v.type() == QVariant::Int ) + return static_cast( v.toInt() ); + return partition->activeFlags(); +} + +void setFlags(Partition* partition, PartitionTable::Flags f) +{ + partition->setProperty( FLAGS_PROPERTY, PartitionTable::Flags::Int( f ) ); +} + void reset( Partition* partition ) { partition->setProperty( MOUNT_POINT_PROPERTY, QVariant() ); partition->setProperty( FORMAT_PROPERTY, QVariant() ); + partition->setProperty( FLAGS_PROPERTY, QVariant() ); } bool isDirty( Partition* partition ) { return !mountPoint( partition ).isEmpty() - || format( partition ); + || format( partition ) + || flags( partition ) != partition->activeFlags(); } } // namespace diff --git a/src/modules/partition/core/PartitionInfo.h b/src/modules/partition/core/PartitionInfo.h index 2474a3a2d..9003bf997 100644 --- a/src/modules/partition/core/PartitionInfo.h +++ b/src/modules/partition/core/PartitionInfo.h @@ -21,6 +21,8 @@ #include #include +#include + class Partition; /** @@ -45,6 +47,9 @@ void setMountPoint( Partition* partition, const QString& value ); bool format( Partition* partition ); void setFormat( Partition* partition, bool value ); +PartitionTable::Flags flags( const Partition* partition ); +void setFlags( Partition* partition, PartitionTable::Flags f ); + void reset( Partition* partition ); /** diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index 5952a61a1..439583be9 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -23,6 +23,7 @@ #include "core/PartitionInfo.h" #include "core/PartUtils.h" #include "core/KPMHelpers.h" +#include "gui/PartitionDialogHelpers.h" #include "gui/PartitionSizeController.h" #include "ui_CreatePartitionDialog.h" @@ -56,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 ) ) @@ -81,12 +82,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par m_ui->lvNameLineEdit->setValidator(validator); } - QStringList mountPoints = { "/", "/boot", "/home", "/opt", "/usr", "/var" }; - if ( PartUtils::isEfiSystem() ) - mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString(); - mountPoints.removeDuplicates(); - mountPoints.sort(); - m_ui->mountPointComboBox->addItems( mountPoints ); + standardMountPoints( *(m_ui->mountPointComboBox), partition ? PartitionInfo::mountPoint( partition ) : QString() ); if ( device->partitionTable()->type() == PartitionTable::msdos || device->partitionTable()->type() == PartitionTable::msdos_sectorbased ) @@ -125,7 +121,8 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par m_ui->fsComboBox->setCurrentIndex( defaultFsIndex ); updateMountPointUi(); - setupFlagsList(); + setFlagList( *(m_ui->m_listFlags), static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int(0) ), partition ? PartitionInfo::flags( partition ) : PartitionTable::Flags() ); + // Checks the initial selection. checkMountPointSelection(); } @@ -137,35 +134,9 @@ CreatePartitionDialog::~CreatePartitionDialog() PartitionTable::Flags CreatePartitionDialog::newFlags() const { - PartitionTable::Flags flags; - - for ( int i = 0; i < m_ui->m_listFlags->count(); i++ ) - if ( m_ui->m_listFlags->item( i )->checkState() == Qt::Checked ) - flags |= static_cast< PartitionTable::Flag >( - m_ui->m_listFlags->item( i )->data( Qt::UserRole ).toInt() ); - - return flags; + return flagsFromList( *(m_ui->m_listFlags) ); } - -void -CreatePartitionDialog::setupFlagsList() -{ - int f = 1; - QString s; - while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() ) - { - QListWidgetItem* item = new QListWidgetItem( s ); - m_ui->m_listFlags->addItem( item ); - item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled ); - item->setData( Qt::UserRole, f ); - item->setCheckState( Qt::Unchecked ); - - f <<= 1; - } -} - - void CreatePartitionDialog::initMbrPartitionTypeUi() { @@ -246,7 +217,7 @@ CreatePartitionDialog::createPartition() partition->setPartitionPath(m_device->deviceNode() + QStringLiteral("/") + m_ui->lvNameLineEdit->text().trimmed()); } - PartitionInfo::setMountPoint( partition, m_ui->mountPointComboBox->currentText() ); + PartitionInfo::setMountPoint( partition, selectedMountPoint( m_ui->mountPointComboBox ) ); PartitionInfo::setFormat( partition, true ); return partition; @@ -283,9 +254,7 @@ CreatePartitionDialog::updateMountPointUi() void CreatePartitionDialog::checkMountPointSelection() { - const QString& selection = m_ui->mountPointComboBox->currentText(); - - if ( m_usedMountPoints.contains( selection ) ) + if ( m_usedMountPoints.contains( selectedMountPoint( m_ui->mountPointComboBox ) ) ) { m_ui->labelMountPoint->setText( tr( "Mountpoint already in use. Please select another one." ) ); m_ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); @@ -334,7 +303,7 @@ CreatePartitionDialog::initFromPartitionToCreate( Partition* partition ) m_ui->fsComboBox->setCurrentText( FileSystem::nameForType( fsType ) ); // Mount point - m_ui->mountPointComboBox->setCurrentText( PartitionInfo::mountPoint( partition ) ); + setSelectedMountPoint( m_ui->mountPointComboBox, PartitionInfo::mountPoint( partition ) ); updateMountPointUi(); } diff --git a/src/modules/partition/gui/CreatePartitionDialog.h b/src/modules/partition/gui/CreatePartitionDialog.h index 6e8e9b6fd..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(); /** @@ -64,7 +70,6 @@ private Q_SLOTS: void checkMountPointSelection(); private: - void setupFlagsList(); QScopedPointer< Ui_CreatePartitionDialog > m_ui; PartitionSizeController* m_partitionSizeController; Device* m_device; diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index 2212c104c..c0fff50a8 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -28,6 +28,7 @@ #include #include "core/PartUtils.h" #include +#include "gui/PartitionDialogHelpers.h" #include #include @@ -55,19 +56,12 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit , m_usedMountPoints( usedMountPoints ) { m_ui->setupUi( this ); - - QStringList mountPoints = { "/", "/boot", "/home", "/opt", "/usr", "/var" }; - if ( PartUtils::isEfiSystem() ) - mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString(); - mountPoints.removeDuplicates(); - mountPoints.sort(); - m_ui->mountPointComboBox->addItems( mountPoints ); + standardMountPoints( *(m_ui->mountPointComboBox), 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 ); @@ -112,7 +106,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() ); m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() ); - setupFlagsList(); + setFlagList( *(m_ui->m_listFlags), m_partition->availableFlags(), PartitionInfo::flags( m_partition ) ); } @@ -123,44 +117,13 @@ EditExistingPartitionDialog::~EditExistingPartitionDialog() PartitionTable::Flags EditExistingPartitionDialog::newFlags() const { - PartitionTable::Flags flags; - - for ( int i = 0; i < m_ui->m_listFlags->count(); i++ ) - if ( m_ui->m_listFlags->item( i )->checkState() == Qt::Checked ) - flags |= static_cast< PartitionTable::Flag >( - m_ui->m_listFlags->item( i )->data( Qt::UserRole ).toInt() ); - - return flags; + return flagsFromList( *(m_ui->m_listFlags) ); } - -void -EditExistingPartitionDialog::setupFlagsList() -{ - int f = 1; - QString s; - while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() ) - { - if ( m_partition->availableFlags() & f ) - { - QListWidgetItem* item = new QListWidgetItem( s ); - m_ui->m_listFlags->addItem( item ); - item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled ); - item->setData( Qt::UserRole, f ); - item->setCheckState( ( m_partition->activeFlags() & f ) ? - Qt::Checked : - Qt::Unchecked ); - } - - f <<= 1; - } -} - - void EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core ) { - PartitionInfo::setMountPoint( m_partition, m_ui->mountPointComboBox->currentText() ); + PartitionInfo::setMountPoint( m_partition, selectedMountPoint(m_ui->mountPointComboBox) ); qint64 newFirstSector = m_partitionSizeController->firstSector(); qint64 newLastSector = m_partitionSizeController->lastSector(); @@ -294,15 +257,13 @@ EditExistingPartitionDialog::updateMountPointPicker() m_ui->mountPointLabel->setEnabled( canMount ); m_ui->mountPointComboBox->setEnabled( canMount ); if ( !canMount ) - m_ui->mountPointComboBox->setCurrentText( QString() ); + setSelectedMountPoint( m_ui->mountPointComboBox, QString() ); } void EditExistingPartitionDialog::checkMountPointSelection() { - const QString& selection = m_ui->mountPointComboBox->currentText(); - - if ( m_usedMountPoints.contains( selection ) ) + if ( m_usedMountPoints.contains( selectedMountPoint( m_ui->mountPointComboBox ) ) ) { m_ui->labelMountPoint->setText( tr( "Mountpoint already in use. Please select another one." ) ); m_ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.h b/src/modules/partition/gui/EditExistingPartitionDialog.h index b933e90ce..106ba6639 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.h +++ b/src/modules/partition/gui/EditExistingPartitionDialog.h @@ -56,7 +56,6 @@ private: QStringList m_usedMountPoints; PartitionTable::Flags newFlags() const; - void setupFlagsList(); void replacePartResizerWidget(); void updateMountPointPicker(); }; diff --git a/src/modules/partition/gui/PartitionDialogHelpers.cpp b/src/modules/partition/gui/PartitionDialogHelpers.cpp new file mode 100644 index 000000000..3dcf41f58 --- /dev/null +++ b/src/modules/partition/gui/PartitionDialogHelpers.cpp @@ -0,0 +1,118 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * Copyright 2016, Teo Mrnjavac + * Copyright 2018, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "PartitionDialogHelpers.h" + +#include "core/PartUtils.h" + +#include "GlobalStorage.h" +#include "JobQueue.h" +#include "utils/Logger.h" + +#include +#include + +QStringList +standardMountPoints() +{ + QStringList mountPoints{ "/", "/boot", "/home", "/opt", "/srv", "/usr", "/var" }; + if ( PartUtils::isEfiSystem() ) + mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString(); + mountPoints.removeDuplicates(); + mountPoints.sort(); + return mountPoints; +} + +void +standardMountPoints(QComboBox& combo) +{ + combo.clear(); + combo.addItem( combo.tr( "(no mount point)" ) ); + combo.addItems( standardMountPoints() ); +} + +void +standardMountPoints(QComboBox& combo, const QString& selected) +{ + standardMountPoints( combo ); + setSelectedMountPoint( combo, selected ); +} + +QString +selectedMountPoint(QComboBox& combo) +{ + if ( combo.currentIndex() == 0 ) + return QString(); + return combo.currentText(); +} + +void +setSelectedMountPoint(QComboBox& combo, const QString& selected) +{ + if ( selected.isEmpty() ) + combo.setCurrentIndex( 0 ); // (no mount point) + else + { + for ( int i = 0; i < combo.count(); ++i ) + if ( selected == combo.itemText( i ) ) + { + combo.setCurrentIndex( i ); + return; + } + combo.addItem( selected ); + combo.setCurrentIndex( combo.count() - 1); + } +} + + +PartitionTable::Flags +flagsFromList( const QListWidget& list ) +{ + PartitionTable::Flags flags; + + for ( int i = 0; i < list.count(); i++ ) + if ( list.item( i )->checkState() == Qt::Checked ) + flags |= static_cast< PartitionTable::Flag >( + list.item( i )->data( Qt::UserRole ).toInt() ); + + return flags; +} + +void +setFlagList( QListWidget& list, PartitionTable::Flags available, PartitionTable::Flags checked ) +{ + int f = 1; + QString s; + while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() ) + { + if ( available & f ) + { + QListWidgetItem* item = new QListWidgetItem( s ); + list.addItem( item ); + item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled ); + item->setData( Qt::UserRole, f ); + item->setCheckState( ( checked & f ) ? + Qt::Checked : + Qt::Unchecked ); + } + + f <<= 1; + } +} diff --git a/src/modules/partition/gui/PartitionDialogHelpers.h b/src/modules/partition/gui/PartitionDialogHelpers.h new file mode 100644 index 000000000..594142993 --- /dev/null +++ b/src/modules/partition/gui/PartitionDialogHelpers.h @@ -0,0 +1,68 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * Copyright 2016, Teo Mrnjavac + * Copyright 2018, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef PARTITION_GUI_PARTITIONDIALOGHELPERS +#define PARTITION_GUI_PARTITIONDIALOGHELPERS + +#include + +#include + +class QComboBox; +class QListWidget; + +/** + * Returns a list of standard mount points (e.g. /, /usr, ...). + * This also includes the EFI mount point if that is necessary + * on the target system. + */ +QStringList standardMountPoints(); + +/** + * Clears the combobox and fills it with "(no mount point)" + * and the elements of standardMountPoints(), above. + */ +void standardMountPoints( QComboBox& ); + +/** + * As above, but also sets the displayed mount point to @p selected, + * unless it is empty, in which case "(no mount point)" is chosen. + */ +void standardMountPoints( QComboBox&, const QString& selected ); + +/** + * Get the mount point selected in the combo box (which should + * have been set up with standardMountPoints(), above); this + * will map the topmost item (i.e. "(no mount point)") back + * to blank, to allow easy detection of no-mount-selected. + */ +QString selectedMountPoint( QComboBox& combo ); +static inline QString selectedMountPoint(QComboBox* combo) { return selectedMountPoint(*combo); } + +void setSelectedMountPoint( QComboBox& combo, const QString& selected ); +static inline void setSelectedMountPoint(QComboBox* combo, const QString& selected) { setSelectedMountPoint( *combo, selected); } + +/** + * Get the flags that have been checked in the list widget. + */ +PartitionTable::Flags flagsFromList( const QListWidget& list ); +void setFlagList( QListWidget& list, PartitionTable::Flags available, PartitionTable::Flags checked ); + +#endif diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index c521604fb..426667a08 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -34,6 +34,7 @@ #include "ui_PartitionPage.h" #include "ui_CreatePartitionTableDialog.h" +#include "utils/Logger.h" #include "utils/Retranslator.h" #include "Branding.h" #include "JobQueue.h" @@ -178,6 +179,29 @@ PartitionPage::onNewPartitionTableClicked() updateBootLoaderIndex(); } +bool +PartitionPage::checkCanCreate( Device* device ) +{ + auto table = device->partitionTable(); + + if ( table->type() == PartitionTable::msdos ||table->type() == PartitionTable::msdos_sectorbased ) + { + cDebug() << "Checking MSDOS partition" << table->numPrimaries() << "primaries, max" << table->maxPrimaries(); + + if ( ( table->numPrimaries() >= table->maxPrimaries() ) && !table->hasExtended() ) + { + QMessageBox::warning( this, tr( "Can not create new partition" ), + tr( "The partition table on %1 already has %2 primary partitions, and no more can be added. " + "Please remove one primary partition and add an extended partition, instead." ).arg( device->name() ).arg( table->numPrimaries() ) + ); + return false; + } + return true; + } + else + return true; // GPT is fine +} + void PartitionPage::onCreateClicked() { @@ -188,8 +212,12 @@ PartitionPage::onCreateClicked() Partition* partition = model->partitionForIndex( index ); Q_ASSERT( partition ); + if ( !checkCanCreate( model->device() ) ) + return; + QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( model->device(), partition->parent(), + nullptr, getCurrentUsedMountpoints(), this ); dlg->initFromFreeSpace( partition ); @@ -285,6 +313,7 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition ) QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( device, partition->parent(), + partition, mountPoints, this ); dlg->initFromPartitionToCreate( partition ); diff --git a/src/modules/partition/gui/PartitionPage.h b/src/modules/partition/gui/PartitionPage.h index 24cf65675..d7c823a61 100644 --- a/src/modules/partition/gui/PartitionPage.h +++ b/src/modules/partition/gui/PartitionPage.h @@ -62,6 +62,14 @@ private: void updateFromCurrentDevice(); void updateBootLoaderIndex(); + /** + * @brief Check if a new partition can be created (as primary) on the device. + * + * Returns true if a new partition can be created on the device. Provides + * a warning popup and returns false if it cannot. + */ + bool checkCanCreate( Device* ); + QStringList getCurrentUsedMountpoints(); QMutex m_revertMutex;