[partition] Convenience userVisibleFS()

- Mark uses of filesystem-name where it's intentional that they
   are user-visible, with a new convenience function.
This commit is contained in:
Adriaan de Groot 2020-02-13 11:22:09 +01:00
parent dac5516b2c
commit 29894cec6a
3 changed files with 24 additions and 6 deletions

View File

@ -127,6 +127,18 @@ untranslatedFS( FileSystem* fs )
return fs ? untranslatedFS( *fs ) : QString(); return fs ? untranslatedFS( *fs ) : QString();
} }
static inline QString
userVisibleFS( FileSystem& fs )
{
return fs.name();
}
static inline QString
userVisibleFS( FileSystem* fs )
{
return fs ? userVisibleFS( *fs ) : QString();
}
} }
#endif /* KPMHELPERS_H */ #endif /* KPMHELPERS_H */

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 2015, Teo Mrnjavac <teo@kde.org> * Copyright 2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org> * Copyright 2017, 2020, Adriaan de Groot <groot@kde.org>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -20,6 +20,8 @@
#include "jobs/CreatePartitionJob.h" #include "jobs/CreatePartitionJob.h"
#include "core/KPMHelpers.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Units.h" #include "utils/Units.h"
@ -32,6 +34,9 @@
#include <kpmcore/ops/newoperation.h> #include <kpmcore/ops/newoperation.h>
#include <kpmcore/util/report.h> #include <kpmcore/util/report.h>
using KPMHelpers::untranslatedFS;
using KPMHelpers::userVisibleFS;
CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition ) CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition )
: PartitionJob( partition ) : PartitionJob( partition )
, m_device( device ) , m_device( device )
@ -42,7 +47,7 @@ QString
CreatePartitionJob::prettyName() const CreatePartitionJob::prettyName() const
{ {
return tr( "Create new %2MiB partition on %4 (%3) with file system %1." ) return tr( "Create new %2MiB partition on %4 (%3) with file system %1." )
.arg( m_partition->fileSystem().name() ) .arg( userVisibleFS( m_partition->fileSystem() )
.arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) )
.arg( m_device->name() ) .arg( m_device->name() )
.arg( m_device->deviceNode() ); .arg( m_device->deviceNode() );
@ -54,7 +59,7 @@ CreatePartitionJob::prettyDescription() const
{ {
return tr( "Create new <strong>%2MiB</strong> partition on <strong>%4</strong> " return tr( "Create new <strong>%2MiB</strong> partition on <strong>%4</strong> "
"(%3) with file system <strong>%1</strong>." ) "(%3) with file system <strong>%1</strong>." )
.arg( m_partition->fileSystem().name() ) .arg( userVisibleFS( m_partition->fileSystem() ) )
.arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) ) .arg( CalamaresUtils::BytesToMiB( m_partition->capacity() ) )
.arg( m_device->name() ) .arg( m_device->name() )
.arg( m_device->deviceNode() ); .arg( m_device->deviceNode() );
@ -65,7 +70,7 @@ QString
CreatePartitionJob::prettyStatusMessage() const CreatePartitionJob::prettyStatusMessage() const
{ {
return tr( "Creating new %1 partition on %2." ) return tr( "Creating new %1 partition on %2." )
.arg( m_partition->fileSystem().name() ) .arg( userVisibleFS( m_partition->fileSystem() ) )
.arg( m_device->deviceNode() ); .arg( m_device->deviceNode() );
} }

View File

@ -42,6 +42,7 @@
#include <QProcess> #include <QProcess>
using KPMHelpers::untranslatedFS; using KPMHelpers::untranslatedFS;
using KPMHelpers::userVisibleFS;
typedef QHash< QString, QString > UuidForPartitionHash; typedef QHash< QString, QString > UuidForPartitionHash;
@ -91,7 +92,7 @@ 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(); // User-visible map[ "fsName" ] = userVisibleFS( partition->fileSystem() );
map[ "fs" ] = untranslatedFS( partition->fileSystem() ); 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() )
@ -106,7 +107,7 @@ mapForPartition( Partition* partition, const QString& uuid )
using TR = Logger::DebugRow< const char* const, const QString& >; using TR = Logger::DebugRow< const char* const, const QString& >;
deb << Logger::SubEntry << "mapping for" << partition->partitionPath() << partition->deviceNode() deb << Logger::SubEntry << "mapping for" << partition->partitionPath() << partition->deviceNode()
<< TR( "mtpoint:", PartitionInfo::mountPoint( partition ) ) << TR( "fs:", map[ "fs" ].toString() ) << TR( "mtpoint:", PartitionInfo::mountPoint( partition ) ) << TR( "fs:", map[ "fs" ].toString() )
<< TR( "fsname", map[ "fsName" ].toString() ) << TR( "uuid", uuid ); << TR( "fsName", map[ "fsName" ].toString() ) << TR( "uuid", uuid );
if ( partition->roles().has( PartitionRole::Luks ) ) if ( partition->roles().has( PartitionRole::Luks ) )
{ {