Merge branch 'fs-translation'

Double-check the uses of filesystem names -- give only *untranslated*
names to system tools, and show *translated* ones.
This commit is contained in:
Adriaan de Groot 2020-02-13 13:30:33 +01:00
commit 6d10c41aeb
10 changed files with 158 additions and 77 deletions

View File

@ -8,6 +8,7 @@ website will have to do for older versions.
This release contains contributions from (alphabetically by first name):
- Anke Boersma
- Camilo Higuita
- Gabriel Craciunescu
## Core ##
- *Assamese* translation has been completed.

View File

@ -114,6 +114,31 @@ Partition* createNewEncryptedPartition( PartitionNode* parent,
Partition* clonePartition( Device* device, Partition* partition );
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();
}
static inline QString
userVisibleFS( FileSystem& fs )
{
return fs.name();
}
static inline QString
userVisibleFS( FileSystem* fs )
{
return fs ? userVisibleFS( *fs ) : QString();
}
}
#endif /* KPMHELPERS_H */

View File

@ -2,7 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@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>
* Copyright 2018, Andrius Štikonas <andrius@stikonas.eu>
* Copyright 2018, Caio Carvalho <caiojcarvalho@gmail.com>
*
@ -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;
@ -106,8 +112,8 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
if ( fs->supportCreate() != FileSystem::cmdSupportNone &&
fs->type() != FileSystem::Extended )
{
fsNames << fs->name();
if ( fs->type() == defaultFsType )
fsNames << KPMHelpers::userVisibleFS( fs ); // This is put into the combobox
if ( fs->type() == defaultFSType )
defaultFsIndex = fsCounter;
fsCounter++;
}
@ -232,6 +238,7 @@ CreatePartitionDialog::updateMountPointUi()
bool enabled = m_ui->primaryRadioButton->isChecked();
if ( enabled )
{
// This maps translated (user-visible) FS names to a type
FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() );
enabled = !s_unmountableFS.contains( type );

View File

@ -2,7 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@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,
* Copyright 2008-2009, Volker Lanz <vl@fidra.de>
@ -22,21 +22,21 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gui/EditExistingPartitionDialog.h>
#include "EditExistingPartitionDialog.h"
#include <core/ColorUtils.h>
#include <core/PartitionCoreModule.h>
#include <core/PartitionInfo.h>
#include "core/ColorUtils.h"
#include "core/PartitionCoreModule.h"
#include "core/PartitionInfo.h"
#include "core/PartUtils.h"
#include <core/KPMHelpers.h>
#include "core/KPMHelpers.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 "JobQueue.h"
#include "utils/Logger.h"
// KPMcore
#include <kpmcore/core/device.h>
@ -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() );

View File

@ -600,7 +600,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
else if ( fsType != FileSystem::Unknown )
cWarning() << "Partition-module setting *defaultFileSystemType* changed" << fsRealName;
else
cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << fsRealName << ") using ext4.";
cWarning() << "Partition-module setting *defaultFileSystemType* is bad (" << fsName << ") using" << fsRealName << "instead.";
gs->insert( "defaultFileSystemType", fsRealName );

View File

@ -22,6 +22,7 @@
#include "ui_ReplaceWidget.h"
#include "core/DeviceModel.h"
#include "core/KPMHelpers.h"
#include "core/PartitionCoreModule.h"
#include "core/PartitionActions.h"
#include "core/PartitionInfo.h"
@ -192,8 +193,8 @@ ReplaceWidget::onPartitionSelected()
return;
}
QString prettyName = tr( "Data partition (%1)" )
.arg( partition->fileSystem().name() );
QString fsNameForUser = KPMHelpers::userVisibleFS( partition->fileSystem() );
QString prettyName = tr( "Data partition (%1)" ).arg( fsNameForUser );
for ( const QString& line : osproberLines )
{
QStringList lineColumns = line.split( ':' );
@ -210,13 +211,13 @@ ReplaceWidget::onPartitionSelected()
if ( osName.isEmpty() )
{
prettyName = tr( "Unknown system partition (%1)" )
.arg( partition->fileSystem().name() );
.arg( fsNameForUser );
}
else
{
prettyName = tr ( "%1 system partition (%2)" )
.arg( osName.replace( 0, 1, osName.at( 0 ).toUpper() ) )
.arg( partition->fileSystem().name() );
.arg( fsNameForUser );
}
break;
}

View File

@ -2,7 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@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
* it under the terms of the GNU General Public License as published by
@ -20,6 +20,8 @@
#include "jobs/CreatePartitionJob.h"
#include "core/KPMHelpers.h"
#include "utils/Logger.h"
#include "utils/Units.h"
@ -32,6 +34,9 @@
#include <kpmcore/ops/newoperation.h>
#include <kpmcore/util/report.h>
using KPMHelpers::untranslatedFS;
using KPMHelpers::userVisibleFS;
CreatePartitionJob::CreatePartitionJob( Device* device, Partition* partition )
: PartitionJob( partition )
, m_device( device )
@ -42,7 +47,7 @@ QString
CreatePartitionJob::prettyName() const
{
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( m_device->name() )
.arg( m_device->deviceNode() );
@ -54,7 +59,7 @@ CreatePartitionJob::prettyDescription() const
{
return tr( "Create new <strong>%2MiB</strong> partition on <strong>%4</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( m_device->name() )
.arg( m_device->deviceNode() );
@ -65,7 +70,7 @@ QString
CreatePartitionJob::prettyStatusMessage() const
{
return tr( "Creating new %1 partition on %2." )
.arg( m_partition->fileSystem().name() )
.arg( userVisibleFS( m_partition->fileSystem() ) )
.arg( m_device->deviceNode() );
}

View File

@ -2,7 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, 2019, Adriaan de Groot <groot@kde.org>
* Copyright 2017, 2019-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
@ -20,12 +20,13 @@
#include "jobs/FillGlobalStorageJob.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "core/KPMHelpers.h"
#include "core/PartitionInfo.h"
#include "core/PartitionIterator.h"
#include "core/KPMHelpers.h"
#include "Branding.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/Logger.h"
// KPMcore
@ -40,16 +41,18 @@
#include <QFileInfo>
#include <QProcess>
typedef QHash<QString, QString> UuidForPartitionHash;
using KPMHelpers::untranslatedFS;
using KPMHelpers::userVisibleFS;
typedef QHash< QString, QString > UuidForPartitionHash;
static UuidForPartitionHash
findPartitionUuids( QList < Device* > devices )
findPartitionUuids( QList< Device* > devices )
{
UuidForPartitionHash hash;
foreach ( Device* device, devices )
{
for ( auto it = PartitionIterator::begin( device );
it != PartitionIterator::end( device ); ++it )
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
{
Partition* p = *it;
QString path = p->partitionPath();
@ -59,7 +62,9 @@ findPartitionUuids( QList < Device* > devices )
}
if ( hash.isEmpty() )
{
cDebug() << "No UUIDs found for existing partitions.";
}
return hash;
}
@ -73,7 +78,9 @@ getLuksUuid( const QString& path )
process.start();
process.waitForFinished();
if ( process.exitStatus() != QProcess::NormalExit || process.exitCode() )
{
return QString();
}
QString uuid = QString::fromLocal8Bit( process.readAllStandardOutput() ).trimmed();
return uuid;
}
@ -85,22 +92,22 @@ mapForPartition( Partition* partition, const QString& uuid )
QVariantMap map;
map[ "device" ] = partition->partitionPath();
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
map[ "fsName" ] = partition->fileSystem().name();
map[ "fs" ] = partition->fileSystem().name( { QStringLiteral("C") } ); // Untranslated
if ( partition->fileSystem().type() == FileSystem::Luks &&
dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() )
map[ "fs" ] = dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS()->name();
map[ "fsName" ] = userVisibleFS( partition->fileSystem() );
map[ "fs" ] = untranslatedFS( partition->fileSystem() );
if ( partition->fileSystem().type() == FileSystem::Luks
&& dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() )
{
map[ "fs" ] = untranslatedFS( dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() );
}
map[ "uuid" ] = uuid;
// Debugging for inside the loop in createPartitionList(),
// so indent a bit
Logger::CDebug deb;
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()
<< TR( "mtpoint:", PartitionInfo::mountPoint( partition ) )
<< TR( "fs:", map[ "fs" ].toString() )
<< TR( "fsname", map[ "fsName" ].toString() )
<< TR( "uuid", uuid );
<< TR( "mtpoint:", PartitionInfo::mountPoint( partition ) ) << TR( "fs:", map[ "fs" ].toString() )
<< TR( "fsName", map[ "fsName" ].toString() ) << TR( "uuid", uuid );
if ( partition->roles().has( PartitionRole::Luks ) )
{
@ -137,7 +144,7 @@ FillGlobalStorageJob::prettyDescription() const
QStringList lines;
const auto partitionList = createPartitionList().toList();
for ( const QVariant &partitionItem : partitionList )
for ( const QVariant& partitionItem : partitionList )
{
if ( partitionItem.type() == QVariant::Map )
{
@ -146,32 +153,42 @@ FillGlobalStorageJob::prettyDescription() const
QString mountPoint = partitionMap.value( "mountPoint" ).toString();
QString fsType = partitionMap.value( "fs" ).toString();
if ( mountPoint.isEmpty() || fsType.isEmpty() )
{
continue;
}
if ( path.isEmpty() )
{
if ( mountPoint == "/" )
{
lines.append( tr( "Install %1 on <strong>new</strong> %2 system partition." )
.arg( *Calamares::Branding::ShortProductName )
.arg( fsType ) );
.arg( *Calamares::Branding::ShortProductName )
.arg( fsType ) );
}
else
{
lines.append( tr( "Set up <strong>new</strong> %2 partition with mount point "
"<strong>%1</strong>." )
.arg( mountPoint )
.arg( fsType ) );
.arg( mountPoint )
.arg( fsType ) );
}
}
else
{
if ( mountPoint == "/" )
{
lines.append( tr( "Install %2 on %3 system partition <strong>%1</strong>." )
.arg( path )
.arg( *Calamares::Branding::ShortProductName )
.arg( fsType ) );
.arg( path )
.arg( *Calamares::Branding::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 ) );
.arg( path )
.arg( mountPoint )
.arg( fsType ) );
}
}
}
}
@ -179,8 +196,7 @@ FillGlobalStorageJob::prettyDescription() const
QVariant bootloaderMap = createBootLoaderMap();
if ( !m_bootLoaderPath.isEmpty() )
{
lines.append( tr( "Install boot loader on <strong>%1</strong>." )
.arg( m_bootLoaderPath ) );
lines.append( tr( "Install boot loader on <strong>%1</strong>." ).arg( m_bootLoaderPath ) );
}
return lines.join( "<br/>" );
}
@ -201,7 +217,9 @@ FillGlobalStorageJob::exec()
{
QVariant var = createBootLoaderMap();
if ( !var.isValid() )
{
cDebug() << "Failed to find path for boot loader";
}
cDebug() << "FillGlobalStorageJob writing bootLoader path:" << var;
storage->insert( "bootLoader", var );
}
@ -222,8 +240,7 @@ FillGlobalStorageJob::createPartitionList() const
for ( auto device : m_devices )
{
cDebug() << Logger::SubEntry << "partitions on" << device->deviceNode();
for ( auto it = PartitionIterator::begin( device );
it != PartitionIterator::end( device ); ++it )
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
{
// Debug-logging is done when creating the map
lst << mapForPartition( *it, hash.value( ( *it )->partitionPath() ) );
@ -241,7 +258,9 @@ FillGlobalStorageJob::createBootLoaderMap() const
{
Partition* partition = KPMHelpers::findPartitionByMountPoint( m_devices, path );
if ( !partition )
{
return QVariant();
}
path = partition->partitionPath();
}
map[ "installPath" ] = path;

View File

@ -19,6 +19,8 @@
#include "jobs/FormatPartitionJob.h"
#include "core/KPMHelpers.h"
#include "utils/Logger.h"
// KPMcore
@ -29,6 +31,9 @@
#include <ops/createfilesystemoperation.h>
#include <util/report.h>
using KPMHelpers::untranslatedFS;
using KPMHelpers::userVisibleFS;
FormatPartitionJob::FormatPartitionJob( Device* device, Partition* partition )
: PartitionJob( partition )
, m_device( device )
@ -40,7 +45,7 @@ FormatPartitionJob::prettyName() const
{
return tr( "Format partition %1 (file system: %2, size: %3 MiB) on %4." )
.arg( m_partition->partitionPath() )
.arg( m_partition->fileSystem().name() )
.arg( userVisibleFS( m_partition->fileSystem() ) )
.arg( m_partition->capacity() / 1024 / 1024 )
.arg( m_device->name() );
}
@ -52,7 +57,7 @@ FormatPartitionJob::prettyDescription() const
return tr( "Format <strong>%3MiB</strong> partition <strong>%1</strong> with "
"file system <strong>%2</strong>." )
.arg( m_partition->partitionPath() )
.arg( m_partition->fileSystem().name() )
.arg( userVisibleFS( m_partition->fileSystem() ) )
.arg( m_partition->capacity() / 1024 / 1024 );
}
@ -63,7 +68,7 @@ FormatPartitionJob::prettyStatusMessage() const
return tr( "Formatting partition %1 with "
"file system %2." )
.arg( m_partition->partitionPath() )
.arg( m_partition->fileSystem().name() );
.arg( userVisibleFS( m_partition->fileSystem() ) );
}

View File

@ -21,6 +21,8 @@
#include "SetPartitionFlagsJob.h"
#include "core/KPMHelpers.h"
#include "utils/Logger.h"
#include "utils/Units.h"
@ -32,6 +34,8 @@
#include <util/report.h>
using CalamaresUtils::BytesToMiB;
using KPMHelpers::untranslatedFS;
using KPMHelpers::userVisibleFS;
SetPartFlagsJob::SetPartFlagsJob( Device* device,
Partition* partition,
@ -48,10 +52,11 @@ SetPartFlagsJob::prettyName() const
if ( !partition()->partitionPath().isEmpty() )
return tr( "Set flags on partition %1." ).arg( partition()->partitionPath() );
if ( !partition()->fileSystem().name().isEmpty() )
QString fsNameForUser = userVisibleFS( partition()->fileSystem() );
if ( !fsNameForUser.isEmpty() )
return tr( "Set flags on %1MiB %2 partition." )
.arg( BytesToMiB( partition()->capacity() ) )
.arg( partition()->fileSystem().name() );
.arg( fsNameForUser );
return tr( "Set flags on new partition." );
}
@ -67,10 +72,11 @@ SetPartFlagsJob::prettyDescription() const
return tr( "Clear flags on partition <strong>%1</strong>." )
.arg( partition()->partitionPath() );
if ( !partition()->fileSystem().name().isEmpty() )
QString fsNameForUser = userVisibleFS( partition()->fileSystem() );
if ( !fsNameForUser.isEmpty() )
return tr( "Clear flags on %1MiB <strong>%2</strong> partition." )
.arg( BytesToMiB( partition()->capacity() ) )
.arg( partition()->fileSystem().name() );
.arg( fsNameForUser );
return tr( "Clear flags on new partition." );
}
@ -81,11 +87,12 @@ SetPartFlagsJob::prettyDescription() const
.arg( partition()->partitionPath() )
.arg( flagsList.join( ", " ) );
if ( !partition()->fileSystem().name().isEmpty() )
QString fsNameForUser = userVisibleFS( partition()->fileSystem() );
if ( !fsNameForUser.isEmpty() )
return tr( "Flag %1MiB <strong>%2</strong> partition as "
"<strong>%3</strong>." )
.arg( BytesToMiB( partition()->capacity() ) )
.arg( partition()->fileSystem().name() )
.arg( fsNameForUser )
.arg( flagsList.join( ", " ) );
return tr( "Flag new partition as <strong>%1</strong>." )
@ -103,10 +110,11 @@ SetPartFlagsJob::prettyStatusMessage() const
return tr( "Clearing flags on partition <strong>%1</strong>." )
.arg( partition()->partitionPath() );
if ( !partition()->fileSystem().name().isEmpty() )
QString fsNameForUser = userVisibleFS( partition()->fileSystem() );
if ( !fsNameForUser.isEmpty() )
return tr( "Clearing flags on %1MiB <strong>%2</strong> partition." )
.arg( BytesToMiB( partition()->capacity() ) )
.arg( partition()->fileSystem().name() );
.arg( fsNameForUser );
return tr( "Clearing flags on new partition." );
}
@ -117,11 +125,12 @@ SetPartFlagsJob::prettyStatusMessage() const
.arg( partition()->partitionPath() )
.arg( flagsList.join( ", " ) );
if ( !partition()->fileSystem().name().isEmpty() )
QString fsNameForUser = userVisibleFS( partition()->fileSystem() );
if ( !fsNameForUser.isEmpty() )
return tr( "Setting flags <strong>%3</strong> on "
"%1MiB <strong>%2</strong> partition." )
.arg( BytesToMiB( partition()->capacity() ) )
.arg( partition()->fileSystem().name() )
.arg( fsNameForUser )
.arg( flagsList.join( ", " ) );
return tr( "Setting flags <strong>%1</strong> on new partition." )