diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index 156ff86f5..dc6735f28 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -38,6 +38,7 @@ if ( KPMcore_FOUND ) gui/DeviceInfoWidget.cpp gui/EditExistingPartitionDialog.cpp gui/EncryptWidget.cpp + gui/MountPoints.cpp gui/PartitionPage.cpp gui/PartitionBarsView.cpp gui/PartitionLabelsView.cpp diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index 5952a61a1..f790f4d38 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/MountPoints.h" #include "gui/PartitionSizeController.h" #include "ui_CreatePartitionDialog.h" @@ -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) ); if ( device->partitionTable()->type() == PartitionTable::msdos || device->partitionTable()->type() == PartitionTable::msdos_sectorbased ) diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index 2212c104c..e52627fec 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/MountPoints.h" #include #include @@ -55,13 +56,7 @@ 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) ); QColor color = ColorUtils::colorForPartition( m_partition ); m_partitionSizeController->init( m_device, m_partition, color ); diff --git a/src/modules/partition/gui/MountPoints.cpp b/src/modules/partition/gui/MountPoints.cpp new file mode 100644 index 000000000..03de34207 --- /dev/null +++ b/src/modules/partition/gui/MountPoints.cpp @@ -0,0 +1,48 @@ +/* === 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 "MountPoints.h" + +#include "core/PartUtils.h" + +#include "GlobalStorage.h" +#include "JobQueue.h" + +#include + +QStringList +standardMountPoints() +{ + QStringList mountPoints{ "/", "/boot", "/home", "/opt", "/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() ); +} + diff --git a/src/modules/partition/gui/MountPoints.h b/src/modules/partition/gui/MountPoints.h new file mode 100644 index 000000000..d9edd9db4 --- /dev/null +++ b/src/modules/partition/gui/MountPoints.h @@ -0,0 +1,41 @@ +/* === 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_MOUNTPOINTS +#define PARTITION_GUI_MOUNTPOINTS + +#include + +class QComboBox; + +/** + * 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& ); + +#endif