[partition] Drop InstallChoice enum from Page

- The enum for install choice was copied into PartitionActions and
  used in the Config object; its definition does not belong in the UI.
- Chase the renamings required.
This commit is contained in:
Adriaan de Groot 2020-07-30 11:51:26 +02:00
parent e21a2f0676
commit 41ce42cd4b
3 changed files with 50 additions and 57 deletions

View File

@ -80,7 +80,7 @@ ChoicePage::ChoicePage( Config* config, QWidget* parent )
, m_config( config ) , m_config( config )
, m_nextEnabled( false ) , m_nextEnabled( false )
, m_core( nullptr ) , m_core( nullptr )
, m_choice( NoChoice ) , m_choice( InstallChoice::NoChoice )
, m_isEfi( false ) , m_isEfi( false )
, m_grp( nullptr ) , m_grp( nullptr )
, m_alongsideButton( nullptr ) , m_alongsideButton( nullptr )
@ -242,14 +242,14 @@ ChoicePage::setupChoices()
m_alongsideButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionAlongside, m_alongsideButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionAlongside,
CalamaresUtils::Original, CalamaresUtils::Original,
iconSize ) ); iconSize ) );
m_alongsideButton->addToGroup( m_grp, Alongside ); m_alongsideButton->addToGroup( m_grp, InstallChoice::Alongside );
m_eraseButton = new PrettyRadioButton; m_eraseButton = new PrettyRadioButton;
m_eraseButton->setIconSize( iconSize ); m_eraseButton->setIconSize( iconSize );
m_eraseButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionEraseAuto, m_eraseButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionEraseAuto,
CalamaresUtils::Original, CalamaresUtils::Original,
iconSize ) ); iconSize ) );
m_eraseButton->addToGroup( m_grp, Erase ); m_eraseButton->addToGroup( m_grp, InstallChoice::Erase );
m_replaceButton = new PrettyRadioButton; m_replaceButton = new PrettyRadioButton;
@ -257,7 +257,7 @@ ChoicePage::setupChoices()
m_replaceButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionReplaceOs, m_replaceButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::PartitionReplaceOs,
CalamaresUtils::Original, CalamaresUtils::Original,
iconSize ) ); iconSize ) );
m_replaceButton->addToGroup( m_grp, Replace ); m_replaceButton->addToGroup( m_grp, InstallChoice::Replace );
// Fill up swap options // Fill up swap options
// .. TODO: only if enabled in the config // .. TODO: only if enabled in the config
@ -277,7 +277,7 @@ ChoicePage::setupChoices()
CalamaresUtils::Original, CalamaresUtils::Original,
iconSize ) ); iconSize ) );
m_itemsLayout->addWidget( m_somethingElseButton ); m_itemsLayout->addWidget( m_somethingElseButton );
m_somethingElseButton->addToGroup( m_grp, Manual ); m_somethingElseButton->addToGroup( m_grp, InstallChoice::Manual );
m_itemsLayout->addStretch(); m_itemsLayout->addStretch();
@ -295,7 +295,7 @@ ChoicePage::setupChoices()
{ {
if ( m_grp->checkedButton() == nullptr ) // If no other action is chosen, we must if ( m_grp->checkedButton() == nullptr ) // If no other action is chosen, we must
{ // set m_choice to NoChoice and reset previews. { // set m_choice to NoChoice and reset previews.
m_choice = NoChoice; m_choice = InstallChoice::NoChoice;
updateNextEnabled(); updateNextEnabled();
emit actionChosen(); emit actionChosen();
@ -441,7 +441,7 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
switch ( choice ) switch ( choice )
{ {
case Erase: case InstallChoice::Erase:
{ {
auto gs = Calamares::JobQueue::instance()->globalStorage(); auto gs = Calamares::JobQueue::instance()->globalStorage();
@ -474,7 +474,7 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
} }
} }
break; break;
case Replace: case InstallChoice::Replace:
if ( m_core->isDirty() ) if ( m_core->isDirty() )
{ {
ScanningDialog::run( QtConcurrent::run( [ = ] ScanningDialog::run( QtConcurrent::run( [ = ]
@ -492,7 +492,7 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
Qt::UniqueConnection ); Qt::UniqueConnection );
break; break;
case Alongside: case InstallChoice::Alongside:
if ( m_core->isDirty() ) if ( m_core->isDirty() )
{ {
ScanningDialog::run( QtConcurrent::run( [ = ] ScanningDialog::run( QtConcurrent::run( [ = ]
@ -515,8 +515,8 @@ ChoicePage::applyActionChoice( ChoicePage::InstallChoice choice )
this, SLOT( doAlongsideSetupSplitter( QModelIndex, QModelIndex ) ), this, SLOT( doAlongsideSetupSplitter( QModelIndex, QModelIndex ) ),
Qt::UniqueConnection ); Qt::UniqueConnection );
break; break;
case NoChoice: case InstallChoice::NoChoice:
case Manual: case InstallChoice::Manual:
break; break;
} }
updateActionChoicePreview( choice ); updateActionChoicePreview( choice );
@ -571,13 +571,13 @@ void
ChoicePage::onEncryptWidgetStateChanged() ChoicePage::onEncryptWidgetStateChanged()
{ {
EncryptWidget::Encryption state = m_encryptWidget->state(); EncryptWidget::Encryption state = m_encryptWidget->state();
if ( m_choice == Erase ) if ( m_choice == InstallChoice::Erase )
{ {
if ( state == EncryptWidget::Encryption::Confirmed || if ( state == EncryptWidget::Encryption::Confirmed ||
state == EncryptWidget::Encryption::Disabled ) state == EncryptWidget::Encryption::Disabled )
applyActionChoice( m_choice ); applyActionChoice( m_choice );
} }
else if ( m_choice == Replace ) else if ( m_choice == InstallChoice::Replace )
{ {
if ( m_beforePartitionBarsView && if ( m_beforePartitionBarsView &&
m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() && m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() &&
@ -596,7 +596,7 @@ ChoicePage::onEncryptWidgetStateChanged()
void void
ChoicePage::onHomeCheckBoxStateChanged() ChoicePage::onHomeCheckBoxStateChanged()
{ {
if ( currentChoice() == Replace && if ( currentChoice() == InstallChoice::Replace &&
m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() ) m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() )
{ {
doReplaceSelectedPartition( m_beforePartitionBarsView-> doReplaceSelectedPartition( m_beforePartitionBarsView->
@ -609,10 +609,10 @@ ChoicePage::onHomeCheckBoxStateChanged()
void void
ChoicePage::onLeave() ChoicePage::onLeave()
{ {
if ( m_choice == Alongside ) if ( m_choice == InstallChoice::Alongside )
doAlongsideApply(); doAlongsideApply();
if ( m_isEfi && ( m_choice == Alongside || m_choice == Replace ) ) if ( m_isEfi && ( m_choice == InstallChoice::Alongside || m_choice == InstallChoice::Replace ) )
{ {
QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions(); QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions();
if ( efiSystemPartitions.count() == 1 ) if ( efiSystemPartitions.count() == 1 )
@ -879,8 +879,8 @@ ChoicePage::updateDeviceStatePreview()
switch ( m_choice ) switch ( m_choice )
{ {
case Replace: case InstallChoice::Replace:
case Alongside: case InstallChoice::Alongside:
m_beforePartitionBarsView->setSelectionMode( QAbstractItemView::SingleSelection ); m_beforePartitionBarsView->setSelectionMode( QAbstractItemView::SingleSelection );
m_beforePartitionLabelsView->setSelectionMode( QAbstractItemView::SingleSelection ); m_beforePartitionLabelsView->setSelectionMode( QAbstractItemView::SingleSelection );
break; break;
@ -931,7 +931,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
switch ( choice ) switch ( choice )
{ {
case Alongside: case InstallChoice::Alongside:
{ {
if ( m_enableEncryptionWidget ) if ( m_enableEncryptionWidget )
m_encryptWidget->show(); m_encryptWidget->show();
@ -975,8 +975,8 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
break; break;
} }
case Erase: case InstallChoice::Erase:
case Replace: case InstallChoice::Replace:
{ {
if ( m_enableEncryptionWidget ) if ( m_enableEncryptionWidget )
m_encryptWidget->show(); m_encryptWidget->show();
@ -1042,7 +1042,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
m_previewAfterFrame->show(); m_previewAfterFrame->show();
m_previewAfterLabel->show(); m_previewAfterLabel->show();
if ( m_choice == Erase ) if ( m_choice == InstallChoice::Erase )
m_selectLabel->hide(); m_selectLabel->hide();
else else
{ {
@ -1062,8 +1062,8 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
break; break;
} }
case NoChoice: case InstallChoice::NoChoice:
case Manual: case InstallChoice::Manual:
m_selectLabel->hide(); m_selectLabel->hide();
m_previewAfterFrame->hide(); m_previewAfterFrame->hide();
m_previewBeforeLabel->setText( tr( "Current:" ) ); m_previewBeforeLabel->setText( tr( "Current:" ) );
@ -1072,7 +1072,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
break; break;
} }
if ( m_isEfi && ( m_choice == Alongside || m_choice == Replace ) ) if ( m_isEfi && ( m_choice == InstallChoice::Alongside || m_choice == InstallChoice::Replace ) )
{ {
QHBoxLayout* efiLayout = new QHBoxLayout; QHBoxLayout* efiLayout = new QHBoxLayout;
layout->addLayout( efiLayout ); layout->addLayout( efiLayout );
@ -1089,8 +1089,8 @@ ChoicePage::updateActionChoicePreview( ChoicePage::InstallChoice choice )
QAbstractItemView::SelectionMode previewSelectionMode; QAbstractItemView::SelectionMode previewSelectionMode;
switch ( m_choice ) switch ( m_choice )
{ {
case Replace: case InstallChoice::Replace:
case Alongside: case InstallChoice::Alongside:
previewSelectionMode = QAbstractItemView::SingleSelection; previewSelectionMode = QAbstractItemView::SingleSelection;
break; break;
default: default:
@ -1433,11 +1433,11 @@ ChoicePage::calculateNextEnabled() const
switch ( m_choice ) switch ( m_choice )
{ {
case NoChoice: case InstallChoice::NoChoice:
cDebug() << "No partitioning choice"; cDebug() << "No partitioning choice";
return false; return false;
case Replace: case InstallChoice::Replace:
case Alongside: case InstallChoice::Alongside:
if ( !( sm_p && sm_p->currentIndex().isValid() ) ) if ( !( sm_p && sm_p->currentIndex().isValid() ) )
{ {
cDebug() << "No partition selected"; cDebug() << "No partition selected";
@ -1445,8 +1445,8 @@ ChoicePage::calculateNextEnabled() const
} }
enabled = true; enabled = true;
break; break;
case Erase: case InstallChoice::Erase:
case Manual: case InstallChoice::Manual:
enabled = true; enabled = true;
} }
@ -1457,7 +1457,7 @@ ChoicePage::calculateNextEnabled() const
} }
if ( m_isEfi && ( m_choice == Alongside || m_choice == Replace ) ) if ( m_isEfi && ( m_choice == InstallChoice::Alongside || m_choice == InstallChoice::Replace ) )
{ {
if ( m_core->efiSystemPartitions().count() == 0 ) if ( m_core->efiSystemPartitions().count() == 0 )
{ {
@ -1466,7 +1466,7 @@ ChoicePage::calculateNextEnabled() const
} }
} }
if ( m_choice != Manual && m_encryptWidget->isVisible() ) if ( m_choice != InstallChoice::Manual && m_encryptWidget->isVisible() )
{ {
switch ( m_encryptWidget->state() ) switch ( m_encryptWidget->state() )
{ {

View File

@ -62,14 +62,7 @@ class ChoicePage : public QWidget, private Ui::ChoicePage
{ {
Q_OBJECT Q_OBJECT
public: public:
enum InstallChoice using InstallChoice = PartitionActions::Choices::InstallChoice;
{
NoChoice,
Alongside,
Erase,
Replace,
Manual
};
explicit ChoicePage( Config* config, QWidget* parent = nullptr ); explicit ChoicePage( Config* config, QWidget* parent = nullptr );
virtual ~ChoicePage(); virtual ~ChoicePage();

View File

@ -167,20 +167,20 @@ PartitionViewStep::createSummaryWidget() const
QString modeText; QString modeText;
switch ( choice ) switch ( choice )
{ {
case ChoicePage::Alongside: case ChoicePage::InstallChoice::Alongside:
modeText = tr( "Install %1 <strong>alongside</strong> another operating system." ) modeText = tr( "Install %1 <strong>alongside</strong> another operating system." )
.arg( branding->shortVersionedName() ); .arg( branding->shortVersionedName() );
break; break;
case ChoicePage::Erase: case ChoicePage::InstallChoice::Erase:
modeText modeText
= tr( "<strong>Erase</strong> disk and install %1." ).arg( branding->shortVersionedName() ); = tr( "<strong>Erase</strong> disk and install %1." ).arg( branding->shortVersionedName() );
break; break;
case ChoicePage::Replace: case ChoicePage::InstallChoice::Replace:
modeText modeText
= tr( "<strong>Replace</strong> a partition with %1." ).arg( branding->shortVersionedName() ); = tr( "<strong>Replace</strong> a partition with %1." ).arg( branding->shortVersionedName() );
break; break;
case ChoicePage::NoChoice: case ChoicePage::InstallChoice::NoChoice:
case ChoicePage::Manual: case ChoicePage::InstallChoice::Manual:
modeText = tr( "<strong>Manual</strong> partitioning." ); modeText = tr( "<strong>Manual</strong> partitioning." );
} }
modeLabel->setText( modeText ); modeLabel->setText( modeText );
@ -193,27 +193,27 @@ PartitionViewStep::createSummaryWidget() const
QString modeText; QString modeText;
switch ( choice ) switch ( choice )
{ {
case ChoicePage::Alongside: case ChoicePage::InstallChoice::Alongside:
modeText = tr( "Install %1 <strong>alongside</strong> another operating system on disk " modeText = tr( "Install %1 <strong>alongside</strong> another operating system on disk "
"<strong>%2</strong> (%3)." ) "<strong>%2</strong> (%3)." )
.arg( branding->shortVersionedName() ) .arg( branding->shortVersionedName() )
.arg( info.deviceNode ) .arg( info.deviceNode )
.arg( info.deviceName ); .arg( info.deviceName );
break; break;
case ChoicePage::Erase: case ChoicePage::InstallChoice::Erase:
modeText = tr( "<strong>Erase</strong> disk <strong>%2</strong> (%3) and install %1." ) modeText = tr( "<strong>Erase</strong> disk <strong>%2</strong> (%3) and install %1." )
.arg( branding->shortVersionedName() ) .arg( branding->shortVersionedName() )
.arg( info.deviceNode ) .arg( info.deviceNode )
.arg( info.deviceName ); .arg( info.deviceName );
break; break;
case ChoicePage::Replace: case ChoicePage::InstallChoice::Replace:
modeText = tr( "<strong>Replace</strong> a partition on disk <strong>%2</strong> (%3) with %1." ) modeText = tr( "<strong>Replace</strong> a partition on disk <strong>%2</strong> (%3) with %1." )
.arg( branding->shortVersionedName() ) .arg( branding->shortVersionedName() )
.arg( info.deviceNode ) .arg( info.deviceNode )
.arg( info.deviceName ); .arg( info.deviceName );
break; break;
case ChoicePage::NoChoice: case ChoicePage::InstallChoice::NoChoice:
case ChoicePage::Manual: case ChoicePage::InstallChoice::Manual:
modeText = tr( "<strong>Manual</strong> partitioning on disk <strong>%1</strong> (%2)." ) modeText = tr( "<strong>Manual</strong> partitioning on disk <strong>%1</strong> (%2)." )
.arg( info.deviceNode ) .arg( info.deviceNode )
.arg( info.deviceName ); .arg( info.deviceName );
@ -296,7 +296,7 @@ PartitionViewStep::next()
{ {
if ( m_choicePage == m_widget->currentWidget() ) if ( m_choicePage == m_widget->currentWidget() )
{ {
if ( m_choicePage->currentChoice() == ChoicePage::Manual ) if ( m_choicePage->currentChoice() == ChoicePage::InstallChoice::Manual )
{ {
if ( !m_manualPartitionPage ) if ( !m_manualPartitionPage )
{ {
@ -378,8 +378,8 @@ PartitionViewStep::isAtEnd() const
{ {
if ( m_widget->currentWidget() == m_choicePage ) if ( m_widget->currentWidget() == m_choicePage )
{ {
if ( m_choicePage->currentChoice() == ChoicePage::Erase || m_choicePage->currentChoice() == ChoicePage::Replace if ( m_choicePage->currentChoice() == ChoicePage::InstallChoice::Erase || m_choicePage->currentChoice() == ChoicePage::InstallChoice::Replace
|| m_choicePage->currentChoice() == ChoicePage::Alongside ) || m_choicePage->currentChoice() == ChoicePage::InstallChoice::Alongside )
{ {
return true; return true;
} }
@ -395,9 +395,9 @@ PartitionViewStep::onActivate()
m_config->updateGlobalStorage(); m_config->updateGlobalStorage();
// if we're coming back to PVS from the next VS // if we're coming back to PVS from the next VS
if ( m_widget->currentWidget() == m_choicePage && m_choicePage->currentChoice() == ChoicePage::Alongside ) if ( m_widget->currentWidget() == m_choicePage && m_choicePage->currentChoice() == ChoicePage::InstallChoice::Alongside )
{ {
m_choicePage->applyActionChoice( ChoicePage::Alongside ); m_choicePage->applyActionChoice( ChoicePage::InstallChoice::Alongside );
// m_choicePage->reset(); // m_choicePage->reset();
//FIXME: ReplaceWidget should be reset maybe? //FIXME: ReplaceWidget should be reset maybe?
} }