[partition] Migrate InstallChoice to the Config object
This commit is contained in:
parent
010526ee2a
commit
881661e94b
@ -19,6 +19,19 @@ Config::Config( QObject* parent )
|
||||
{
|
||||
}
|
||||
|
||||
const NamedEnumTable< Config::InstallChoice >&
|
||||
Config::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;
|
||||
}
|
||||
|
||||
|
||||
static PartitionActions::Choices::SwapChoiceSet
|
||||
getSwapChoices( const QVariantMap& configurationMap )
|
||||
{
|
||||
@ -109,17 +122,16 @@ getSwapChoices( const QVariantMap& configurationMap )
|
||||
void
|
||||
Config::setInstallChoice( int c )
|
||||
{
|
||||
if ( ( c < PartitionActions::Choices::InstallChoice::NoChoice )
|
||||
|| ( c > PartitionActions::Choices::InstallChoice::Manual ) )
|
||||
if ( ( c < InstallChoice::NoChoice ) || ( c > InstallChoice::Manual ) )
|
||||
{
|
||||
cWarning() << "Invalid install choice (int)" << c;
|
||||
c = PartitionActions::Choices::InstallChoice::NoChoice;
|
||||
c = InstallChoice::NoChoice;
|
||||
}
|
||||
setInstallChoice( static_cast< PartitionActions::Choices::InstallChoice >( c ) );
|
||||
setInstallChoice( static_cast< InstallChoice >( c ) );
|
||||
}
|
||||
|
||||
void
|
||||
Config::setInstallChoice( PartitionActions::Choices::InstallChoice c )
|
||||
Config::setInstallChoice( InstallChoice c )
|
||||
{
|
||||
if ( c != m_installChoice )
|
||||
{
|
||||
@ -137,7 +149,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
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(
|
||||
m_initialInstallChoice = Config::installChoiceNames().find(
|
||||
CalamaresUtils::getString( configurationMap, "initialPartitioningChoice" ), nameFound );
|
||||
setInstallChoice( m_initialInstallChoice );
|
||||
|
||||
|
@ -18,17 +18,27 @@
|
||||
class Config : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Config( QObject* parent );
|
||||
virtual ~Config() = default;
|
||||
|
||||
/** @brief The installation choice (Erase, Alongside, ...)
|
||||
*
|
||||
* This is an int because exposing the enum values is slightly complicated
|
||||
* by the source layout.
|
||||
*/
|
||||
Q_PROPERTY( int installChoice READ installChoice WRITE setInstallChoice NOTIFY installChoiceChanged )
|
||||
Q_PROPERTY( InstallChoice installChoice READ installChoice WRITE setInstallChoice NOTIFY installChoiceChanged )
|
||||
|
||||
public:
|
||||
Config( QObject* parent );
|
||||
virtual ~Config() = default;
|
||||
|
||||
enum InstallChoice
|
||||
{
|
||||
NoChoice,
|
||||
Alongside,
|
||||
Erase,
|
||||
Replace,
|
||||
Manual
|
||||
};
|
||||
Q_ENUM( InstallChoice )
|
||||
static const NamedEnumTable< InstallChoice >& installChoiceNames();
|
||||
|
||||
void setConfigurationMap( const QVariantMap& );
|
||||
void updateGlobalStorage() const;
|
||||
@ -39,7 +49,7 @@ public:
|
||||
*
|
||||
* @return the partitioning choice (may be @c NoChoice)
|
||||
*/
|
||||
PartitionActions::Choices::InstallChoice initialInstallChoice() const { return m_initialInstallChoice; }
|
||||
InstallChoice initialInstallChoice() const { return m_initialInstallChoice; }
|
||||
|
||||
/** @brief What kind of installation (partition) is requested **now**?
|
||||
*
|
||||
@ -48,7 +58,7 @@ public:
|
||||
*
|
||||
* @return the partitioning choice (may be @c NoChoice)
|
||||
*/
|
||||
PartitionActions::Choices::InstallChoice installChoice() const { return m_installChoice; }
|
||||
InstallChoice installChoice() const { return m_installChoice; }
|
||||
|
||||
|
||||
/** @brief What kind of swap selection is requested **initially**?
|
||||
@ -59,16 +69,16 @@ public:
|
||||
|
||||
public Q_SLOTS:
|
||||
void setInstallChoice( int );
|
||||
void setInstallChoice( PartitionActions::Choices::InstallChoice );
|
||||
void setInstallChoice( InstallChoice );
|
||||
|
||||
Q_SIGNALS:
|
||||
void installChoiceChanged( PartitionActions::Choices::InstallChoice );
|
||||
void installChoiceChanged( InstallChoice );
|
||||
|
||||
private:
|
||||
PartitionActions::Choices::SwapChoice m_initialSwapChoice;
|
||||
PartitionActions::Choices::SwapChoiceSet m_swapChoices;
|
||||
PartitionActions::Choices::InstallChoice m_initialInstallChoice = PartitionActions::Choices::NoChoice;
|
||||
PartitionActions::Choices::InstallChoice m_installChoice = PartitionActions::Choices::NoChoice;
|
||||
InstallChoice m_initialInstallChoice = NoChoice;
|
||||
InstallChoice m_installChoice = NoChoice;
|
||||
qreal m_requiredStorageGiB = 0.0; // May duplicate setting in the welcome module
|
||||
};
|
||||
|
||||
|
@ -279,19 +279,6 @@ 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
|
||||
|
@ -47,16 +47,6 @@ 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"
|
||||
|
@ -561,7 +561,7 @@ PartitionCoreModule::setPartitionFlags( Device* device, Partition* partition, Pa
|
||||
}
|
||||
|
||||
Calamares::JobList
|
||||
PartitionCoreModule::jobs() const
|
||||
PartitionCoreModule::jobs( const Config* config ) const
|
||||
{
|
||||
Calamares::JobList lst;
|
||||
QList< Device* > devices;
|
||||
@ -592,7 +592,7 @@ PartitionCoreModule::jobs() const
|
||||
lst << info->jobs();
|
||||
devices << info->device.data();
|
||||
}
|
||||
lst << Calamares::job_ptr( new FillGlobalStorageJob( devices, m_bootLoaderInstallPath ) );
|
||||
lst << Calamares::job_ptr( new FillGlobalStorageJob( config, devices, m_bootLoaderInstallPath ) );
|
||||
|
||||
return lst;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <functional>
|
||||
|
||||
class BootLoaderModel;
|
||||
class Config;
|
||||
class CreatePartitionJob;
|
||||
class Device;
|
||||
class DeviceModel;
|
||||
@ -171,7 +172,7 @@ public:
|
||||
* requested by the user.
|
||||
* @return a list of jobs.
|
||||
*/
|
||||
Calamares::JobList jobs() const;
|
||||
Calamares::JobList jobs( const Config* ) const;
|
||||
|
||||
bool hasRootMountPoint() const;
|
||||
|
||||
|
@ -59,6 +59,7 @@ using Calamares::PrettyRadioButton;
|
||||
using CalamaresUtils::Partition::findPartitionByPath;
|
||||
using CalamaresUtils::Partition::isPartitionFreeSpace;
|
||||
using CalamaresUtils::Partition::PartitionIterator;
|
||||
using InstallChoice = Config::InstallChoice;
|
||||
using PartitionActions::Choices::SwapChoice;
|
||||
|
||||
/**
|
||||
@ -439,10 +440,10 @@ ChoicePage::onEraseSwapChoiceChanged()
|
||||
}
|
||||
|
||||
void
|
||||
ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
|
||||
ChoicePage::applyActionChoice( InstallChoice choice )
|
||||
{
|
||||
cDebug() << "Prev" << m_lastSelectedActionIndex << "InstallChoice" << choice
|
||||
<< PartitionActions::Choices::installChoiceNames().find( choice );
|
||||
<< Config::installChoiceNames().find( choice );
|
||||
m_beforePartitionBarsView->selectionModel()->disconnect( SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ) );
|
||||
m_beforePartitionBarsView->selectionModel()->clearSelection();
|
||||
m_beforePartitionBarsView->selectionModel()->clearCurrentIndex();
|
||||
@ -925,7 +926,7 @@ ChoicePage::updateDeviceStatePreview()
|
||||
* @param choice the chosen partitioning action.
|
||||
*/
|
||||
void
|
||||
ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
|
||||
ChoicePage::updateActionChoicePreview( InstallChoice choice )
|
||||
{
|
||||
Device* currentDevice = selectedDevice();
|
||||
Q_ASSERT( currentDevice );
|
||||
|
@ -15,8 +15,9 @@
|
||||
#include "ui_ChoicePage.h"
|
||||
|
||||
|
||||
#include "core/Config.h"
|
||||
#include "core/OsproberEntry.h"
|
||||
#include "core/PartitionActions.h"
|
||||
// #include "core/PartitionActions.h"
|
||||
|
||||
#include <QMutex>
|
||||
#include <QPointer>
|
||||
@ -53,8 +54,6 @@ class ChoicePage : public QWidget, private Ui::ChoicePage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using InstallChoice = PartitionActions::Choices::InstallChoice;
|
||||
|
||||
explicit ChoicePage( Config* config, QWidget* parent = nullptr );
|
||||
virtual ~ChoicePage();
|
||||
|
||||
@ -81,7 +80,7 @@ public:
|
||||
* @brief applyActionChoice reacts to a choice of partitioning mode.
|
||||
* @param choice the partitioning action choice.
|
||||
*/
|
||||
void applyActionChoice( ChoicePage::InstallChoice choice );
|
||||
void applyActionChoice( Config::InstallChoice choice );
|
||||
|
||||
int lastSelectedDeviceIndex();
|
||||
void setLastSelectedDeviceIndex( int index );
|
||||
@ -107,7 +106,7 @@ private:
|
||||
bool calculateNextEnabled() const;
|
||||
void updateNextEnabled();
|
||||
void setupChoices();
|
||||
void checkInstallChoiceRadioButton( ChoicePage::InstallChoice choice ); ///< Sets the chosen button to "on"
|
||||
void checkInstallChoiceRadioButton( Config::InstallChoice choice ); ///< Sets the chosen button to "on"
|
||||
QComboBox* createBootloaderComboBox( QWidget* parentButton );
|
||||
Device* selectedDevice();
|
||||
|
||||
@ -117,7 +116,7 @@ private:
|
||||
void continueApplyDeviceChoice(); // .. called after scan
|
||||
|
||||
void updateDeviceStatePreview();
|
||||
void updateActionChoicePreview( ChoicePage::InstallChoice choice );
|
||||
void updateActionChoicePreview( Config::InstallChoice choice );
|
||||
void setupActions();
|
||||
OsproberEntryList getOsproberEntriesForDevice( Device* device ) const;
|
||||
void doAlongsideApply();
|
||||
|
@ -140,7 +140,7 @@ PartitionViewStep::createSummaryWidget() const
|
||||
widget->setLayout( mainLayout );
|
||||
mainLayout->setMargin( 0 );
|
||||
|
||||
ChoicePage::InstallChoice choice = m_config->installChoice();
|
||||
Config::InstallChoice choice = m_config->installChoice();
|
||||
|
||||
QFormLayout* formLayout = new QFormLayout( widget );
|
||||
const int MARGIN = CalamaresUtils::defaultFontHeight() / 2;
|
||||
@ -158,18 +158,18 @@ PartitionViewStep::createSummaryWidget() const
|
||||
QString modeText;
|
||||
switch ( choice )
|
||||
{
|
||||
case ChoicePage::InstallChoice::Alongside:
|
||||
case Config::InstallChoice::Alongside:
|
||||
modeText = tr( "Install %1 <strong>alongside</strong> another operating system." )
|
||||
.arg( branding->shortVersionedName() );
|
||||
break;
|
||||
case ChoicePage::InstallChoice::Erase:
|
||||
case Config::InstallChoice::Erase:
|
||||
modeText = tr( "<strong>Erase</strong> disk and install %1." ).arg( branding->shortVersionedName() );
|
||||
break;
|
||||
case ChoicePage::InstallChoice::Replace:
|
||||
case Config::InstallChoice::Replace:
|
||||
modeText = tr( "<strong>Replace</strong> a partition with %1." ).arg( branding->shortVersionedName() );
|
||||
break;
|
||||
case ChoicePage::InstallChoice::NoChoice:
|
||||
case ChoicePage::InstallChoice::Manual:
|
||||
case Config::InstallChoice::NoChoice:
|
||||
case Config::InstallChoice::Manual:
|
||||
modeText = tr( "<strong>Manual</strong> partitioning." );
|
||||
}
|
||||
modeLabel->setText( modeText );
|
||||
@ -182,27 +182,27 @@ PartitionViewStep::createSummaryWidget() const
|
||||
QString modeText;
|
||||
switch ( choice )
|
||||
{
|
||||
case ChoicePage::InstallChoice::Alongside:
|
||||
case Config::InstallChoice::Alongside:
|
||||
modeText = tr( "Install %1 <strong>alongside</strong> another operating system on disk "
|
||||
"<strong>%2</strong> (%3)." )
|
||||
.arg( branding->shortVersionedName() )
|
||||
.arg( info.deviceNode )
|
||||
.arg( info.deviceName );
|
||||
break;
|
||||
case ChoicePage::InstallChoice::Erase:
|
||||
case Config::InstallChoice::Erase:
|
||||
modeText = tr( "<strong>Erase</strong> disk <strong>%2</strong> (%3) and install %1." )
|
||||
.arg( branding->shortVersionedName() )
|
||||
.arg( info.deviceNode )
|
||||
.arg( info.deviceName );
|
||||
break;
|
||||
case ChoicePage::InstallChoice::Replace:
|
||||
case Config::InstallChoice::Replace:
|
||||
modeText = tr( "<strong>Replace</strong> a partition on disk <strong>%2</strong> (%3) with %1." )
|
||||
.arg( branding->shortVersionedName() )
|
||||
.arg( info.deviceNode )
|
||||
.arg( info.deviceName );
|
||||
break;
|
||||
case ChoicePage::InstallChoice::NoChoice:
|
||||
case ChoicePage::InstallChoice::Manual:
|
||||
case Config::InstallChoice::NoChoice:
|
||||
case Config::InstallChoice::Manual:
|
||||
modeText = tr( "<strong>Manual</strong> partitioning on disk <strong>%1</strong> (%2)." )
|
||||
.arg( info.deviceNode )
|
||||
.arg( info.deviceName );
|
||||
@ -286,7 +286,7 @@ PartitionViewStep::next()
|
||||
{
|
||||
if ( m_choicePage == m_widget->currentWidget() )
|
||||
{
|
||||
if ( m_config->installChoice() == ChoicePage::InstallChoice::Manual )
|
||||
if ( m_config->installChoice() == Config::InstallChoice::Manual )
|
||||
{
|
||||
if ( !m_manualPartitionPage )
|
||||
{
|
||||
@ -369,8 +369,8 @@ PartitionViewStep::isAtEnd() const
|
||||
if ( m_widget->currentWidget() == m_choicePage )
|
||||
{
|
||||
auto choice = m_config->installChoice();
|
||||
if ( ChoicePage::InstallChoice::Erase == choice || ChoicePage::InstallChoice::Replace == choice
|
||||
|| ChoicePage::InstallChoice::Alongside == choice )
|
||||
if ( Config::InstallChoice::Erase == choice || Config::InstallChoice::Replace == choice
|
||||
|| Config::InstallChoice::Alongside == choice )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -386,10 +386,9 @@ PartitionViewStep::onActivate()
|
||||
m_config->updateGlobalStorage();
|
||||
|
||||
// if we're coming back to PVS from the next VS
|
||||
if ( m_widget->currentWidget() == m_choicePage
|
||||
&& m_config->installChoice() == ChoicePage::InstallChoice::Alongside )
|
||||
if ( m_widget->currentWidget() == m_choicePage && m_config->installChoice() == Config::InstallChoice::Alongside )
|
||||
{
|
||||
m_choicePage->applyActionChoice( ChoicePage::InstallChoice::Alongside );
|
||||
m_choicePage->applyActionChoice( Config::InstallChoice::Alongside );
|
||||
// m_choicePage->reset();
|
||||
//FIXME: ReplaceWidget should be reset maybe?
|
||||
}
|
||||
@ -605,7 +604,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
Calamares::JobList
|
||||
PartitionViewStep::jobs() const
|
||||
{
|
||||
return m_core->jobs();
|
||||
return m_core->jobs( m_config );
|
||||
}
|
||||
|
||||
Calamares::RequirementsList
|
||||
|
@ -126,7 +126,7 @@ mapForPartition( Partition* partition, const QString& uuid )
|
||||
return map;
|
||||
}
|
||||
|
||||
FillGlobalStorageJob::FillGlobalStorageJob( QList< Device* > devices, const QString& bootLoaderPath )
|
||||
FillGlobalStorageJob::FillGlobalStorageJob( const Config*, QList< Device* > devices, const QString& bootLoaderPath )
|
||||
: m_devices( devices )
|
||||
, m_bootLoaderPath( bootLoaderPath )
|
||||
{
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <QList>
|
||||
#include <QVariantList>
|
||||
|
||||
class Config;
|
||||
class Device;
|
||||
class Partition;
|
||||
|
||||
@ -30,7 +31,8 @@ class FillGlobalStorageJob : public Calamares::Job
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FillGlobalStorageJob( QList< Device* > devices, const QString& bootLoaderPath );
|
||||
FillGlobalStorageJob( const Config* config, QList< Device* > devices, const QString& bootLoaderPath );
|
||||
|
||||
QString prettyName() const override;
|
||||
QString prettyDescription() const override;
|
||||
QString prettyStatusMessage() const override;
|
||||
|
Loading…
Reference in New Issue
Block a user