From 5a50a3a40ca6a4749b7d4e38da6642b03d6dad19 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 13 Feb 2020 13:24:53 +0100 Subject: [PATCH] [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. --- .../partition/gui/CreatePartitionDialog.cpp | 14 +++++-- .../gui/EditExistingPartitionDialog.cpp | 41 +++++++++++-------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index b85d3e7e8..926df03a3 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -93,11 +93,17 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par else initGptPartitionTypeUi(); - // File system - FileSystem::Type defaultFsType = FileSystem::typeForName( + // File system; the config value is translated (best-effort) to a type + FileSystem::Type defaultFSType; + QString untranslatedFSName = PartUtils::findFS( Calamares::JobQueue::instance()-> globalStorage()-> - value( "defaultFileSystemType" ).toString() ); + value( "defaultFileSystemType" ).toString(), &defaultFSType ); + if ( defaultFSType == FileSystem::Type::Unknown ) + { + defaultFSType = FileSystem::Type::Ext4; + } + int defaultFsIndex = -1; int fsCounter = 0; QStringList fsNames; @@ -107,7 +113,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par fs->type() != FileSystem::Extended ) { fsNames << KPMHelpers::userVisibleFS( fs ); // This is put into the combobox - if ( fs->type() == defaultFsType ) + if ( fs->type() == defaultFSType ) defaultFsIndex = fsCounter; fsCounter++; } diff --git a/src/modules/partition/gui/EditExistingPartitionDialog.cpp b/src/modules/partition/gui/EditExistingPartitionDialog.cpp index 3ad5080b4..6268a2a22 100644 --- a/src/modules/partition/gui/EditExistingPartitionDialog.cpp +++ b/src/modules/partition/gui/EditExistingPartitionDialog.cpp @@ -2,7 +2,7 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2016, Teo Mrnjavac - * Copyright 2018, Adriaan de Groot + * Copyright 2018, 2020, Adriaan de Groot * * Flags handling originally from KDE Partition Manager, * Copyright 2008-2009, Volker Lanz @@ -22,21 +22,21 @@ * along with Calamares. If not, see . */ -#include +#include "EditExistingPartitionDialog.h" -#include -#include -#include +#include "core/ColorUtils.h" +#include "core/PartitionCoreModule.h" +#include "core/PartitionInfo.h" #include "core/PartUtils.h" -#include +#include "core/KPMHelpers.h" #include "gui/PartitionDialogHelpers.h" -#include +#include "gui/PartitionSizeController.h" -#include +#include "ui_EditExistingPartitionDialog.h" -#include #include "GlobalStorage.h" #include "JobQueue.h" +#include "utils/Logger.h" // KPMcore #include @@ -77,7 +77,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit m_ui->fileSystemComboBox->setEnabled( doFormat ); if ( !doFormat ) - m_ui->fileSystemComboBox->setCurrentText( m_partition->fileSystem().name() ); + m_ui->fileSystemComboBox->setCurrentText( KPMHelpers::userVisibleFS( m_partition->fileSystem() ) ); updateMountPointPicker(); } ); @@ -93,16 +93,25 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit for ( auto fs : FileSystemFactory::map() ) { 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 ); - if ( fsNames.contains( m_partition->fileSystem().name() ) ) - m_ui->fileSystemComboBox->setCurrentText( m_partition->fileSystem().name() ); + FileSystem::Type defaultFSType; + QString untranslatedFSName = PartUtils::findFS( + Calamares::JobQueue::instance()-> + globalStorage()-> + 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( Calamares::JobQueue::instance()-> - globalStorage()-> - value( "defaultFileSystemType" ).toString() ); + m_ui->fileSystemComboBox->setCurrentText( FileSystem::nameForType( defaultFSType ) ); m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() ); m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() );