diff --git a/CHANGES b/CHANGES index 1322f0449..cb807cdc4 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,8 @@ 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. diff --git a/src/libcalamares/locale/Label.cpp b/src/libcalamares/locale/Label.cpp index 58c19101d..816246699 100644 --- a/src/libcalamares/locale/Label.cpp +++ b/src/libcalamares/locale/Label.cpp @@ -24,23 +24,16 @@ namespace CalamaresUtils namespace Locale { -Label::Label() - : m_locale( QLocale() ) +Label::Label( QObject* parent ) + : Label( QString(), LabelFormat::IfNeededWithCountry, parent ) { - m_localeId = m_locale.name(); - - setLabels( QString(), LabelFormat::IfNeededWithCountry ); } -Label::Label( const QString& locale, LabelFormat format ) - : m_locale( Label::getLocale( locale ) ) - , m_localeId( locale ) -{ - setLabels( locale, format ); -} +Label::Label( const QString& locale, LabelFormat format, QObject* parent ) + : QObject( parent ) + , m_locale( Label::getLocale( locale ) ) + , m_localeId( locale.isEmpty() ? m_locale.name() : locale ) -void -Label::setLabels( const QString& locale, LabelFormat format ) { //: language[name] (country[name]) QString longFormat = QObject::tr( "%1 (%2)" ); @@ -69,6 +62,10 @@ Label::setLabels( const QString& locale, LabelFormat format ) QLocale Label::getLocale( const QString& localeName ) { + if ( localeName.isEmpty() ) + { + return QLocale(); + } if ( localeName.contains( "@latin" ) ) { QLocale loc( localeName ); // Ignores @latin diff --git a/src/libcalamares/locale/Label.h b/src/libcalamares/locale/Label.h index 95129d38c..d7fa14453 100644 --- a/src/libcalamares/locale/Label.h +++ b/src/libcalamares/locale/Label.h @@ -21,6 +21,7 @@ #define LOCALE_LABEL_H #include +#include #include namespace CalamaresUtils @@ -35,8 +36,14 @@ namespace Locale * translation system) into QLocales, and also into consistent * human-readable text labels. */ -class Label +class Label : public QObject { + Q_OBJECT + + Q_PROPERTY( QString label READ label CONSTANT FINAL ) + Q_PROPERTY( QString englishLabel READ englishLabel CONSTANT FINAL ) + Q_PROPERTY( QString localeId MEMBER m_localeId CONSTANT FINAL ) + public: /** @brief Formatting option for label -- add (country) to label. */ enum class LabelFormat @@ -46,7 +53,7 @@ public: }; /** @brief Empty locale. This uses the system-default locale. */ - Label(); + Label( QObject* parent = nullptr ); /** @brief Construct from a locale name. * @@ -54,7 +61,9 @@ public: * The @p format determines whether the country name is always present * in the label (human-readable form) or only if needed for disambiguation. */ - Label( const QString& localeName, LabelFormat format = LabelFormat::IfNeededWithCountry ); + Label( const QString& localeName, + LabelFormat format = LabelFormat::IfNeededWithCountry, + QObject* parent = nullptr ); /** @brief Define a sorting order. * @@ -94,8 +103,6 @@ public: static QLocale getLocale( const QString& localeName ); protected: - void setLabels( const QString& name, LabelFormat format ); - QLocale m_locale; QString m_localeId; // the locale identifier, e.g. "en_GB" QString m_label; // the native name of the locale diff --git a/src/libcalamares/locale/LabelModel.cpp b/src/libcalamares/locale/LabelModel.cpp index bcb8af057..da4e1a9f7 100644 --- a/src/libcalamares/locale/LabelModel.cpp +++ b/src/libcalamares/locale/LabelModel.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * - * Copyright 2019, Adriaan de Groot + * Copyright 2019-2020 Adriaan de Groot + * Copyright 2019, Camilo Higuita * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -36,7 +37,7 @@ LabelModel::LabelModel( const QStringList& locales, QObject* parent ) for ( const auto& l : locales ) { - m_locales.push_back( Label( l ) ); + m_locales.push_back( new Label( l, Label::LabelFormat::IfNeededWithCountry, this ) ); } } @@ -65,27 +66,33 @@ LabelModel::data( const QModelIndex& index, int role ) const switch ( role ) { case LabelRole: - return locale.label(); + return locale->label(); case EnglishLabelRole: - return locale.englishLabel(); + return locale->englishLabel(); default: return QVariant(); } } +QHash< int, QByteArray > +LabelModel::roleNames() const +{ + return { { LabelRole, "label" }, { EnglishLabelRole, "englishLabel" } }; +} + const Label& LabelModel::locale( int row ) const { if ( ( row < 0 ) || ( row >= m_locales.count() ) ) { for ( const auto& l : m_locales ) - if ( l.isEnglish() ) + if ( l->isEnglish() ) { - return l; + return *l; } - return m_locales[ 0 ]; + return *m_locales[ 0 ]; } - return m_locales[ row ]; + return *m_locales[ row ]; } int @@ -93,7 +100,7 @@ LabelModel::find( std::function< bool( const Label& ) > predicate ) const { for ( int row = 0; row < m_locales.count(); ++row ) { - if ( predicate( m_locales[ row ] ) ) + if ( predicate( *m_locales[ row ] ) ) { return row; } diff --git a/src/libcalamares/locale/LabelModel.h b/src/libcalamares/locale/LabelModel.h index 03daddbf3..7bd1fad67 100644 --- a/src/libcalamares/locale/LabelModel.h +++ b/src/libcalamares/locale/LabelModel.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * - * Copyright 2019, Adriaan de Groot + * Copyright 2019-2020, Adriaan de Groot + * Copyright 2019, Camilo Higuita * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,6 +34,8 @@ namespace Locale class DLLEXPORT LabelModel : public QAbstractListModel { + Q_OBJECT + public: enum { @@ -46,6 +49,7 @@ public: int rowCount( const QModelIndex& parent ) const override; QVariant data( const QModelIndex& index, int role ) const override; + QHash< int, QByteArray > roleNames() const override; /** @brief Gets locale information for entry #n * @@ -69,7 +73,7 @@ public: int find( const QString& countryCode ) const; private: - QVector< Label > m_locales; + QVector< Label* > m_locales; QStringList m_localeIds; }; diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index a5b6e5dce..9bdccfa51 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -3,6 +3,7 @@ * Copyright 2014-2015, Teo Mrnjavac * Copyright 2017-2019, Adriaan de Groot * Copyright 2018, Raul Rodrigo Segura (raurodse) + * Copyright 2019, Camilo Higuita * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -74,7 +75,8 @@ const QStringList Branding::s_imageEntryStrings = { "productLogo", "productIcon", - "productWelcome" + "productWelcome", + "productWallpaper" }; const QStringList Branding::s_styleEntryStrings = diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 30e8be846..e3952881e 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -3,6 +3,7 @@ * Copyright 2014-2015, Teo Mrnjavac * Copyright 2017-2018, Adriaan de Groot * Copyright 2018, Raul Rodrigo Segura (raurodse) + * Copyright 2019, Camilo Higuita * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,7 +49,7 @@ public: * e.g. *Branding::ProductName to get the string value for * the product name. */ - enum StringEntry : short + enum StringEntry { ProductName, Version, @@ -62,13 +63,16 @@ public: KnownIssuesUrl, ReleaseNotesUrl }; + Q_ENUM( StringEntry ) enum ImageEntry : short { ProductLogo, ProductIcon, - ProductWelcome + ProductWelcome, + ProductWallpaper }; + Q_ENUM( ImageEntry ) enum StyleEntry : short { @@ -77,6 +81,7 @@ public: SidebarTextSelect, SidebarTextHighlight }; + Q_ENUM( StyleEntry ) /** @brief Setting for how much the main window may expand. */ enum class WindowExpansion @@ -85,6 +90,7 @@ public: Fullscreen, Fixed }; + Q_ENUM( WindowExpansion ) /** @brief Setting for the main window size. * * The units are pixels (Pixies) or something-based-on-fontsize (Fonties), which @@ -96,6 +102,7 @@ public: Pixies, Fonties }; + Q_ENUM( WindowDimensionUnit ) class WindowDimension : public NamedSuffix< WindowDimensionUnit, WindowDimensionUnit::None > { public: diff --git a/src/modules/partition/core/KPMHelpers.h b/src/modules/partition/core/KPMHelpers.h index bca69d1f6..bb510cafb 100644 --- a/src/modules/partition/core/KPMHelpers.h +++ b/src/modules/partition/core/KPMHelpers.h @@ -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 */ diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index 7823d743d..926df03a3 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.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 * Copyright 2018, Andrius Štikonas * Copyright 2018, Caio Carvalho * @@ -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 ); 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() ); diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index 17ac339e9..1bb7f64fd 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -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 ); diff --git a/src/modules/partition/gui/ReplaceWidget.cpp b/src/modules/partition/gui/ReplaceWidget.cpp index 2ee360ced..3d0711761 100644 --- a/src/modules/partition/gui/ReplaceWidget.cpp +++ b/src/modules/partition/gui/ReplaceWidget.cpp @@ -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; } diff --git a/src/modules/partition/jobs/CreatePartitionJob.cpp b/src/modules/partition/jobs/CreatePartitionJob.cpp index 9f8a01004..0f9590bfd 100644 --- a/src/modules/partition/jobs/CreatePartitionJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionJob.cpp @@ -2,7 +2,7 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2015, Teo Mrnjavac - * Copyright 2017, Adriaan de Groot + * Copyright 2017, 2020, Adriaan de Groot * * 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 #include +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 %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() ); @@ -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() ); } diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index 8b981ce3e..12faaf969 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -2,7 +2,7 @@ * * Copyright 2014, Aurélien Gâteau * Copyright 2015-2016, Teo Mrnjavac - * Copyright 2017, 2019, Adriaan de Groot + * Copyright 2017, 2019-2020, Adriaan de Groot * * 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 #include -typedef QHash 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; + 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 new %2 system partition." ) - .arg( *Calamares::Branding::ShortProductName ) - .arg( fsType ) ); + .arg( *Calamares::Branding::ShortProductName ) + .arg( fsType ) ); + } else + { lines.append( tr( "Set up new %2 partition with mount point " "%1." ) - .arg( mountPoint ) - .arg( fsType ) ); + .arg( mountPoint ) + .arg( fsType ) ); + } } else { if ( mountPoint == "/" ) + { lines.append( tr( "Install %2 on %3 system partition %1." ) - .arg( path ) - .arg( *Calamares::Branding::ShortProductName ) - .arg( fsType ) ); + .arg( path ) + .arg( *Calamares::Branding::ShortProductName ) + .arg( fsType ) ); + } else + { lines.append( tr( "Set up %3 partition %1 with mount point " "%2." ) - .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 %1." ) - .arg( m_bootLoaderPath ) ); + lines.append( tr( "Install boot loader on %1." ).arg( m_bootLoaderPath ) ); } return lines.join( "
" ); } @@ -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; diff --git a/src/modules/partition/jobs/FormatPartitionJob.cpp b/src/modules/partition/jobs/FormatPartitionJob.cpp index 0d43dfdb3..c877343c3 100644 --- a/src/modules/partition/jobs/FormatPartitionJob.cpp +++ b/src/modules/partition/jobs/FormatPartitionJob.cpp @@ -19,6 +19,8 @@ #include "jobs/FormatPartitionJob.h" +#include "core/KPMHelpers.h" + #include "utils/Logger.h" // KPMcore @@ -29,6 +31,9 @@ #include #include +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 %3MiB partition %1 with " "file system %2." ) .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() ) ); } diff --git a/src/modules/partition/jobs/SetPartitionFlagsJob.cpp b/src/modules/partition/jobs/SetPartitionFlagsJob.cpp index d79f70479..09380a24c 100644 --- a/src/modules/partition/jobs/SetPartitionFlagsJob.cpp +++ b/src/modules/partition/jobs/SetPartitionFlagsJob.cpp @@ -21,6 +21,8 @@ #include "SetPartitionFlagsJob.h" +#include "core/KPMHelpers.h" + #include "utils/Logger.h" #include "utils/Units.h" @@ -32,6 +34,8 @@ #include 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 %1." ) .arg( partition()->partitionPath() ); - if ( !partition()->fileSystem().name().isEmpty() ) + QString fsNameForUser = userVisibleFS( partition()->fileSystem() ); + if ( !fsNameForUser.isEmpty() ) return tr( "Clear flags on %1MiB %2 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 %2 partition as " "%3." ) .arg( BytesToMiB( partition()->capacity() ) ) - .arg( partition()->fileSystem().name() ) + .arg( fsNameForUser ) .arg( flagsList.join( ", " ) ); return tr( "Flag new partition as %1." ) @@ -103,10 +110,11 @@ SetPartFlagsJob::prettyStatusMessage() const return tr( "Clearing flags on partition %1." ) .arg( partition()->partitionPath() ); - if ( !partition()->fileSystem().name().isEmpty() ) + QString fsNameForUser = userVisibleFS( partition()->fileSystem() ); + if ( !fsNameForUser.isEmpty() ) return tr( "Clearing flags on %1MiB %2 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 %3 on " "%1MiB %2 partition." ) .arg( BytesToMiB( partition()->capacity() ) ) - .arg( partition()->fileSystem().name() ) + .arg( fsNameForUser ) .arg( flagsList.join( ", " ) ); return tr( "Setting flags %1 on new partition." )