From d499fed8a0b72107740845ce4adc1952987b0bbc Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Fri, 29 May 2015 16:45:24 +0200 Subject: [PATCH] Add EFI detection support to Alongside page. --- src/modules/partition/gui/AlongsidePage.cpp | 86 +++++++++++++++++++-- src/modules/partition/gui/AlongsidePage.h | 3 + 2 files changed, 84 insertions(+), 5 deletions(-) diff --git a/src/modules/partition/gui/AlongsidePage.cpp b/src/modules/partition/gui/AlongsidePage.cpp index aecd424c1..fdb189944 100644 --- a/src/modules/partition/gui/AlongsidePage.cpp +++ b/src/modules/partition/gui/AlongsidePage.cpp @@ -39,6 +39,7 @@ #include #include #include +#include AlongsidePage::AlongsidePage( QWidget* parent ) @@ -80,6 +81,20 @@ AlongsidePage::AlongsidePage( QWidget* parent ) m_sizeLabel->setWordWrap( true ); mainLayout->addWidget( m_sizeLabel ); + QBoxLayout* efiLayout = new QHBoxLayout; + m_efiLabel = new QLabel; + m_efiComboBox = new QComboBox; + efiLayout->addWidget( m_efiLabel ); + efiLayout->addWidget( m_efiComboBox ); + m_efiLabel->setBuddy( m_efiComboBox ); + efiLayout->addStretch(); + mainLayout->addLayout( efiLayout ); + + m_efiLabel->hide(); + m_efiComboBox->hide(); + + m_isEfi = QDir( "/sys/firmware/efi/efivars" ).exists(); + mainLayout->addStretch(); } @@ -187,14 +202,54 @@ AlongsidePage::onPartitionSelected( int comboBoxIndex ) string( Calamares::Branding::ProductName ) ); m_splitterWidget->setFixedHeight( qMax< int >( CalamaresUtils::defaultFontHeight() * 1.5, 30 ) ); - if ( ok ) + + m_efiComboBox->hide(); + m_efiLabel->hide(); + + if ( m_isEfi ) { + QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions(); + m_efiLabel->show(); - - + if ( efiSystemPartitions.count() == 0 ) + { + m_efiLabel->setText( + tr( "An EFI system partition cannot be found anywhere " + "on this system. Please go back and use manual " + "partitioning to set up %1." ) + .arg( Calamares::Branding::instance()-> + string( Calamares::Branding::ShortProductName ) ) ); + setNextEnabled( false ); + } + else if ( efiSystemPartitions.count() == 1 ) + { + m_efiLabel->setText( + tr( "The EFI system partition at %1 will be used for " + "starting %2." ) + .arg( efiSystemPartitions.first()->partitionPath() ) + .arg( Calamares::Branding::instance()-> + string( Calamares::Branding::ShortProductName ) ) ); + setNextEnabled( true ); + } + else + { + m_efiComboBox->show(); + m_efiLabel->setText( tr( "EFI system partition:" ) ); + for ( int i = 0; i < efiSystemPartitions.count(); ++i ) + { + Partition* efiPartition = efiSystemPartitions.at( i ); + m_efiComboBox->addItem( efiPartition->partitionPath(), i ); + if ( efiPartition->devicePath() == candidate->devicePath() && + efiPartition->number() == 1 ) + m_efiComboBox->setCurrentIndex( i ); + } + setNextEnabled( true ); + } + } + else + { + setNextEnabled( true ); } - - setNextEnabled( true ); return; } } @@ -245,6 +300,27 @@ AlongsidePage::applyChanges() m_core->createPartition( dev, newPartition ); m_core->setBootLoaderInstallPath( dev->deviceNode() ); + if ( m_isEfi ) + { + QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions(); + if ( efiSystemPartitions.count() == 1 ) + { + PartitionInfo::setMountPoint( + efiSystemPartitions.first(), + Calamares::JobQueue::instance()-> + globalStorage()-> + value( "efiSystemPartition" ).toString() ); + } + else if ( efiSystemPartitions.count() > 1 ) + { + PartitionInfo::setMountPoint( + efiSystemPartitions.at( m_efiComboBox->currentIndex() ), + Calamares::JobQueue::instance()-> + globalStorage()-> + value( "efiSystemPartition" ).toString() ); + } + } + m_core->dumpQueue(); break; diff --git a/src/modules/partition/gui/AlongsidePage.h b/src/modules/partition/gui/AlongsidePage.h index 8a7d05306..3583666e8 100644 --- a/src/modules/partition/gui/AlongsidePage.h +++ b/src/modules/partition/gui/AlongsidePage.h @@ -57,6 +57,9 @@ private: PartitionPreview* m_previewWidget; QLabel* m_sizeLabel; + QLabel* m_efiLabel; + QComboBox* m_efiComboBox; + PartitionCoreModule* m_core; bool m_isEfi;