[partition] Output filesystem features in overview

This commit is contained in:
Gaël PORTAY 2020-11-01 21:29:47 -05:00
parent c045af1975
commit af5c57a713

View File

@ -91,6 +91,7 @@ mapForPartition( Partition* partition, const QString& uuid )
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
map[ "fsName" ] = userVisibleFS( partition->fileSystem() );
map[ "fs" ] = untranslatedFS( partition->fileSystem() );
map[ "features" ] = partition->fileSystem().features();
if ( partition->fileSystem().type() == FileSystem::Luks
&& dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() )
{
@ -126,6 +127,33 @@ mapForPartition( Partition* partition, const QString& uuid )
return map;
}
static QString
prettyFileSystemFeatures( const QVariantMap& features )
{
QStringList list;
for ( const auto& key : features.keys() )
{
const auto& value = features.value( key );
if ( value.type() == QVariant::Bool )
{
if ( value.toBool() )
{
list += key;
}
else
{
list += QString( "not " ) + key;
}
}
else
{
list += key + QString( "=" ) + value.toString();
}
}
return list.join( QStringLiteral( ", " ) );
}
FillGlobalStorageJob::FillGlobalStorageJob( const Config*, QList< Device* > devices, const QString& bootLoaderPath )
: m_devices( devices )
, m_bootLoaderPath( bootLoaderPath )
@ -153,6 +181,7 @@ FillGlobalStorageJob::prettyDescription() const
QString path = partitionMap.value( "device" ).toString();
QString mountPoint = partitionMap.value( "mountPoint" ).toString();
QString fsType = partitionMap.value( "fs" ).toString();
QString features = prettyFileSystemFeatures( partitionMap.value( "features" ).toMap() );
if ( mountPoint.isEmpty() || fsType.isEmpty() || fsType == QString( "unformatted" ) )
{
continue;
@ -161,34 +190,81 @@ FillGlobalStorageJob::prettyDescription() const
{
if ( mountPoint == "/" )
{
lines.append( tr( "Install %1 on <strong>new</strong> %2 system partition." )
.arg( Calamares::Branding::instance()->shortProductName() )
.arg( fsType ) );
if ( !features.isEmpty() )
{
lines.append( tr( "Install %1 on <strong>new</strong> %2 system partition "
"with features <em>%3</em>" )
.arg( Calamares::Branding::instance()->shortProductName() )
.arg( fsType )
.arg( features ) );
}
else
{
lines.append( tr( "Install %1 on <strong>new</strong> %2 system partition." )
.arg( Calamares::Branding::instance()->shortProductName() )
.arg( fsType ) );
}
}
else
{
lines.append( tr( "Set up <strong>new</strong> %2 partition with mount point "
"<strong>%1</strong>." )
.arg( mountPoint )
.arg( fsType ) );
if ( !features.isEmpty() )
{
lines.append( tr( "Set up <strong>new</strong> %2 partition with mount point "
"<strong>%1</strong> and features <em>%3</em>." )
.arg( mountPoint )
.arg( fsType )
.arg( features ) );
}
else
{
lines.append( tr( "Set up <strong>new</strong> %2 partition with mount point "
"<strong>%1</strong>%3." )
.arg( mountPoint )
.arg( fsType )
.arg( features ) );
}
}
}
else
{
if ( mountPoint == "/" )
{
lines.append( tr( "Install %2 on %3 system partition <strong>%1</strong>." )
.arg( path )
.arg( Calamares::Branding::instance()->shortProductName() )
.arg( fsType ) );
if ( !features.isEmpty() )
{
lines.append( tr( "Install %2 on %3 system partition <strong>%1</strong>"
" with features <em>%4</em>." )
.arg( path )
.arg( Calamares::Branding::instance()->shortProductName() )
.arg( fsType )
.arg( features ) );
}
else
{
lines.append( tr( "Install %2 on %3 system partition <strong>%1</strong>." )
.arg( path )
.arg( Calamares::Branding::instance()->shortProductName() )
.arg( fsType ) );
}
}
else
{
lines.append( tr( "Set up %3 partition <strong>%1</strong> with mount point "
"<strong>%2</strong>." )
.arg( path )
.arg( mountPoint )
.arg( fsType ) );
if ( !features.isEmpty() )
{
lines.append( tr( "Set up %3 partition <strong>%1</strong> with mount point "
"<strong>%2</strong> and features <em>%4</em>." )
.arg( path )
.arg( mountPoint )
.arg( fsType )
.arg( features ) );
}
else
{
lines.append( tr( "Set up %3 partition <strong>%1</strong> with mount point "
"<strong>%2</strong>%4." )
.arg( path )
.arg( mountPoint )
.arg( fsType ) );
}
}
}
}