[partition] Factor out visibility of encryption widget

- Put this in a method of its own even though it's used
  only once, so we can put a good name on it.
- If there are no FS choices (e.g. the sample settings file)
  then there is no combo-box, and the check was crashing.

FIXES #2029
This commit is contained in:
Adriaan de Groot 2022-07-26 17:33:39 +02:00
parent ba96f7ddc2
commit be54cd24de
2 changed files with 11 additions and 3 deletions

View File

@ -1063,8 +1063,7 @@ ChoicePage::updateActionChoicePreview( InstallChoice choice )
case InstallChoice::Erase:
case InstallChoice::Replace:
{
m_encryptWidget->setVisible( m_enableEncryptionWidget && m_eraseFsTypesChoiceComboBox->currentText() != "zfs"
&& choice == InstallChoice::Erase );
m_encryptWidget->setVisible( shouldShowEncryptWidget( choice ) );
m_previewBeforeLabel->setText( tr( "Current:" ) );
m_afterPartitionBarsView = new PartitionBarsView( m_previewAfterFrame );
m_afterPartitionBarsView->setNestedPartitionsMode( mode );
@ -1731,3 +1730,11 @@ ChoicePage::createBootloaderPanel()
return panelWidget;
}
bool ChoicePage::shouldShowEncryptWidget( Config::InstallChoice choice ) const
{
// If there are any choices for FS, check it's not ZFS because that doesn't
// support the kind of encryption we enable here.
const bool suitableFS = m_eraseFsTypesChoiceComboBox ? m_eraseFsTypesChoiceComboBox->currentText() != "zfs" : true;
return (choice == InstallChoice::Erase) && m_enableEncryptionWidget && suitableFS;
}

View File

@ -126,6 +126,7 @@ private:
void updateDeviceStatePreview();
void updateActionChoicePreview( Config::InstallChoice choice );
bool shouldShowEncryptWidget( Config::InstallChoice choice ) const;
void setupActions();
OsproberEntryList getOsproberEntriesForDevice( Device* device ) const;
void doAlongsideApply();
@ -167,7 +168,7 @@ private:
int m_lastSelectedDeviceIndex = -1;
int m_lastSelectedActionIndex = -1;
bool m_enableEncryptionWidget;
bool m_enableEncryptionWidget = false;
QMutex m_coreMutex;
};