[partition] Do not translate filesystem names

- Move contents of FSName to KPMHelpers
 - Use the new functions from FillGlobalStorage

Needs more use in the rest of the partition module.
This commit is contained in:
Adriaan de Groot 2020-02-13 11:06:53 +01:00
parent f410a4bb68
commit a0449abab9
3 changed files with 21 additions and 57 deletions

View File

@ -1,52 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2020, Adriaan de Groot <groot@kde.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/** @brief Gets filesystem names from KPMCore
*
* A name (e.g. "ext4") can be for internal, untranslated, use, or for
* user-visible use. In the latter case it should be translated. The
* KPMCore API gives user-visible names by default.
*/
#ifndef PARTITION_FSNAME_H
#define PARTITION_FSNAME_H
#include <fs/filesystem.h>
#include <QString>
namespace CalamaresUtils
{
namespace Partition
{
static inline QString
untranslatedFS( FileSystem& fs )
{
return fs.name( { QStringLiteral( "C" ) } );
}
static inline QString
untranslatedFS( FileSystem* fs )
{
return fs ? untranslatedFS( *fs ) : QString();
}
} // namespace Partition
} // namespace CalamaresUtils
#endif // PARTITION_FSNAME_H

View File

@ -114,6 +114,19 @@ Partition* createNewEncryptedPartition( PartitionNode* parent,
Partition* clonePartition( Device* device, Partition* partition ); Partition* clonePartition( Device* device, Partition* partition );
QString prettyNameForFileSystemType( FileSystem::Type t ); QString prettyNameForFileSystemType( FileSystem::Type t );
static inline QString
untranslatedFS( FileSystem& fs )
{
return fs.name( { QStringLiteral( "C" ) } );
}
static inline QString
untranslatedFS( FileSystem* fs )
{
return fs ? untranslatedFS( *fs ) : QString();
}
} }
#endif /* KPMHELPERS_H */ #endif /* KPMHELPERS_H */

View File

@ -20,11 +20,12 @@
#include "jobs/FillGlobalStorageJob.h" #include "jobs/FillGlobalStorageJob.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "core/PartitionInfo.h" #include "core/PartitionInfo.h"
#include "core/PartitionIterator.h" #include "core/PartitionIterator.h"
#include "core/KPMHelpers.h" #include "core/KPMHelpers.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "Branding.h" #include "Branding.h"
#include "utils/Logger.h" #include "utils/Logger.h"
@ -40,6 +41,8 @@
#include <QFileInfo> #include <QFileInfo>
#include <QProcess> #include <QProcess>
using KPMHelpers::untranslatedFS;
typedef QHash<QString, QString> UuidForPartitionHash; typedef QHash<QString, QString> UuidForPartitionHash;
static UuidForPartitionHash static UuidForPartitionHash
@ -85,11 +88,11 @@ mapForPartition( Partition* partition, const QString& uuid )
QVariantMap map; QVariantMap map;
map[ "device" ] = partition->partitionPath(); map[ "device" ] = partition->partitionPath();
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition ); map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
map[ "fsName" ] = partition->fileSystem().name(); map[ "fsName" ] = partition->fileSystem().name(); // User-visible
map[ "fs" ] = partition->fileSystem().name( { QStringLiteral("C") } ); // Untranslated map[ "fs" ] = untranslatedFS( partition->fileSystem() );
if ( partition->fileSystem().type() == FileSystem::Luks && if ( partition->fileSystem().type() == FileSystem::Luks &&
dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() ) dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() )
map[ "fs" ] = dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS()->name( { QStringLiteral("C") } ); map[ "fs" ] = untranslatedFS( dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() );
map[ "uuid" ] = uuid; map[ "uuid" ] = uuid;
// Debugging for inside the loop in createPartitionList(), // Debugging for inside the loop in createPartitionList(),