From e21a2f0676a7dfa17ca31be89545760c4cdd8273 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 30 Jul 2020 11:36:59 +0200 Subject: [PATCH] [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 --- src/modules/partition/core/Config.cpp | 3 ++ src/modules/partition/core/Config.h | 8 ++++ .../partition/core/PartitionActions.cpp | 13 ++++++ src/modules/partition/core/PartitionActions.h | 11 ++++- src/modules/partition/partition.conf | 43 ++++++++++--------- src/modules/partition/partition.schema.yaml | 1 + 6 files changed, 58 insertions(+), 21 deletions(-) diff --git a/src/modules/partition/core/Config.cpp b/src/modules/partition/core/Config.cpp index 7af004942..086d87da5 100644 --- a/src/modules/partition/core/Config.cpp +++ b/src/modules/partition/core/Config.cpp @@ -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 diff --git a/src/modules/partition/core/Config.h b/src/modules/partition/core/Config.h index f6823e640..fb2f8116c 100644 --- a/src/modules/partition/core/Config.h +++ b/src/modules/partition/core/Config.h @@ -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 }; diff --git a/src/modules/partition/core/PartitionActions.cpp b/src/modules/partition/core/PartitionActions.cpp index dc4d4eeb4..cae5025bf 100644 --- a/src/modules/partition/core/PartitionActions.cpp +++ b/src/modules/partition/core/PartitionActions.cpp @@ -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 diff --git a/src/modules/partition/core/PartitionActions.h b/src/modules/partition/core/PartitionActions.h index 706fbaea3..6f4b41cc8 100644 --- a/src/modules/partition/core/PartitionActions.h +++ b/src/modules/partition/core/PartitionActions.h @@ -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" diff --git a/src/modules/partition/partition.conf b/src/modules/partition/partition.conf index 5413c10f1..363ef7db1 100644 --- a/src/modules/partition/partition.conf +++ b/src/modules/partition/partition.conf @@ -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: diff --git a/src/modules/partition/partition.schema.yaml b/src/modules/partition/partition.schema.yaml index d08f4a6cd..157f416d7 100644 --- a/src/modules/partition/partition.schema.yaml +++ b/src/modules/partition/partition.schema.yaml @@ -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: