mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-29 02:15:36 -04:00
[partition] Restore selected bootloader
- After the BootLoader model is reset, if a bootloader location has been selected before, try to find it in the (now-reset) model to preserve the selection.
This commit is contained in:
parent
3eae445ead
commit
273c32705d
1 changed files with 35 additions and 0 deletions
|
@ -506,9 +506,44 @@ PartitionPage::updateSelectedBootLoaderIndex()
|
|||
cDebug() << "Selected bootloader index" << m_lastSelectedBootLoaderIndex;
|
||||
}
|
||||
|
||||
int
|
||||
findBootloader( const QAbstractItemModel* model, const QString& path )
|
||||
{
|
||||
for ( int i = 0; i < model->rowCount(); ++i)
|
||||
{
|
||||
const auto index = model->index( i, 0, QModelIndex() );
|
||||
cDebug() << i << model->itemData( index );
|
||||
QVariant var = model->data( index, BootLoaderModel::BootLoaderPathRole );
|
||||
if ( var.isValid() && var.toString() == path )
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
PartitionPage::restoreSelectedBootLoader()
|
||||
{
|
||||
const auto* model = m_ui->bootLoaderComboBox->model();
|
||||
if ( model->rowCount() < 1 )
|
||||
{
|
||||
cDebug() << "No items in BootLoaderModel";
|
||||
return;
|
||||
}
|
||||
|
||||
int r = -1;
|
||||
if ( m_core->bootLoaderInstallPath().isEmpty() )
|
||||
{
|
||||
m_ui->bootLoaderComboBox->setCurrentIndex( 0 );
|
||||
}
|
||||
else if ( (r = findBootloader( model, m_core->bootLoaderInstallPath() )) >= 0 )
|
||||
{
|
||||
m_ui->bootLoaderComboBox->setCurrentIndex( r );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->bootLoaderComboBox->setCurrentIndex( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue