Merge branch 'master' of https://github.com/calamares/calamares into development

This commit is contained in:
Philip Müller 2020-02-14 00:22:06 +01:00
commit 039940a131
16 changed files with 215 additions and 109 deletions

View File

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

View File

@ -24,23 +24,16 @@ namespace CalamaresUtils
namespace Locale namespace Locale
{ {
Label::Label() Label::Label( QObject* parent )
: m_locale( QLocale() ) : Label( QString(), LabelFormat::IfNeededWithCountry, parent )
{ {
m_localeId = m_locale.name();
setLabels( QString(), LabelFormat::IfNeededWithCountry );
} }
Label::Label( const QString& locale, LabelFormat format ) Label::Label( const QString& locale, LabelFormat format, QObject* parent )
: m_locale( Label::getLocale( locale ) ) : QObject( parent )
, m_localeId( locale ) , m_locale( Label::getLocale( locale ) )
{ , m_localeId( locale.isEmpty() ? m_locale.name() : locale )
setLabels( locale, format );
}
void
Label::setLabels( const QString& locale, LabelFormat format )
{ {
//: language[name] (country[name]) //: language[name] (country[name])
QString longFormat = QObject::tr( "%1 (%2)" ); QString longFormat = QObject::tr( "%1 (%2)" );
@ -69,6 +62,10 @@ Label::setLabels( const QString& locale, LabelFormat format )
QLocale QLocale
Label::getLocale( const QString& localeName ) Label::getLocale( const QString& localeName )
{ {
if ( localeName.isEmpty() )
{
return QLocale();
}
if ( localeName.contains( "@latin" ) ) if ( localeName.contains( "@latin" ) )
{ {
QLocale loc( localeName ); // Ignores @latin QLocale loc( localeName ); // Ignores @latin

View File

@ -21,6 +21,7 @@
#define LOCALE_LABEL_H #define LOCALE_LABEL_H
#include <QLocale> #include <QLocale>
#include <QObject>
#include <QString> #include <QString>
namespace CalamaresUtils namespace CalamaresUtils
@ -35,8 +36,14 @@ namespace Locale
* translation system) into QLocales, and also into consistent * translation system) into QLocales, and also into consistent
* human-readable text labels. * 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: public:
/** @brief Formatting option for label -- add (country) to label. */ /** @brief Formatting option for label -- add (country) to label. */
enum class LabelFormat enum class LabelFormat
@ -46,7 +53,7 @@ public:
}; };
/** @brief Empty locale. This uses the system-default locale. */ /** @brief Empty locale. This uses the system-default locale. */
Label(); Label( QObject* parent = nullptr );
/** @brief Construct from a locale name. /** @brief Construct from a locale name.
* *
@ -54,7 +61,9 @@ public:
* The @p format determines whether the country name is always present * The @p format determines whether the country name is always present
* in the label (human-readable form) or only if needed for disambiguation. * 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. /** @brief Define a sorting order.
* *
@ -94,8 +103,6 @@ public:
static QLocale getLocale( const QString& localeName ); static QLocale getLocale( const QString& localeName );
protected: protected:
void setLabels( const QString& name, LabelFormat format );
QLocale m_locale; QLocale m_locale;
QString m_localeId; // the locale identifier, e.g. "en_GB" QString m_localeId; // the locale identifier, e.g. "en_GB"
QString m_label; // the native name of the locale QString m_label; // the native name of the locale

View File

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2019, Adriaan de Groot <groot@kde.org> * Copyright 2019-2020 Adriaan de Groot <groot@kde.org>
* Copyright 2019, Camilo Higuita <milo.h@aol.com>
* *
* 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
@ -36,7 +37,7 @@ LabelModel::LabelModel( const QStringList& locales, QObject* parent )
for ( const auto& l : locales ) 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 ) switch ( role )
{ {
case LabelRole: case LabelRole:
return locale.label(); return locale->label();
case EnglishLabelRole: case EnglishLabelRole:
return locale.englishLabel(); return locale->englishLabel();
default: default:
return QVariant(); return QVariant();
} }
} }
QHash< int, QByteArray >
LabelModel::roleNames() const
{
return { { LabelRole, "label" }, { EnglishLabelRole, "englishLabel" } };
}
const Label& const Label&
LabelModel::locale( int row ) const LabelModel::locale( int row ) const
{ {
if ( ( row < 0 ) || ( row >= m_locales.count() ) ) if ( ( row < 0 ) || ( row >= m_locales.count() ) )
{ {
for ( const auto& l : m_locales ) 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 int
@ -93,7 +100,7 @@ LabelModel::find( std::function< bool( const Label& ) > predicate ) const
{ {
for ( int row = 0; row < m_locales.count(); ++row ) for ( int row = 0; row < m_locales.count(); ++row )
{ {
if ( predicate( m_locales[ row ] ) ) if ( predicate( *m_locales[ row ] ) )
{ {
return row; return row;
} }

View File

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> === /* === This file is part of Calamares - <https://github.com/calamares> ===
* *
* Copyright 2019, Adriaan de Groot <groot@kde.org> * Copyright 2019-2020, Adriaan de Groot <groot@kde.org>
* Copyright 2019, Camilo Higuita <milo.h@aol.com>
* *
* 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
@ -33,6 +34,8 @@ namespace Locale
class DLLEXPORT LabelModel : public QAbstractListModel class DLLEXPORT LabelModel : public QAbstractListModel
{ {
Q_OBJECT
public: public:
enum enum
{ {
@ -46,6 +49,7 @@ public:
int rowCount( const QModelIndex& parent ) const override; int rowCount( const QModelIndex& parent ) const override;
QVariant data( const QModelIndex& index, int role ) const override; QVariant data( const QModelIndex& index, int role ) const override;
QHash< int, QByteArray > roleNames() const override;
/** @brief Gets locale information for entry #n /** @brief Gets locale information for entry #n
* *
@ -69,7 +73,7 @@ public:
int find( const QString& countryCode ) const; int find( const QString& countryCode ) const;
private: private:
QVector< Label > m_locales; QVector< Label* > m_locales;
QStringList m_localeIds; QStringList m_localeIds;
}; };

View File

@ -3,6 +3,7 @@
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2019, Adriaan de Groot <groot@kde.org> * Copyright 2017-2019, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Raul Rodrigo Segura (raurodse) * Copyright 2018, Raul Rodrigo Segura (raurodse)
* Copyright 2019, Camilo Higuita <milo.h@aol.com>
* *
* 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
@ -74,7 +75,8 @@ const QStringList Branding::s_imageEntryStrings =
{ {
"productLogo", "productLogo",
"productIcon", "productIcon",
"productWelcome" "productWelcome",
"productWallpaper"
}; };
const QStringList Branding::s_styleEntryStrings = const QStringList Branding::s_styleEntryStrings =

View File

@ -3,6 +3,7 @@
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org> * Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org> * Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Raul Rodrigo Segura (raurodse) * Copyright 2018, Raul Rodrigo Segura (raurodse)
* Copyright 2019, Camilo Higuita <milo.h@aol.com>
* *
* 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
@ -48,7 +49,7 @@ public:
* e.g. *Branding::ProductName to get the string value for * e.g. *Branding::ProductName to get the string value for
* the product name. * the product name.
*/ */
enum StringEntry : short enum StringEntry
{ {
ProductName, ProductName,
Version, Version,
@ -62,13 +63,16 @@ public:
KnownIssuesUrl, KnownIssuesUrl,
ReleaseNotesUrl ReleaseNotesUrl
}; };
Q_ENUM( StringEntry )
enum ImageEntry : short enum ImageEntry : short
{ {
ProductLogo, ProductLogo,
ProductIcon, ProductIcon,
ProductWelcome ProductWelcome,
ProductWallpaper
}; };
Q_ENUM( ImageEntry )
enum StyleEntry : short enum StyleEntry : short
{ {
@ -77,6 +81,7 @@ public:
SidebarTextSelect, SidebarTextSelect,
SidebarTextHighlight SidebarTextHighlight
}; };
Q_ENUM( StyleEntry )
/** @brief Setting for how much the main window may expand. */ /** @brief Setting for how much the main window may expand. */
enum class WindowExpansion enum class WindowExpansion
@ -85,6 +90,7 @@ public:
Fullscreen, Fullscreen,
Fixed Fixed
}; };
Q_ENUM( WindowExpansion )
/** @brief Setting for the main window size. /** @brief Setting for the main window size.
* *
* The units are pixels (Pixies) or something-based-on-fontsize (Fonties), which * The units are pixels (Pixies) or something-based-on-fontsize (Fonties), which
@ -96,6 +102,7 @@ public:
Pixies, Pixies,
Fonties Fonties
}; };
Q_ENUM( WindowDimensionUnit )
class WindowDimension : public NamedSuffix< WindowDimensionUnit, WindowDimensionUnit::None > class WindowDimension : public NamedSuffix< WindowDimensionUnit, WindowDimensionUnit::None >
{ {
public: public:

View File

@ -114,6 +114,31 @@ 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();
}
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 2016, Teo Mrnjavac <teo@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, Andrius Štikonas <andrius@stikonas.eu>
* Copyright 2018, Caio Carvalho <caiojcarvalho@gmail.com> * Copyright 2018, Caio Carvalho <caiojcarvalho@gmail.com>
* *
@ -93,11 +93,17 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
else else
initGptPartitionTypeUi(); initGptPartitionTypeUi();
// File system // File system; the config value is translated (best-effort) to a type
FileSystem::Type defaultFsType = FileSystem::typeForName( FileSystem::Type defaultFSType;
QString untranslatedFSName = PartUtils::findFS(
Calamares::JobQueue::instance()-> Calamares::JobQueue::instance()->
globalStorage()-> globalStorage()->
value( "defaultFileSystemType" ).toString() ); value( "defaultFileSystemType" ).toString(), &defaultFSType );
if ( defaultFSType == FileSystem::Type::Unknown )
{
defaultFSType = FileSystem::Type::Ext4;
}
int defaultFsIndex = -1; int defaultFsIndex = -1;
int fsCounter = 0; int fsCounter = 0;
QStringList fsNames; QStringList fsNames;
@ -106,8 +112,8 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
if ( fs->supportCreate() != FileSystem::cmdSupportNone && if ( fs->supportCreate() != FileSystem::cmdSupportNone &&
fs->type() != FileSystem::Extended ) fs->type() != FileSystem::Extended )
{ {
fsNames << fs->name(); fsNames << KPMHelpers::userVisibleFS( fs ); // This is put into the combobox
if ( fs->type() == defaultFsType ) if ( fs->type() == defaultFSType )
defaultFsIndex = fsCounter; defaultFsIndex = fsCounter;
fsCounter++; fsCounter++;
} }
@ -232,6 +238,7 @@ CreatePartitionDialog::updateMountPointUi()
bool enabled = m_ui->primaryRadioButton->isChecked(); bool enabled = m_ui->primaryRadioButton->isChecked();
if ( enabled ) if ( enabled )
{ {
// This maps translated (user-visible) FS names to a type
FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() ); FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() );
enabled = !s_unmountableFS.contains( type ); enabled = !s_unmountableFS.contains( type );

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 2016, Teo Mrnjavac <teo@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, * Flags handling originally from KDE Partition Manager,
* Copyright 2008-2009, Volker Lanz <vl@fidra.de> * Copyright 2008-2009, Volker Lanz <vl@fidra.de>
@ -22,21 +22,21 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>. * along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <gui/EditExistingPartitionDialog.h> #include "EditExistingPartitionDialog.h"
#include <core/ColorUtils.h> #include "core/ColorUtils.h"
#include <core/PartitionCoreModule.h> #include "core/PartitionCoreModule.h"
#include <core/PartitionInfo.h> #include "core/PartitionInfo.h"
#include "core/PartUtils.h" #include "core/PartUtils.h"
#include <core/KPMHelpers.h> #include "core/KPMHelpers.h"
#include "gui/PartitionDialogHelpers.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 "GlobalStorage.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "utils/Logger.h"
// KPMcore // KPMcore
#include <kpmcore/core/device.h> #include <kpmcore/core/device.h>
@ -77,7 +77,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
m_ui->fileSystemComboBox->setEnabled( doFormat ); m_ui->fileSystemComboBox->setEnabled( doFormat );
if ( !doFormat ) if ( !doFormat )
m_ui->fileSystemComboBox->setCurrentText( m_partition->fileSystem().name() ); m_ui->fileSystemComboBox->setCurrentText( KPMHelpers::userVisibleFS( m_partition->fileSystem() ) );
updateMountPointPicker(); updateMountPointPicker();
} ); } );
@ -93,16 +93,25 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
for ( auto fs : FileSystemFactory::map() ) for ( auto fs : FileSystemFactory::map() )
{ {
if ( fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Extended ) 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 ); m_ui->fileSystemComboBox->addItems( fsNames );
if ( fsNames.contains( m_partition->fileSystem().name() ) ) FileSystem::Type defaultFSType;
m_ui->fileSystemComboBox->setCurrentText( m_partition->fileSystem().name() ); 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 else
m_ui->fileSystemComboBox->setCurrentText( Calamares::JobQueue::instance()-> m_ui->fileSystemComboBox->setCurrentText( FileSystem::nameForType( defaultFSType ) );
globalStorage()->
value( "defaultFileSystemType" ).toString() );
m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() ); m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() );
m_ui->fileSystemComboBox->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 ) else if ( fsType != FileSystem::Unknown )
cWarning() << "Partition-module setting *defaultFileSystemType* changed" << fsRealName; cWarning() << "Partition-module setting *defaultFileSystemType* changed" << fsRealName;
else 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 ); gs->insert( "defaultFileSystemType", fsRealName );

View File

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

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

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

View File

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

View File

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