diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 5ab46e2f2..8dfb1a80a 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -121,6 +121,7 @@ ChoicePage::ChoicePage( QWidget* parent ) m_previewAfterFrame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); m_previewAfterLabel->hide(); m_previewAfterFrame->hide(); + m_encryptWidget->hide(); // end } @@ -157,6 +158,9 @@ ChoicePage::init( PartitionCoreModule* core ) static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ), this, &ChoicePage::applyDeviceChoice ); + connect( m_encryptWidget, &EncryptWidget::stateChanged, + this, &ChoicePage::updateNextEnabled ); + ChoicePage::applyDeviceChoice(); } @@ -238,14 +242,8 @@ ChoicePage::setupChoices() if ( checked ) // An action was picked. { m_choice = static_cast< Choice >( id ); - if ( m_choice == Replace ) - { - setNextEnabled( false ); - } - else - { - setNextEnabled( true ); - } + updateNextEnabled(); + emit actionChosen(); } else // An action was unpicked, either on its own or because of another selection. @@ -253,7 +251,8 @@ ChoicePage::setupChoices() if ( m_grp->checkedButton() == nullptr ) // If no other action is chosen, we must { // set m_choice to NoChoice and reset previews. m_choice = NoChoice; - setNextEnabled( false ); + updateNextEnabled(); + emit actionChosen(); } } @@ -392,7 +391,7 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice ) []{}, this ); } - setNextEnabled( !m_beforePartitionBarsView->selectionModel()->selectedRows().isEmpty() ); + updateNextEnabled(); connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ), this, SLOT( doReplaceSelectedPartition( QModelIndex, QModelIndex ) ), @@ -415,7 +414,7 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice ) }, this ); } - setNextEnabled( !m_beforePartitionBarsView->selectionModel()->selectedRows().isEmpty() ); + updateNextEnabled(); connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ), this, SLOT( doAlongsideSetupSplitter( QModelIndex, QModelIndex ) ), @@ -466,7 +465,7 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current, Calamares::Branding::instance()-> string( Calamares::Branding::ProductName ) ); - setNextEnabled( m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() ); + updateNextEnabled(); if ( m_isEfi ) setupEfiSystemPartitionSelector(); @@ -628,7 +627,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current, if ( m_isEfi ) setupEfiSystemPartitionSelector(); - setNextEnabled( !m_beforePartitionBarsView->selectionModel()->selectedRows().isEmpty() ); + updateNextEnabled(); if ( !m_bootloaderComboBox.isNull() && m_bootloaderComboBox->currentIndex() < 0 ) m_bootloaderComboBox->setCurrentIndex( m_lastSelectedDeviceIndex ); @@ -770,10 +769,12 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice ) }; m_beforePartitionBarsView->setSelectionFilter( filter ); m_beforePartitionLabelsView->setSelectionFilter( filter ); + m_encryptWidget->hide(); break; } case Erase: + m_encryptWidget->show(); case Replace: { m_previewBeforeLabel->setText( tr( "Current:" ) ); @@ -854,6 +855,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice ) m_previewAfterFrame->hide(); m_previewBeforeLabel->setText( tr( "Current:" ) ); m_previewAfterLabel->hide(); + m_encryptWidget->hide(); break; } @@ -903,7 +905,7 @@ ChoicePage::setupEfiSystemPartitionSelector() "partitioning to set up %1." ) .arg( Calamares::Branding::instance()-> string( Calamares::Branding::ShortProductName ) ) ); - setNextEnabled( false ); + updateNextEnabled(); } else if ( efiSystemPartitions.count() == 1 ) //probably most usual situation { @@ -1193,8 +1195,42 @@ ChoicePage::currentChoice() const void -ChoicePage::setNextEnabled( bool enabled ) +ChoicePage::updateNextEnabled() { + bool enabled = false; + + switch ( m_choice ) + { + case NoChoice: + enabled = false; + break; + case Replace: + enabled = !m_beforePartitionBarsView->selectionModel()-> + selectedRows().isEmpty(); + break; + case Alongside: + enabled = !m_beforePartitionBarsView->selectionModel()-> + selectedRows().isEmpty() && + m_beforePartitionBarsView->selectionModel()-> + currentIndex().isValid(); + break; + case Erase: + case Manual: + enabled = true; + } + + if ( m_isEfi && + ( m_choice == Alongside || + m_choice == Replace ) ) + { + if ( m_core->efiSystemPartitions().count() == 0 ) + enabled = false; + } + + if ( m_encryptWidget->isVisible() && + m_encryptWidget->state() == EncryptWidget::EncryptionUnconfirmed ) + enabled = false; + if ( enabled == m_nextEnabled ) return; diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 75d1e6642..1f09da101 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -76,7 +76,7 @@ private slots: void doAlongsideSetupSplitter( const QModelIndex& current, const QModelIndex& previous ); private: - void setNextEnabled( bool enabled ); + void updateNextEnabled(); void setupChoices(); QComboBox* createBootloaderComboBox( QWidget* parentButton ); Device* selectedDevice(); diff --git a/src/modules/partition/gui/ChoicePage.ui b/src/modules/partition/gui/ChoicePage.ui index 1dbe050d0..5c7b89ef7 100644 --- a/src/modules/partition/gui/ChoicePage.ui +++ b/src/modules/partition/gui/ChoicePage.ui @@ -32,7 +32,7 @@ - + @@ -63,7 +63,7 @@ 0 0 729 - 327 + 276 @@ -93,6 +93,9 @@ + + + @@ -197,6 +200,14 @@ + + + EncryptWidget + QWidget +
gui/EncryptWidget.h
+ 1 +
+