From 8080adbce2300e4b188fdae71479848573b38a5f Mon Sep 17 00:00:00 2001 From: dalto Date: Fri, 17 Feb 2023 15:33:37 -0600 Subject: [PATCH] [partition] Fix issues with replace partition --- src/modules/partition/gui/ChoicePage.cpp | 31 ++++++++++++++++++------ src/modules/partition/gui/ChoicePage.h | 2 +- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index e782a0299..ef26fc7e5 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -290,11 +290,14 @@ ChoicePage::setupChoices() m_eraseButton->addOptionsComboBox( m_eraseFsTypesChoiceComboBox ); // Also offer it for "replace - auto* box = new QComboBox; - box->addItems( m_config->eraseFsTypes() ); - connect( box, &QComboBox::currentTextChanged, m_config, &Config::setReplaceFilesystemChoice ); + m_replaceFsTypesChoiceComboBox = new QComboBox; + m_replaceFsTypesChoiceComboBox->addItems( m_config->eraseFsTypes() ); + connect( m_replaceFsTypesChoiceComboBox, + &QComboBox::currentTextChanged, + m_config, + &Config::setReplaceFilesystemChoice ); connect( m_config, &Config::replaceModeFilesystemChanged, this, &ChoicePage::onActionChanged ); - m_replaceButton->addOptionsComboBox( box ); + m_replaceButton->addOptionsComboBox( m_replaceFsTypesChoiceComboBox ); } m_itemsLayout->addWidget( m_alongsideButton ); @@ -451,7 +454,6 @@ ChoicePage::continueApplyDeviceChoice() if ( m_lastSelectedDeviceIndex != m_drivesCombo->currentIndex() ) { m_lastSelectedDeviceIndex = m_drivesCombo->currentIndex(); - m_lastSelectedActionIndex = -1; m_config->setInstallChoice( m_config->initialInstallChoice() ); checkInstallChoiceRadioButton( m_config->installChoice() ); } @@ -485,9 +487,9 @@ ChoicePage::onEraseSwapChoiceChanged() void ChoicePage::applyActionChoice( InstallChoice choice ) { - cDebug() << "Prev" << m_lastSelectedActionIndex << "InstallChoice" << choice - << Config::installChoiceNames().find( choice ); + cDebug() << "InstallChoice" << choice << Config::installChoiceNames().find( choice ); m_beforePartitionBarsView->selectionModel()->disconnect( SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ) ); + auto priorSelection = m_beforePartitionBarsView->selectionModel()->currentIndex(); m_beforePartitionBarsView->selectionModel()->clearSelection(); m_beforePartitionBarsView->selectionModel()->clearCurrentIndex(); @@ -546,6 +548,12 @@ ChoicePage::applyActionChoice( InstallChoice choice ) this, SLOT( onPartitionToReplaceSelected( QModelIndex, QModelIndex ) ), Qt::UniqueConnection ); + + // Maintain the selection for replace + if ( priorSelection.isValid() ) + { + m_beforePartitionBarsView->selectionModel()->setCurrentIndex( priorSelection, QItemSelectionModel::Select ); + } break; 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 // 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 = choice == InstallChoice::Erase || choice == InstallChoice::Alongside || choice == InstallChoice::Replace; return suitableChoice && m_enableEncryptionWidget && suitableFS; diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h index 6d77629d4..684a55018 100644 --- a/src/modules/partition/gui/ChoicePage.h +++ b/src/modules/partition/gui/ChoicePage.h @@ -152,6 +152,7 @@ private: Calamares::Widgets::PrettyRadioButton* m_somethingElseButton; 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_replaceFsTypesChoiceComboBox = nullptr; // UI, see also Config's erase-mode FS DeviceInfoWidget* m_deviceInfoWidget; @@ -166,7 +167,6 @@ private: QPointer< QComboBox > m_efiComboBox; int m_lastSelectedDeviceIndex = -1; - int m_lastSelectedActionIndex = -1; bool m_enableEncryptionWidget = false;