[partition] Fix issues with replace partition

This commit is contained in:
dalto 2023-02-17 15:33:37 -06:00
parent 35cc54a6b9
commit 8080adbce2
2 changed files with 24 additions and 9 deletions

View File

@ -290,11 +290,14 @@ ChoicePage::setupChoices()
m_eraseButton->addOptionsComboBox( m_eraseFsTypesChoiceComboBox ); m_eraseButton->addOptionsComboBox( m_eraseFsTypesChoiceComboBox );
// Also offer it for "replace // Also offer it for "replace
auto* box = new QComboBox; m_replaceFsTypesChoiceComboBox = new QComboBox;
box->addItems( m_config->eraseFsTypes() ); m_replaceFsTypesChoiceComboBox->addItems( m_config->eraseFsTypes() );
connect( box, &QComboBox::currentTextChanged, m_config, &Config::setReplaceFilesystemChoice ); connect( m_replaceFsTypesChoiceComboBox,
&QComboBox::currentTextChanged,
m_config,
&Config::setReplaceFilesystemChoice );
connect( m_config, &Config::replaceModeFilesystemChanged, this, &ChoicePage::onActionChanged ); connect( m_config, &Config::replaceModeFilesystemChanged, this, &ChoicePage::onActionChanged );
m_replaceButton->addOptionsComboBox( box ); m_replaceButton->addOptionsComboBox( m_replaceFsTypesChoiceComboBox );
} }
m_itemsLayout->addWidget( m_alongsideButton ); m_itemsLayout->addWidget( m_alongsideButton );
@ -451,7 +454,6 @@ ChoicePage::continueApplyDeviceChoice()
if ( m_lastSelectedDeviceIndex != m_drivesCombo->currentIndex() ) if ( m_lastSelectedDeviceIndex != m_drivesCombo->currentIndex() )
{ {
m_lastSelectedDeviceIndex = m_drivesCombo->currentIndex(); m_lastSelectedDeviceIndex = m_drivesCombo->currentIndex();
m_lastSelectedActionIndex = -1;
m_config->setInstallChoice( m_config->initialInstallChoice() ); m_config->setInstallChoice( m_config->initialInstallChoice() );
checkInstallChoiceRadioButton( m_config->installChoice() ); checkInstallChoiceRadioButton( m_config->installChoice() );
} }
@ -485,9 +487,9 @@ ChoicePage::onEraseSwapChoiceChanged()
void void
ChoicePage::applyActionChoice( InstallChoice choice ) ChoicePage::applyActionChoice( InstallChoice choice )
{ {
cDebug() << "Prev" << m_lastSelectedActionIndex << "InstallChoice" << choice cDebug() << "InstallChoice" << choice << Config::installChoiceNames().find( choice );
<< Config::installChoiceNames().find( choice );
m_beforePartitionBarsView->selectionModel()->disconnect( SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ) ); m_beforePartitionBarsView->selectionModel()->disconnect( SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ) );
auto priorSelection = m_beforePartitionBarsView->selectionModel()->currentIndex();
m_beforePartitionBarsView->selectionModel()->clearSelection(); m_beforePartitionBarsView->selectionModel()->clearSelection();
m_beforePartitionBarsView->selectionModel()->clearCurrentIndex(); m_beforePartitionBarsView->selectionModel()->clearCurrentIndex();
@ -546,6 +548,12 @@ ChoicePage::applyActionChoice( InstallChoice choice )
this, this,
SLOT( onPartitionToReplaceSelected( QModelIndex, QModelIndex ) ), SLOT( onPartitionToReplaceSelected( QModelIndex, QModelIndex ) ),
Qt::UniqueConnection ); Qt::UniqueConnection );
// Maintain the selection for replace
if ( priorSelection.isValid() )
{
m_beforePartitionBarsView->selectionModel()->setCurrentIndex( priorSelection, QItemSelectionModel::Select );
}
break; break;
case InstallChoice::Alongside: case InstallChoice::Alongside:
@ -1742,7 +1750,14 @@ ChoicePage::shouldShowEncryptWidget( Config::InstallChoice choice ) const
{ {
// If there are any choices for FS, check it's not ZFS because that doesn't // If there are any choices for FS, check it's not ZFS because that doesn't
// support the kind of encryption we enable here. // support the kind of encryption we enable here.
const bool suitableFS = m_eraseFsTypesChoiceComboBox ? m_eraseFsTypesChoiceComboBox->currentText() != "zfs" : true; bool suitableFS = true;
if ( ( m_eraseFsTypesChoiceComboBox && m_eraseFsTypesChoiceComboBox->isVisible()
&& m_eraseFsTypesChoiceComboBox->currentText() == "zfs" )
|| ( m_replaceFsTypesChoiceComboBox && m_replaceFsTypesChoiceComboBox->isVisible()
&& m_replaceFsTypesChoiceComboBox->currentText() == "zfs" ) )
{
suitableFS = false;
}
const bool suitableChoice const bool suitableChoice
= choice == InstallChoice::Erase || choice == InstallChoice::Alongside || choice == InstallChoice::Replace; = choice == InstallChoice::Erase || choice == InstallChoice::Alongside || choice == InstallChoice::Replace;
return suitableChoice && m_enableEncryptionWidget && suitableFS; return suitableChoice && m_enableEncryptionWidget && suitableFS;

View File

@ -152,6 +152,7 @@ private:
Calamares::Widgets::PrettyRadioButton* m_somethingElseButton; Calamares::Widgets::PrettyRadioButton* m_somethingElseButton;
QComboBox* m_eraseSwapChoiceComboBox = nullptr; // UI, see also Config's swap choice QComboBox* m_eraseSwapChoiceComboBox = nullptr; // UI, see also Config's swap choice
QComboBox* m_eraseFsTypesChoiceComboBox = nullptr; // UI, see also Config's erase-mode FS QComboBox* m_eraseFsTypesChoiceComboBox = nullptr; // UI, see also Config's erase-mode FS
QComboBox* m_replaceFsTypesChoiceComboBox = nullptr; // UI, see also Config's erase-mode FS
DeviceInfoWidget* m_deviceInfoWidget; DeviceInfoWidget* m_deviceInfoWidget;
@ -166,7 +167,6 @@ private:
QPointer< QComboBox > m_efiComboBox; QPointer< QComboBox > m_efiComboBox;
int m_lastSelectedDeviceIndex = -1; int m_lastSelectedDeviceIndex = -1;
int m_lastSelectedActionIndex = -1;
bool m_enableEncryptionWidget = false; bool m_enableEncryptionWidget = false;