[partition] Add InitialInstallChoice to Config

- add an option to select what button should be selected when the
  partitioning module is started; TODO: the actual functionality is
  **not** implemented.
- drop the previously suggested name, which didn't get beyond the
  comments-in-the-config-file stage (but which intended to do the
  same things as this one)
- add option to schema already, even if it's not implemented.

See #1297

FIXUP conf
This commit is contained in:
Adriaan de Groot 2020-07-30 11:36:59 +02:00
parent 380e2b3613
commit e21a2f0676
6 changed files with 58 additions and 21 deletions

View File

@ -123,6 +123,9 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
// Settings that overlap with the Welcome module
m_requiredStorageGiB = CalamaresUtils::getDouble( configurationMap, "requiredStorage", -1.0 );
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( CalamaresUtils::getString( configurationMap, "initialPartitioningChoice" ), nameFound );
}
void

View File

@ -38,8 +38,16 @@ public:
PartitionActions::Choices::SwapChoiceSet swapChoices() const { return m_swapChoices; }
/**
* @brief What kind of installation (partitioning) is requested **initially**?
*
* @return the partitioning choice (may by @c NoChoice)
*/
PartitionActions::Choices::InstallChoice initialInstallChoice() const { return m_initialInstallChoice; }
private:
PartitionActions::Choices::SwapChoiceSet m_swapChoices;
PartitionActions::Choices::InstallChoice m_initialInstallChoice = PartitionActions::Choices::NoChoice;
qreal m_requiredStorageGiB = 0.0; // May duplicate setting in the welcome module
};

View File

@ -288,6 +288,19 @@ 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

View File

@ -46,7 +46,6 @@ enum SwapChoice
SwapFile // use a file (if supported)
};
using SwapChoiceSet = QSet< SwapChoice >;
const NamedEnumTable< SwapChoice >& swapChoiceNames();
/** @brief Given a set of swap choices, return a sensible value from it.
@ -57,6 +56,16 @@ 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"

View File

@ -39,16 +39,6 @@ userSwapChoices:
# - reuse # Re-use existing swap, but don't create any (unsupported right now)
# - file # To swap file instead of partition (unsupported right now)
# By default, when the user arrives at the partitioning page, no action
# is selected (out of erase, reuse, ...). You can explicitly set None
# here to select no action on arrival, **or** pick one of these
# actions and that will be selected if it is available. If it isn't
# available on arrival, no action will be selected.
# - erase
# - replace
# - alongside
userDefaultAction: None
# LEGACY SETTINGS (these will generate a warning)
# ensureSuspendToDisk: true
# neverCreateSwap: false
@ -59,6 +49,29 @@ drawNestedPartitions: false
# Show/hide partition labels on manual partitioning page.
alwaysShowPartitionLabels: true
# Allow manual partitioning.
#
# When set to false, this option hides the "Manual partitioning" button,
# limiting the user's choice to "Erase", "Replace" or "Alongside".
# This can be useful when using a custom partition layout we don't want
# the user to modify.
#
# If nothing is specified, manual partitioning is enabled.
#allowManualPartitioning: true
# Initial selection on the Choice page
#
# There are four radio buttons (in principle: erase, replace, alongside, manual),
# and you can pick which of them, if any, is initially selected. For most
# installers, "none" is the right choice: it makes the user pick something specific,
# rather than accidentally being able to click past an important choice (in particular,
# "erase" is a dangerous choice).
#
# The default is "none"
#
# TODO: this isn't implemented
# initialPartitioningChoice: none
# Default filesystem type, used when a "new" partition is made.
#
# When replacing a partition, the existing filesystem inside the
@ -96,16 +109,6 @@ defaultFileSystemType: "ext4"
# If nothing is specified, LUKS is enabled in automated modes.
#enableLuksAutomatedPartitioning: true
# Allow manual partitioning.
#
# When set to false, this option hides the "Manual partitioning" button,
# limiting the user's choice to "Erase", "Replace" or "Alongside".
# This can be useful when using a custom partition layout we don't want
# the user to modify.
#
# If nothing is specified, manual partitioning is enabled.
#allowManualPartitioning: true
# To apply a custom partition layout, it has to be defined this way :
#
# partitionLayout:

View File

@ -19,6 +19,7 @@ properties:
enableLuksAutomatedPartitioning: { type: boolean, default: false }
allowManualPartitioning: { type: boolean, default: true }
partitionLayout: { type: array } # TODO: specify items
initialPartitioningChoice: { type: string, enum: [ none, erase, replace, alongside, manual ] }
requiredStorage: { type: number }
required: