diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 9e48e69ac..1d0c96623 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -1442,46 +1442,75 @@ ChoicePage::currentChoice() const return m_choice; } - -void -ChoicePage::updateNextEnabled() +bool +ChoicePage::calculateNextEnabled() const { bool enabled = false; - auto sm_p = m_beforePartitionBarsView ? m_beforePartitionBarsView->selectionModel() : nullptr; switch ( m_choice ) { case NoChoice: - enabled = false; - break; + cDebug() << "No partitioning choice"; + return false; case Replace: case Alongside: - enabled = sm_p && sm_p->currentIndex().isValid(); + if ( !( sm_p && sm_p->currentIndex().isValid() ) ) + { + cDebug() << "No partition selected"; + return false; + } + enabled = true; break; case Erase: case Manual: enabled = true; } - if ( m_isEfi && - ( m_choice == Alongside || - m_choice == Replace ) ) + if (!enabled) { - if ( m_core->efiSystemPartitions().count() == 0 ) - enabled = false; + cDebug() << "No valid choice made"; + return false; } - if ( m_choice != Manual && - m_encryptWidget->isVisible() && - m_encryptWidget->state() == EncryptWidget::Encryption::Unconfirmed ) - enabled = false; - if ( enabled == m_nextEnabled ) - return; + if ( m_isEfi && ( m_choice == Alongside || m_choice == Replace ) ) + { + if ( m_core->efiSystemPartitions().count() == 0 ) + { + cDebug() << "No EFI partition for alongside or replace"; + return false; + } + } - m_nextEnabled = enabled; - emit nextStatusChanged( enabled ); + if ( m_choice != Manual && m_encryptWidget->isVisible() ) + { + switch ( m_encryptWidget->state() ) + { + case EncryptWidget::Encryption::Unconfirmed: + cDebug() << "No passphrase provided"; + return false; + case EncryptWidget::Encryption::Disabled: + case EncryptWidget::Encryption::Confirmed: + // Checkbox not checked, **or** passphrases match + break; + } + } + + return true; +} + + +void +ChoicePage::updateNextEnabled() +{ + bool enabled = calculateNextEnabled(); + + if ( enabled != m_nextEnabled ) + { + m_nextEnabled = enabled; + emit nextStatusChanged( enabled ); + } } void diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 1ff8f0d40..a28892011 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -126,6 +126,7 @@ private slots: void onEraseSwapChoiceChanged(); private: + bool calculateNextEnabled() const; void updateNextEnabled(); void setupChoices(); QComboBox* createBootloaderComboBox( QWidget* parentButton ); diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index 42a073db7..5e44c15fd 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -91,9 +91,39 @@ EncryptWidget::retranslate() } +///@brief Give @p label the @p pixmap from the standard-pixmaps +static void +applyPixmap( QLabel* label, CalamaresUtils::ImageType pixmap ) +{ + label->setFixedWidth( label->height() ); + label->setPixmap( CalamaresUtils::defaultPixmap( pixmap, CalamaresUtils::Original, label->size() ) ); +} + void EncryptWidget::updateState() { + if ( m_ui->m_passphraseLineEdit->isVisible() ) + { + QString p1 = m_ui->m_passphraseLineEdit->text(); + QString p2 = m_ui->m_confirmLineEdit->text(); + + if ( p1.isEmpty() && p2.isEmpty() ) + { + applyPixmap( m_ui->m_iconLabel, CalamaresUtils::StatusWarning ); + m_ui->m_iconLabel->setToolTip( tr( "Please enter the same passphrase in both boxes." ) ); + } + else if ( p1 == p2 ) + { + applyPixmap( m_ui->m_iconLabel, CalamaresUtils::StatusOk ); + m_ui->m_iconLabel->setToolTip( QString() ); + } + else + { + applyPixmap( m_ui->m_iconLabel, CalamaresUtils::StatusError ); + m_ui->m_iconLabel->setToolTip( tr( "Please enter the same passphrase in both boxes." ) ); + } + } + Encryption newState; if ( m_ui->m_encryptCheckBox->isChecked() ) { @@ -119,14 +149,6 @@ EncryptWidget::updateState() } } -///@brief Give @p label the @p pixmap from the standard-pixmaps -static void -applyPixmap( QLabel* label, CalamaresUtils::ImageType pixmap ) -{ - label->setFixedWidth( label->height() ); - label->setPixmap( CalamaresUtils::defaultPixmap( pixmap, CalamaresUtils::Original, label->size() ) ); -} - void EncryptWidget::onPassphraseEdited() { @@ -135,24 +157,6 @@ EncryptWidget::onPassphraseEdited() m_ui->m_iconLabel->show(); } - QString p1 = m_ui->m_passphraseLineEdit->text(); - QString p2 = m_ui->m_confirmLineEdit->text(); - - m_ui->m_iconLabel->setToolTip( QString() ); - if ( p1.isEmpty() && p2.isEmpty() ) - { - m_ui->m_iconLabel->clear(); - } - else if ( p1 == p2 ) - { - applyPixmap( m_ui->m_iconLabel, CalamaresUtils::Yes ); - } - else - { - applyPixmap( m_ui->m_iconLabel, CalamaresUtils::No ); - m_ui->m_iconLabel->setToolTip( tr( "Please enter the same passphrase in both boxes." ) ); - } - updateState(); } diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index b0142a82a..900d10e57 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -107,8 +107,8 @@ PartitionViewStep::continueLoading() m_waitingWidget->deleteLater(); m_waitingWidget = nullptr; - connect( m_core, &PartitionCoreModule::hasRootMountPointChanged, this, &PartitionViewStep::nextStatusChanged ); - connect( m_choicePage, &ChoicePage::nextStatusChanged, this, &PartitionViewStep::nextStatusChanged ); + connect( m_core, &PartitionCoreModule::hasRootMountPointChanged, this, &PartitionViewStep::nextPossiblyChanged ); + connect( m_choicePage, &ChoicePage::nextStatusChanged, this, &PartitionViewStep::nextPossiblyChanged ); } @@ -348,6 +348,11 @@ PartitionViewStep::isNextEnabled() const return false; } +void +PartitionViewStep::nextPossiblyChanged(bool) +{ + emit nextStatusChanged( isNextEnabled() ); +} bool PartitionViewStep::isBackEnabled() const diff --git a/src/modules/partition/gui/PartitionViewStep.h b/src/modules/partition/gui/PartitionViewStep.h index 63d11c816..47479a135 100644 --- a/src/modules/partition/gui/PartitionViewStep.h +++ b/src/modules/partition/gui/PartitionViewStep.h @@ -78,6 +78,9 @@ private: void initPartitionCoreModule(); void continueLoading(); + /// "slot" for changes to next-status from the KPMCore and ChoicePage + void nextPossiblyChanged( bool ); + PartitionCoreModule* m_core; QStackedWidget* m_widget; ChoicePage* m_choicePage;