Merge pull request #241 from tctara/master

Disk selections in partitioner are not sticky[CAL-361]
This commit is contained in:
Teo Mrnjavac 2016-05-13 19:44:33 +02:00
commit 2050ce97d7
2 changed files with 29 additions and 2 deletions

View File

@ -54,6 +54,7 @@
PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent ) PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, m_ui( new Ui_PartitionPage ) , m_ui( new Ui_PartitionPage )
, m_lastSelectedBootLoaderIndex(-1)
, m_core( core ) , m_core( core )
{ {
m_ui->setupUi( this ); m_ui->setupUi( this );
@ -74,6 +75,11 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
{ {
updateFromCurrentDevice(); updateFromCurrentDevice();
} ); } );
connect( m_ui->bootLoaderComboBox, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::activated),
[ this ]( const QString& /* text */ )
{
m_lastSelectedBootLoaderIndex = m_ui->bootLoaderComboBox->currentIndex();
} );
connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged, connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged,
[ this ]( const QString& /* text */ ) [ this ]( const QString& /* text */ )
@ -152,6 +158,9 @@ PartitionPage::onNewPartitionTableClicked()
m_core->createPartitionTable( device, type ); m_core->createPartitionTable( device, type );
} }
delete dlg; delete dlg;
// PartionModelReset isn't emmited after createPartitionTable, so we have to manually update
// the bootLoader index after the reset.
updateBootLoaderIndex();
} }
void void
@ -188,6 +197,7 @@ PartitionPage::onEditClicked()
updatePartitionToCreate( model->device(), partition ); updatePartitionToCreate( model->device(), partition );
else else
editExistingPartition( model->device(), partition ); editExistingPartition( model->device(), partition );
} }
void void
@ -217,7 +227,12 @@ PartitionPage::onRevertClicked()
m_ui->deviceComboBox->setCurrentIndex( oldIndex ); m_ui->deviceComboBox->setCurrentIndex( oldIndex );
updateFromCurrentDevice(); updateFromCurrentDevice();
} ), } ),
[]{}, [ this ]{
m_lastSelectedBootLoaderIndex = -1;
if( !m_ui->bootLoaderComboBox->currentIndex() >= 0 ) {
m_ui->bootLoaderComboBox->setCurrentIndex( 0 );
}
},
this ); this );
} }
@ -336,4 +351,14 @@ PartitionPage::onPartitionModelReset()
{ {
m_ui->partitionTreeView->expandAll(); m_ui->partitionTreeView->expandAll();
updateButtons(); 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 );
}
} }

View File

@ -60,8 +60,10 @@ private:
void editExistingPartition( Device*, Partition* ); void editExistingPartition( Device*, Partition* );
void updateBootLoaderInstallPath(); void updateBootLoaderInstallPath();
void updateFromCurrentDevice(); void updateFromCurrentDevice();
void updateBootLoaderIndex();
QMutex m_revertMutex; QMutex m_revertMutex;
int m_lastSelectedBootLoaderIndex;
}; };
#endif // PARTITIONPAGE_H #endif // PARTITIONPAGE_H