2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2020-04-17 00:24:32 +02:00
|
|
|
*
|
2020-07-30 10:26:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2020-04-17 00:24:32 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2020-04-17 00:24:32 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PARTITION_CONFIG_H
|
|
|
|
#define PARTITION_CONFIG_H
|
|
|
|
|
2020-10-02 12:22:53 +02:00
|
|
|
#include "utils/NamedEnum.h"
|
2020-04-17 00:24:32 +02:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSet>
|
|
|
|
|
|
|
|
class Config : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2020-10-02 12:40:13 +02:00
|
|
|
///@brief The installation choice (Erase, Alongside, ...)
|
2020-10-02 12:08:42 +02:00
|
|
|
Q_PROPERTY( InstallChoice installChoice READ installChoice WRITE setInstallChoice NOTIFY installChoiceChanged )
|
|
|
|
|
2020-10-02 12:40:13 +02:00
|
|
|
///@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 )
|
|
|
|
|
2020-10-02 12:08:42 +02:00
|
|
|
public:
|
|
|
|
Config( QObject* parent );
|
|
|
|
virtual ~Config() = default;
|
|
|
|
|
|
|
|
enum InstallChoice
|
|
|
|
{
|
|
|
|
NoChoice,
|
|
|
|
Alongside,
|
|
|
|
Erase,
|
|
|
|
Replace,
|
|
|
|
Manual
|
|
|
|
};
|
|
|
|
Q_ENUM( InstallChoice )
|
|
|
|
static const NamedEnumTable< InstallChoice >& installChoiceNames();
|
2020-09-29 14:00:49 +02:00
|
|
|
|
2020-10-02 12:22:53 +02:00
|
|
|
/** @brief Choice of swap (size and type) */
|
|
|
|
enum SwapChoice
|
|
|
|
{
|
|
|
|
NoSwap, // don't create any swap, don't use any
|
|
|
|
ReuseSwap, // don't create, but do use existing
|
|
|
|
SmallSwap, // up to 8GiB of swap
|
|
|
|
FullSwap, // ensureSuspendToDisk -- at least RAM size
|
|
|
|
SwapFile // use a file (if supported)
|
|
|
|
};
|
|
|
|
Q_ENUM( SwapChoice )
|
|
|
|
static const NamedEnumTable< SwapChoice >& swapChoiceNames();
|
|
|
|
using SwapChoiceSet = QSet< SwapChoice >;
|
|
|
|
|
2020-05-18 13:07:12 +02:00
|
|
|
void setConfigurationMap( const QVariantMap& );
|
|
|
|
void updateGlobalStorage() const;
|
2020-04-17 00:24:32 +02:00
|
|
|
|
2020-10-02 12:22:53 +02:00
|
|
|
SwapChoiceSet swapChoices() const { return m_swapChoices; }
|
2020-07-30 10:26:58 +02:00
|
|
|
|
2020-09-28 15:32:47 +02:00
|
|
|
/** @brief What kind of installation (partitioning) is requested **initially**?
|
2020-07-30 11:36:59 +02:00
|
|
|
*
|
2020-09-28 15:32:47 +02:00
|
|
|
* @return the partitioning choice (may be @c NoChoice)
|
2020-07-30 11:36:59 +02:00
|
|
|
*/
|
2020-10-02 12:08:42 +02:00
|
|
|
InstallChoice initialInstallChoice() const { return m_initialInstallChoice; }
|
2020-07-30 11:36:59 +02:00
|
|
|
|
2020-09-29 14:00:49 +02:00
|
|
|
/** @brief What kind of installation (partition) is requested **now**?
|
|
|
|
*
|
|
|
|
* This changes depending on what the user selects (unlike the initial choice,
|
|
|
|
* which is fixed by the configuration).
|
|
|
|
*
|
|
|
|
* @return the partitioning choice (may be @c NoChoice)
|
|
|
|
*/
|
2020-10-02 12:08:42 +02:00
|
|
|
InstallChoice installChoice() const { return m_installChoice; }
|
2020-09-29 14:00:49 +02:00
|
|
|
|
2020-09-28 15:32:47 +02:00
|
|
|
/** @brief What kind of swap selection is requested **initially**?
|
|
|
|
*
|
|
|
|
* @return The swap choice (may be @c NoSwap )
|
|
|
|
*/
|
2020-10-02 12:22:53 +02:00
|
|
|
SwapChoice initialSwapChoice() const { return m_initialSwapChoice; }
|
2020-09-28 15:32:47 +02:00
|
|
|
|
2020-10-02 12:40:13 +02:00
|
|
|
/** @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; }
|
|
|
|
|
2020-09-29 14:00:49 +02:00
|
|
|
public Q_SLOTS:
|
2020-10-02 12:40:13 +02:00
|
|
|
void setInstallChoice( int ); ///< Translates a button ID or so to InstallChoice
|
2020-10-02 12:08:42 +02:00
|
|
|
void setInstallChoice( InstallChoice );
|
2020-10-02 12:40:13 +02:00
|
|
|
void setSwapChoice( int ); ///< Translates a button ID or so to SwapChoice
|
|
|
|
void setSwapChoice( SwapChoice );
|
2020-09-29 14:00:49 +02:00
|
|
|
|
|
|
|
Q_SIGNALS:
|
2020-10-02 12:08:42 +02:00
|
|
|
void installChoiceChanged( InstallChoice );
|
2020-10-02 12:40:13 +02:00
|
|
|
void swapChoiceChanged( SwapChoice );
|
2020-09-29 14:00:49 +02:00
|
|
|
|
2020-05-18 13:07:12 +02:00
|
|
|
private:
|
2020-10-02 12:22:53 +02:00
|
|
|
SwapChoiceSet m_swapChoices;
|
2020-10-02 12:40:13 +02:00
|
|
|
SwapChoice m_initialSwapChoice = NoSwap;
|
|
|
|
SwapChoice m_swapChoice = NoSwap;
|
2020-10-02 12:08:42 +02:00
|
|
|
InstallChoice m_initialInstallChoice = NoChoice;
|
|
|
|
InstallChoice m_installChoice = NoChoice;
|
2020-04-17 00:24:32 +02:00
|
|
|
qreal m_requiredStorageGiB = 0.0; // May duplicate setting in the welcome module
|
|
|
|
};
|
|
|
|
|
2020-10-02 12:22:53 +02:00
|
|
|
/** @brief Given a set of swap choices, return a sensible value from it.
|
|
|
|
*
|
|
|
|
* "Sensible" here means: if there is one value, use it; otherwise, use
|
|
|
|
* NoSwap if there are no choices, or if NoSwap is one of the choices, in the set.
|
|
|
|
* If that's not possible, any value from the set.
|
|
|
|
*/
|
|
|
|
Config::SwapChoice pickOne( const Config::SwapChoiceSet& s );
|
|
|
|
|
2020-04-17 00:24:32 +02:00
|
|
|
|
|
|
|
#endif
|