[partition] Add swap choice to config object

main
Adriaan de Groot 4 years ago
parent 0f4fe6294c
commit f79fbd4105

@ -171,6 +171,26 @@ Config::setInstallChoice( InstallChoice c )
}
}
void
Config::setSwapChoice( int c )
{
if ( ( c < SwapChoice::NoSwap ) || ( c > SwapChoice::SwapFile ) )
{
cWarning() << "Instalid swap choice (int)" << c;
c = SwapChoice::NoSwap;
}
setSwapChoice( static_cast< SwapChoice >( c ) );
}
void
Config::setSwapChoice( Config::SwapChoice c )
{
if ( c != m_swapChoice )
{
m_swapChoice = c;
emit swapChoiceChanged( c );
}
}
void
Config::setConfigurationMap( const QVariantMap& configurationMap )
@ -191,6 +211,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
cWarning() << "Configuration for *initialSwapChoice* is not one of the *userSwapChoices*";
m_initialSwapChoice = pickOne( m_swapChoices );
}
setSwapChoice( m_initialSwapChoice );
}
void

@ -18,13 +18,12 @@
class Config : public QObject
{
Q_OBJECT
/** @brief The installation choice (Erase, Alongside, ...)
*
* This is an int because exposing the enum values is slightly complicated
* by the source layout.
*/
///@brief The installation choice (Erase, Alongside, ...)
Q_PROPERTY( InstallChoice installChoice READ installChoice WRITE setInstallChoice NOTIFY installChoiceChanged )
///@brief The swap choice (None, Small, Hibernate, ...) which only makes sense when Erase is chosen
Q_PROPERTY( SwapChoice swapChoice READ swapChoice WRITE setSwapChoice NOTIFY swapChoiceChanged )
public:
Config( QObject* parent );
virtual ~Config() = default;
@ -73,23 +72,34 @@ public:
*/
InstallChoice installChoice() const { return m_installChoice; }
/** @brief What kind of swap selection is requested **initially**?
*
* @return The swap choice (may be @c NoSwap )
*/
SwapChoice initialSwapChoice() const { return m_initialSwapChoice; }
/** @brief What kind of swap selection is requested **now**?
*
* A choice of swap only makes sense when install choice Erase is made.
*
* @return The swap choice (may be @c NoSwap).
*/
SwapChoice swapChoice() const { return m_swapChoice; }
public Q_SLOTS:
void setInstallChoice( int );
void setInstallChoice( int ); ///< Translates a button ID or so to InstallChoice
void setInstallChoice( InstallChoice );
void setSwapChoice( int ); ///< Translates a button ID or so to SwapChoice
void setSwapChoice( SwapChoice );
Q_SIGNALS:
void installChoiceChanged( InstallChoice );
void swapChoiceChanged( SwapChoice );
private:
SwapChoice m_initialSwapChoice;
SwapChoiceSet m_swapChoices;
SwapChoice m_initialSwapChoice = NoSwap;
SwapChoice m_swapChoice = NoSwap;
InstallChoice m_initialInstallChoice = NoChoice;
InstallChoice m_installChoice = NoChoice;
qreal m_requiredStorageGiB = 0.0; // May duplicate setting in the welcome module

Loading…
Cancel
Save