[partition] Consistent FS name usage

- explicit use of user-visible names in EditExistingPartitionDialog
 - consistent conversion of config-values to FS names (user-visible).
   The GS value comes from the ViewStep, and should always match
   something -- it's already converted to the canonical un-translated
   so the type should be good.
This commit is contained in:
Adriaan de Groot 2020-02-13 13:24:53 +01:00
parent 57b608083e
commit 5a50a3a40c
2 changed files with 35 additions and 20 deletions

View File

@ -93,11 +93,17 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
else else
initGptPartitionTypeUi(); initGptPartitionTypeUi();
// File system // File system; the config value is translated (best-effort) to a type
FileSystem::Type defaultFsType = FileSystem::typeForName( FileSystem::Type defaultFSType;
QString untranslatedFSName = PartUtils::findFS(
Calamares::JobQueue::instance()-> Calamares::JobQueue::instance()->
globalStorage()-> globalStorage()->
value( "defaultFileSystemType" ).toString() ); value( "defaultFileSystemType" ).toString(), &defaultFSType );
if ( defaultFSType == FileSystem::Type::Unknown )
{
defaultFSType = FileSystem::Type::Ext4;
}
int defaultFsIndex = -1; int defaultFsIndex = -1;
int fsCounter = 0; int fsCounter = 0;
QStringList fsNames; QStringList fsNames;
@ -107,7 +113,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
fs->type() != FileSystem::Extended ) fs->type() != FileSystem::Extended )
{ {
fsNames << KPMHelpers::userVisibleFS( fs ); // This is put into the combobox fsNames << KPMHelpers::userVisibleFS( fs ); // This is put into the combobox
if ( fs->type() == defaultFsType ) if ( fs->type() == defaultFSType )
defaultFsIndex = fsCounter; defaultFsIndex = fsCounter;
fsCounter++; fsCounter++;
} }

View File

@ -2,7 +2,7 @@
* *
* Copyright 2014, Aurélien Gâteau <agateau@kde.org> * Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2016, Teo Mrnjavac <teo@kde.org> * Copyright 2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org> * Copyright 2018, 2020, Adriaan de Groot <groot@kde.org>
* *
* Flags handling originally from KDE Partition Manager, * Flags handling originally from KDE Partition Manager,
* Copyright 2008-2009, Volker Lanz <vl@fidra.de> * Copyright 2008-2009, Volker Lanz <vl@fidra.de>
@ -22,21 +22,21 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <gui/EditExistingPartitionDialog.h> #include "EditExistingPartitionDialog.h"
#include <core/ColorUtils.h> #include "core/ColorUtils.h"
#include <core/PartitionCoreModule.h> #include "core/PartitionCoreModule.h"
#include <core/PartitionInfo.h> #include "core/PartitionInfo.h"
#include "core/PartUtils.h" #include "core/PartUtils.h"
#include <core/KPMHelpers.h> #include "core/KPMHelpers.h"
#include "gui/PartitionDialogHelpers.h" #include "gui/PartitionDialogHelpers.h"
#include <gui/PartitionSizeController.h> #include "gui/PartitionSizeController.h"
#include <ui_EditExistingPartitionDialog.h> #include "ui_EditExistingPartitionDialog.h"
#include <utils/Logger.h>
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "utils/Logger.h"
// KPMcore // KPMcore
#include <kpmcore/core/device.h> #include <kpmcore/core/device.h>
@ -77,7 +77,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
m_ui->fileSystemComboBox->setEnabled( doFormat ); m_ui->fileSystemComboBox->setEnabled( doFormat );
if ( !doFormat ) if ( !doFormat )
m_ui->fileSystemComboBox->setCurrentText( m_partition->fileSystem().name() ); m_ui->fileSystemComboBox->setCurrentText( KPMHelpers::userVisibleFS( m_partition->fileSystem() ) );
updateMountPointPicker(); updateMountPointPicker();
} ); } );
@ -93,16 +93,25 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
for ( auto fs : FileSystemFactory::map() ) for ( auto fs : FileSystemFactory::map() )
{ {
if ( fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Extended ) if ( fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Extended )
fsNames << fs->name(); fsNames << KPMHelpers::userVisibleFS( fs ); // For the combo box
} }
m_ui->fileSystemComboBox->addItems( fsNames ); m_ui->fileSystemComboBox->addItems( fsNames );
if ( fsNames.contains( m_partition->fileSystem().name() ) ) FileSystem::Type defaultFSType;
m_ui->fileSystemComboBox->setCurrentText( m_partition->fileSystem().name() ); QString untranslatedFSName = PartUtils::findFS(
else Calamares::JobQueue::instance()->
m_ui->fileSystemComboBox->setCurrentText( Calamares::JobQueue::instance()->
globalStorage()-> globalStorage()->
value( "defaultFileSystemType" ).toString() ); value( "defaultFileSystemType" ).toString(), &defaultFSType );
if ( defaultFSType == FileSystem::Type::Unknown )
{
defaultFSType = FileSystem::Type::Ext4;
}
QString thisFSNameForUser = KPMHelpers::userVisibleFS( m_partition->fileSystem() );
if ( fsNames.contains( thisFSNameForUser ) )
m_ui->fileSystemComboBox->setCurrentText( thisFSNameForUser );
else
m_ui->fileSystemComboBox->setCurrentText( FileSystem::nameForType( defaultFSType ) );
m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() ); m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() );
m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() ); m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() );