From 92a874dae7ab13587cf7938048ff282a674befc2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 6 Oct 2020 15:44:14 +0200 Subject: [PATCH] [partition] move the swap-choice to Config --- src/modules/partition/core/Config.h | 10 ++++++++-- src/modules/partition/gui/ChoicePage.cpp | 11 ++++------- src/modules/partition/gui/ChoicePage.h | 2 -- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/modules/partition/core/Config.h b/src/modules/partition/core/Config.h index 87e0d4047..23ebdedf8 100644 --- a/src/modules/partition/core/Config.h +++ b/src/modules/partition/core/Config.h @@ -57,8 +57,6 @@ public: void setConfigurationMap( const QVariantMap& ); void updateGlobalStorage() const; - SwapChoiceSet swapChoices() const { return m_swapChoices; } - /** @brief What kind of installation (partitioning) is requested **initially**? * * @return the partitioning choice (may be @c NoChoice) @@ -74,6 +72,14 @@ public: */ InstallChoice installChoice() const { return m_installChoice; } + /** @brief The set of swap choices enabled for this install + * + * Not all swap choices are supported by each distro, so they + * can choose to enable or disable them. This method + * returns a set (hopefully non-empty) of configured swap choices. + */ + SwapChoiceSet swapChoices() const { return m_swapChoices; } + /** @brief What kind of swap selection is requested **initially**? * * @return The swap choice (may be @c NoSwap ) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 9467720db..6501a12f6 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -84,8 +84,6 @@ ChoicePage::ChoicePage( Config* config, QWidget* parent ) , m_beforePartitionLabelsView( nullptr ) , m_bootloaderComboBox( nullptr ) , m_enableEncryptionWidget( true ) - , m_availableSwapChoices( config->swapChoices() ) - , m_eraseSwapChoice( config->initialSwapChoice() ) { setupUi( this ); @@ -247,10 +245,9 @@ ChoicePage::setupChoices() m_replaceButton->addToGroup( m_grp, InstallChoice::Replace ); // Fill up swap options - // .. TODO: only if enabled in the config - if ( m_availableSwapChoices.count() > 1 ) + if ( m_config->swapChoices().count() > 1 ) { - m_eraseSwapChoiceComboBox = createCombo( m_availableSwapChoices, m_eraseSwapChoice ); + m_eraseSwapChoiceComboBox = createCombo( m_config->swapChoices(), m_config->swapChoice() ); m_eraseButton->addOptionsComboBox( m_eraseSwapChoiceComboBox ); } @@ -431,7 +428,7 @@ ChoicePage::onEraseSwapChoiceChanged() { if ( m_eraseSwapChoiceComboBox ) { - m_eraseSwapChoice = static_cast< Config::SwapChoice >( m_eraseSwapChoiceComboBox->currentData().toInt() ); + m_config->setSwapChoice( m_eraseSwapChoiceComboBox->currentData().toInt() ); onActionChanged(); } } @@ -456,7 +453,7 @@ ChoicePage::applyActionChoice( InstallChoice choice ) gs->value( "efiSystemPartition" ).toString(), CalamaresUtils::GiBtoBytes( gs->value( "requiredStorageGiB" ).toDouble() ), - m_eraseSwapChoice }; + m_config->swapChoice() }; if ( m_core->isDirty() ) { diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index d79b56c56..cce91e9cc 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -156,8 +156,6 @@ private: QString m_defaultFsType; bool m_enableEncryptionWidget; - SwapChoiceSet m_availableSwapChoices; // What is available - Config::SwapChoice m_eraseSwapChoice; // what is selected QMutex m_coreMutex; };