From 625bbb6a4b32acc15a111855de1ab8f24dc77f51 Mon Sep 17 00:00:00 2001 From: Chantara Tith Date: Thu, 5 May 2016 20:28:35 +0700 Subject: [PATCH] Disk selections in partitioner are not sticky --- src/modules/partition/gui/PartitionPage.cpp | 29 +++++++++++++++++++-- src/modules/partition/gui/PartitionPage.h | 2 ++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index 28304192c..0dcc4cce9 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -54,6 +54,7 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent ) : QWidget( parent ) , m_ui( new Ui_PartitionPage ) + , m_lastSelectedBootLoaderIndex(-1) , m_core( core ) { m_ui->setupUi( this ); @@ -74,6 +75,11 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent ) { updateFromCurrentDevice(); } ); + connect( m_ui->bootLoaderComboBox, static_cast(&QComboBox::activated), + [ this ]( const QString& /* text */ ) + { + m_lastSelectedBootLoaderIndex = m_ui->bootLoaderComboBox->currentIndex(); + } ); connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged, [ this ]( const QString& /* text */ ) @@ -94,7 +100,7 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent ) m_ui->bootLoaderComboBox->hide(); m_ui->label_3->hide(); } - + CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); ) } @@ -152,6 +158,9 @@ PartitionPage::onNewPartitionTableClicked() m_core->createPartitionTable( device, type ); } delete dlg; + // PartionModelReset isn't emmited after createPartitionTable, so we have to manually update + // the bootLoader index after the reset. + updateBootLoaderIndex(); } void @@ -188,6 +197,7 @@ PartitionPage::onEditClicked() updatePartitionToCreate( model->device(), partition ); else editExistingPartition( model->device(), partition ); + } void @@ -217,7 +227,12 @@ PartitionPage::onRevertClicked() m_ui->deviceComboBox->setCurrentIndex( oldIndex ); updateFromCurrentDevice(); } ), - []{}, + [ this ]{ + m_lastSelectedBootLoaderIndex = -1; + if( !m_ui->bootLoaderComboBox->currentIndex() >= 0 ) { + m_ui->bootLoaderComboBox->setCurrentIndex( 0 ); + } + }, this ); } @@ -336,4 +351,14 @@ PartitionPage::onPartitionModelReset() { m_ui->partitionTreeView->expandAll(); updateButtons(); + updateBootLoaderIndex(); +} + +void +PartitionPage::updateBootLoaderIndex() +{ + // set bootloader back to user selected index + if ( m_lastSelectedBootLoaderIndex >= 0 && m_ui->bootLoaderComboBox->count() ) { + m_ui->bootLoaderComboBox->setCurrentIndex( m_lastSelectedBootLoaderIndex ); + } } diff --git a/src/modules/partition/gui/PartitionPage.h b/src/modules/partition/gui/PartitionPage.h index aaf971888..2dc02159d 100644 --- a/src/modules/partition/gui/PartitionPage.h +++ b/src/modules/partition/gui/PartitionPage.h @@ -60,8 +60,10 @@ private: void editExistingPartition( Device*, Partition* ); void updateBootLoaderInstallPath(); void updateFromCurrentDevice(); + void updateBootLoaderIndex(); QMutex m_revertMutex; + int m_lastSelectedBootLoaderIndex; }; #endif // PARTITIONPAGE_H