diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 171df4a57..817580bbf 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -464,6 +464,18 @@ ChoicePage::continueApplyDeviceChoice() void ChoicePage::onActionChanged() { + if ( m_enableEncryptionWidget ) + { + if ( m_config->installChoice() == InstallChoice::Erase && m_eraseFsTypesChoiceComboBox ) + { + m_encryptWidget->setFilesystem( m_eraseFsTypesChoiceComboBox->currentText() ); + } + else if ( m_config->installChoice() == InstallChoice::Replace && m_replaceFsTypesChoiceComboBox ) + { + m_encryptWidget->setFilesystem( m_replaceFsTypesChoiceComboBox->currentText() ); + } + } + Device* currd = selectedDevice(); if ( currd ) { diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index 7c17de7af..e540fd2d0 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -16,6 +16,9 @@ #include "Branding.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Retranslator.h" +#include + +constexpr uint ZFS_MIN_LENGTH = 8; /** @brief Does this system support whole-disk encryption? * @@ -150,11 +153,17 @@ EncryptWidget::updateState() 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 ( FileSystem::typeForName( m_filesystem ) == FileSystem::Zfs && p1.length() < ZFS_MIN_LENGTH ) + { + applyPixmap( m_ui->m_iconLabel, CalamaresUtils::StatusError ); + m_ui->m_iconLabel->setToolTip( tr( "Password must be a minimum of %1 characters" ).arg( ZFS_MIN_LENGTH ) ); + } else if ( p1 == p2 ) { applyPixmap( m_ui->m_iconLabel, CalamaresUtils::StatusOk ); @@ -201,3 +210,10 @@ EncryptWidget::onCheckBoxStateChanged( int checked ) updateState(); } + +void +EncryptWidget::setFilesystem( const QString& fs ) +{ + m_filesystem = fs; + updateState(); +} diff --git a/src/modules/partition/gui/EncryptWidget.h b/src/modules/partition/gui/EncryptWidget.h index 9a3b8ab1f..1e4805850 100644 --- a/src/modules/partition/gui/EncryptWidget.h +++ b/src/modules/partition/gui/EncryptWidget.h @@ -38,6 +38,12 @@ public: Encryption state() const; void setText( const QString& text ); + /** + * @brief setFilesystem sets the filesystem name used for password validation + * @param fs A QString containing the name of the filesystem + */ + void setFilesystem( const QString& fs ); + QString passphrase() const; void retranslate(); @@ -52,6 +58,8 @@ private: Ui::EncryptWidget* m_ui; Encryption m_state; + + QString m_filesystem; }; #endif // ENCRYPTWIDGET_H