diff --git a/src/modules/partition/core/Config.cpp b/src/modules/partition/core/Config.cpp index 6b1b59c1b..5099b48e6 100644 --- a/src/modules/partition/core/Config.cpp +++ b/src/modules/partition/core/Config.cpp @@ -19,6 +19,19 @@ Config::Config( QObject* parent ) { } +const NamedEnumTable< Config::InstallChoice >& +Config::installChoiceNames() +{ + static const NamedEnumTable< InstallChoice > names { { QStringLiteral( "none" ), InstallChoice::NoChoice }, + { QStringLiteral( "nochoice" ), InstallChoice::NoChoice }, + { QStringLiteral( "alongside" ), InstallChoice::Alongside }, + { QStringLiteral( "erase" ), InstallChoice::Erase }, + { QStringLiteral( "replace" ), InstallChoice::Replace }, + { QStringLiteral( "manual" ), InstallChoice::Manual } }; + return names; +} + + static PartitionActions::Choices::SwapChoiceSet getSwapChoices( const QVariantMap& configurationMap ) { @@ -109,17 +122,16 @@ getSwapChoices( const QVariantMap& configurationMap ) void Config::setInstallChoice( int c ) { - if ( ( c < PartitionActions::Choices::InstallChoice::NoChoice ) - || ( c > PartitionActions::Choices::InstallChoice::Manual ) ) + if ( ( c < InstallChoice::NoChoice ) || ( c > InstallChoice::Manual ) ) { cWarning() << "Invalid install choice (int)" << c; - c = PartitionActions::Choices::InstallChoice::NoChoice; + c = InstallChoice::NoChoice; } - setInstallChoice( static_cast< PartitionActions::Choices::InstallChoice >( c ) ); + setInstallChoice( static_cast< InstallChoice >( c ) ); } void -Config::setInstallChoice( PartitionActions::Choices::InstallChoice c ) +Config::setInstallChoice( InstallChoice c ) { if ( c != m_installChoice ) { @@ -137,7 +149,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) m_swapChoices = getSwapChoices( configurationMap ); bool nameFound = false; // In the name table (ignored, falls back to first entry in table) - m_initialInstallChoice = PartitionActions::Choices::installChoiceNames().find( + m_initialInstallChoice = Config::installChoiceNames().find( CalamaresUtils::getString( configurationMap, "initialPartitioningChoice" ), nameFound ); setInstallChoice( m_initialInstallChoice ); diff --git a/src/modules/partition/core/Config.h b/src/modules/partition/core/Config.h index 8869ad9be..00f81b897 100644 --- a/src/modules/partition/core/Config.h +++ b/src/modules/partition/core/Config.h @@ -18,17 +18,27 @@ class Config : public QObject { Q_OBJECT - -public: - Config( QObject* parent ); - virtual ~Config() = default; - /** @brief The installation choice (Erase, Alongside, ...) * * This is an int because exposing the enum values is slightly complicated * by the source layout. */ - Q_PROPERTY( int installChoice READ installChoice WRITE setInstallChoice NOTIFY installChoiceChanged ) + Q_PROPERTY( InstallChoice installChoice READ installChoice WRITE setInstallChoice NOTIFY installChoiceChanged ) + +public: + Config( QObject* parent ); + virtual ~Config() = default; + + enum InstallChoice + { + NoChoice, + Alongside, + Erase, + Replace, + Manual + }; + Q_ENUM( InstallChoice ) + static const NamedEnumTable< InstallChoice >& installChoiceNames(); void setConfigurationMap( const QVariantMap& ); void updateGlobalStorage() const; @@ -39,7 +49,7 @@ public: * * @return the partitioning choice (may be @c NoChoice) */ - PartitionActions::Choices::InstallChoice initialInstallChoice() const { return m_initialInstallChoice; } + InstallChoice initialInstallChoice() const { return m_initialInstallChoice; } /** @brief What kind of installation (partition) is requested **now**? * @@ -48,7 +58,7 @@ public: * * @return the partitioning choice (may be @c NoChoice) */ - PartitionActions::Choices::InstallChoice installChoice() const { return m_installChoice; } + InstallChoice installChoice() const { return m_installChoice; } /** @brief What kind of swap selection is requested **initially**? @@ -59,16 +69,16 @@ public: public Q_SLOTS: void setInstallChoice( int ); - void setInstallChoice( PartitionActions::Choices::InstallChoice ); + void setInstallChoice( InstallChoice ); Q_SIGNALS: - void installChoiceChanged( PartitionActions::Choices::InstallChoice ); + void installChoiceChanged( InstallChoice ); private: PartitionActions::Choices::SwapChoice m_initialSwapChoice; PartitionActions::Choices::SwapChoiceSet m_swapChoices; - PartitionActions::Choices::InstallChoice m_initialInstallChoice = PartitionActions::Choices::NoChoice; - PartitionActions::Choices::InstallChoice m_installChoice = PartitionActions::Choices::NoChoice; + InstallChoice m_initialInstallChoice = NoChoice; + InstallChoice m_installChoice = NoChoice; qreal m_requiredStorageGiB = 0.0; // May duplicate setting in the welcome module }; diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index 748df2d95..168c3804a 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -279,19 +279,6 @@ pickOne( const SwapChoiceSet& s ) return *( s.begin() ); } -const NamedEnumTable< InstallChoice >& -installChoiceNames() -{ - static const NamedEnumTable< InstallChoice > names { { QStringLiteral( "none" ), InstallChoice::NoChoice }, - { QStringLiteral( "nochoice" ), InstallChoice::NoChoice }, - { QStringLiteral( "alongside" ), InstallChoice::Alongside }, - { QStringLiteral( "erase" ), InstallChoice::Erase }, - { QStringLiteral( "replace" ), InstallChoice::Replace }, - { QStringLiteral( "manual" ), InstallChoice::Manual } }; - return names; -} - - } // namespace Choices } // namespace PartitionActions diff --git a/src/modules/partition/core/PartitionActions.h b/src/modules/partition/core/PartitionActions.h index d86e51048..12b0f682e 100644 --- a/src/modules/partition/core/PartitionActions.h +++ b/src/modules/partition/core/PartitionActions.h @@ -47,16 +47,6 @@ const NamedEnumTable< SwapChoice >& swapChoiceNames(); */ SwapChoice pickOne( const SwapChoiceSet& s ); -enum InstallChoice -{ - NoChoice, - Alongside, - Erase, - Replace, - Manual -}; -const NamedEnumTable< InstallChoice >& installChoiceNames(); - struct ReplacePartitionOptions { QString defaultFsType; // e.g. "ext4" or "btrfs" diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 653df9c3b..d2c5ad81f 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -561,7 +561,7 @@ PartitionCoreModule::setPartitionFlags( Device* device, Partition* partition, Pa } Calamares::JobList -PartitionCoreModule::jobs() const +PartitionCoreModule::jobs( const Config* config ) const { Calamares::JobList lst; QList< Device* > devices; @@ -592,7 +592,7 @@ PartitionCoreModule::jobs() const lst << info->jobs(); devices << info->device.data(); } - lst << Calamares::job_ptr( new FillGlobalStorageJob( devices, m_bootLoaderInstallPath ) ); + lst << Calamares::job_ptr( new FillGlobalStorageJob( config, devices, m_bootLoaderInstallPath ) ); return lst; } diff --git a/src/modules/partition/core/PartitionCoreModule.h b/src/modules/partition/core/PartitionCoreModule.h index a51dd0d2d..1dc61db6f 100644 --- a/src/modules/partition/core/PartitionCoreModule.h +++ b/src/modules/partition/core/PartitionCoreModule.h @@ -32,6 +32,7 @@ #include class BootLoaderModel; +class Config; class CreatePartitionJob; class Device; class DeviceModel; @@ -171,7 +172,7 @@ public: * requested by the user. * @return a list of jobs. */ - Calamares::JobList jobs() const; + Calamares::JobList jobs( const Config* ) const; bool hasRootMountPoint() const; diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 1d5f3ea25..ccdd50251 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -59,6 +59,7 @@ using Calamares::PrettyRadioButton; using CalamaresUtils::Partition::findPartitionByPath; using CalamaresUtils::Partition::isPartitionFreeSpace; using CalamaresUtils::Partition::PartitionIterator; +using InstallChoice = Config::InstallChoice; using PartitionActions::Choices::SwapChoice; /** @@ -439,10 +440,10 @@ ChoicePage::onEraseSwapChoiceChanged() } void -ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice ) +ChoicePage::applyActionChoice( InstallChoice choice ) { cDebug() << "Prev" << m_lastSelectedActionIndex << "InstallChoice" << choice - << PartitionActions::Choices::installChoiceNames().find( choice ); + << Config::installChoiceNames().find( choice ); m_beforePartitionBarsView->selectionModel()->disconnect( SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ) ); m_beforePartitionBarsView->selectionModel()->clearSelection(); m_beforePartitionBarsView->selectionModel()->clearCurrentIndex(); @@ -925,7 +926,7 @@ ChoicePage::updateDeviceStatePreview() * @param choice the chosen partitioning action. */ void -ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice ) +ChoicePage::updateActionChoicePreview( InstallChoice choice ) { Device* currentDevice = selectedDevice(); Q_ASSERT( currentDevice ); diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 4a967f91c..5c20d817a 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -15,8 +15,9 @@ #include "ui_ChoicePage.h" +#include "core/Config.h" #include "core/OsproberEntry.h" -#include "core/PartitionActions.h" +// #include "core/PartitionActions.h" #include #include @@ -53,8 +54,6 @@ class ChoicePage : public QWidget, private Ui::ChoicePage { Q_OBJECT public: - using InstallChoice = PartitionActions::Choices::InstallChoice; - explicit ChoicePage( Config* config, QWidget* parent = nullptr ); virtual ~ChoicePage(); @@ -81,7 +80,7 @@ public: * @brief applyActionChoice reacts to a choice of partitioning mode. * @param choice the partitioning action choice. */ - void applyActionChoice( ChoicePage::InstallChoice choice ); + void applyActionChoice( Config::InstallChoice choice ); int lastSelectedDeviceIndex(); void setLastSelectedDeviceIndex( int index ); @@ -107,7 +106,7 @@ private: bool calculateNextEnabled() const; void updateNextEnabled(); void setupChoices(); - void checkInstallChoiceRadioButton( ChoicePage::InstallChoice choice ); ///< Sets the chosen button to "on" + void checkInstallChoiceRadioButton( Config::InstallChoice choice ); ///< Sets the chosen button to "on" QComboBox* createBootloaderComboBox( QWidget* parentButton ); Device* selectedDevice(); @@ -117,7 +116,7 @@ private: void continueApplyDeviceChoice(); // .. called after scan void updateDeviceStatePreview(); - void updateActionChoicePreview( ChoicePage::InstallChoice choice ); + void updateActionChoicePreview( Config::InstallChoice choice ); void setupActions(); OsproberEntryList getOsproberEntriesForDevice( Device* device ) const; void doAlongsideApply(); diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index 996c1601c..946e567f7 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -140,7 +140,7 @@ PartitionViewStep::createSummaryWidget() const widget->setLayout( mainLayout ); mainLayout->setMargin( 0 ); - ChoicePage::InstallChoice choice = m_config->installChoice(); + Config::InstallChoice choice = m_config->installChoice(); QFormLayout* formLayout = new QFormLayout( widget ); const int MARGIN = CalamaresUtils::defaultFontHeight() / 2; @@ -158,18 +158,18 @@ PartitionViewStep::createSummaryWidget() const QString modeText; switch ( choice ) { - case ChoicePage::InstallChoice::Alongside: + case Config::InstallChoice::Alongside: modeText = tr( "Install %1 alongside another operating system." ) .arg( branding->shortVersionedName() ); break; - case ChoicePage::InstallChoice::Erase: + case Config::InstallChoice::Erase: modeText = tr( "Erase disk and install %1." ).arg( branding->shortVersionedName() ); break; - case ChoicePage::InstallChoice::Replace: + case Config::InstallChoice::Replace: modeText = tr( "Replace a partition with %1." ).arg( branding->shortVersionedName() ); break; - case ChoicePage::InstallChoice::NoChoice: - case ChoicePage::InstallChoice::Manual: + case Config::InstallChoice::NoChoice: + case Config::InstallChoice::Manual: modeText = tr( "Manual partitioning." ); } modeLabel->setText( modeText ); @@ -182,27 +182,27 @@ PartitionViewStep::createSummaryWidget() const QString modeText; switch ( choice ) { - case ChoicePage::InstallChoice::Alongside: + case Config::InstallChoice::Alongside: modeText = tr( "Install %1 alongside another operating system on disk " "%2 (%3)." ) .arg( branding->shortVersionedName() ) .arg( info.deviceNode ) .arg( info.deviceName ); break; - case ChoicePage::InstallChoice::Erase: + case Config::InstallChoice::Erase: modeText = tr( "Erase disk %2 (%3) and install %1." ) .arg( branding->shortVersionedName() ) .arg( info.deviceNode ) .arg( info.deviceName ); break; - case ChoicePage::InstallChoice::Replace: + case Config::InstallChoice::Replace: modeText = tr( "Replace a partition on disk %2 (%3) with %1." ) .arg( branding->shortVersionedName() ) .arg( info.deviceNode ) .arg( info.deviceName ); break; - case ChoicePage::InstallChoice::NoChoice: - case ChoicePage::InstallChoice::Manual: + case Config::InstallChoice::NoChoice: + case Config::InstallChoice::Manual: modeText = tr( "Manual partitioning on disk %1 (%2)." ) .arg( info.deviceNode ) .arg( info.deviceName ); @@ -286,7 +286,7 @@ PartitionViewStep::next() { if ( m_choicePage == m_widget->currentWidget() ) { - if ( m_config->installChoice() == ChoicePage::InstallChoice::Manual ) + if ( m_config->installChoice() == Config::InstallChoice::Manual ) { if ( !m_manualPartitionPage ) { @@ -369,8 +369,8 @@ PartitionViewStep::isAtEnd() const if ( m_widget->currentWidget() == m_choicePage ) { auto choice = m_config->installChoice(); - if ( ChoicePage::InstallChoice::Erase == choice || ChoicePage::InstallChoice::Replace == choice - || ChoicePage::InstallChoice::Alongside == choice ) + if ( Config::InstallChoice::Erase == choice || Config::InstallChoice::Replace == choice + || Config::InstallChoice::Alongside == choice ) { return true; } @@ -386,10 +386,9 @@ PartitionViewStep::onActivate() m_config->updateGlobalStorage(); // if we're coming back to PVS from the next VS - if ( m_widget->currentWidget() == m_choicePage - && m_config->installChoice() == ChoicePage::InstallChoice::Alongside ) + if ( m_widget->currentWidget() == m_choicePage && m_config->installChoice() == Config::InstallChoice::Alongside ) { - m_choicePage->applyActionChoice( ChoicePage::InstallChoice::Alongside ); + m_choicePage->applyActionChoice( Config::InstallChoice::Alongside ); // m_choicePage->reset(); //FIXME: ReplaceWidget should be reset maybe? } @@ -605,7 +604,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap ) Calamares::JobList PartitionViewStep::jobs() const { - return m_core->jobs(); + return m_core->jobs( m_config ); } Calamares::RequirementsList diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index f26b70a97..8e7958e83 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -126,7 +126,7 @@ mapForPartition( Partition* partition, const QString& uuid ) return map; } -FillGlobalStorageJob::FillGlobalStorageJob( QList< Device* > devices, const QString& bootLoaderPath ) +FillGlobalStorageJob::FillGlobalStorageJob( const Config*, QList< Device* > devices, const QString& bootLoaderPath ) : m_devices( devices ) , m_bootLoaderPath( bootLoaderPath ) { diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.h b/src/modules/partition/jobs/FillGlobalStorageJob.h index c1256de12..039fb18d8 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.h +++ b/src/modules/partition/jobs/FillGlobalStorageJob.h @@ -16,6 +16,7 @@ #include #include +class Config; class Device; class Partition; @@ -30,7 +31,8 @@ class FillGlobalStorageJob : public Calamares::Job { Q_OBJECT public: - FillGlobalStorageJob( QList< Device* > devices, const QString& bootLoaderPath ); + FillGlobalStorageJob( const Config* config, QList< Device* > devices, const QString& bootLoaderPath ); + QString prettyName() const override; QString prettyDescription() const override; QString prettyStatusMessage() const override;