Refactor leave event of ChoicePage, add ESP mount point support.

PVS now calls ChoicePage::onLeave, which in turn runs ChoicePage::
doAlongsideApply and/or sets up the ESP mount point based on the UI
state if it's running in EFI mode and the action is Alongside or
Replace.
If setting up under BIOS, Alongside and Replace always install
the bootloader in the MBR of the current device.
This commit is contained in:
Teo Mrnjavac 2016-02-19 16:33:19 +01:00
parent 7ec039f860
commit 7a89b53538
3 changed files with 98 additions and 26 deletions

View File

@ -466,6 +466,45 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current,
} }
void
ChoicePage::onLeave()
{
if ( m_choice == Alongside )
doAlongsideApply();
if ( m_isEfi && ( m_choice == Alongside || m_choice == Replace ) )
{
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 && m_efiComboBox )
{
PartitionInfo::setMountPoint(
efiSystemPartitions.at( m_efiComboBox->currentIndex() ),
Calamares::JobQueue::instance()->
globalStorage()->
value( "efiSystemPartition" ).toString() );
}
else
{
cDebug() << "ERROR: cannot set up EFI system partition.\nESP count:"
<< efiSystemPartitions.count() << "\nm_efiComboBox:"
<< m_efiComboBox;
}
}
else // installPath is then passed to the bootloader module for MBR setup
{
m_core->setBootLoaderInstallPath( selectedDevice()->deviceNode() );
}
}
void void
ChoicePage::doAlongsideApply() ChoicePage::doAlongsideApply()
{ {
@ -504,28 +543,6 @@ ChoicePage::doAlongsideApply()
// have to push it one sector further, therefore + 2 instead of + 1. // have to push it one sector further, therefore + 2 instead of + 1.
m_core->createPartition( dev, newPartition ); 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(); m_core->dumpQueue();
@ -792,6 +809,59 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice )
break; break;
} }
if ( m_isEfi && ( m_choice == Alongside || m_choice == Replace ) )
{
QHBoxLayout* efiLayout = new QHBoxLayout;
layout->addLayout( efiLayout );
m_efiLabel = new QLabel( m_previewAfterFrame );
efiLayout->addWidget( m_efiLabel );
m_efiComboBox = new QComboBox( m_previewAfterFrame );
efiLayout->addWidget( m_efiComboBox );
m_efiLabel->setBuddy( m_efiComboBox );
m_efiComboBox->hide();
efiLayout->addStretch();
// Only the already existing ones:
QList< Partition* > efiSystemPartitions = m_core->efiSystemPartitions();
if ( efiSystemPartitions.count() == 0 ) //should never happen
{
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 ) //probably most usual situation
{
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 );
// We pick an ESP on the currently selected device, if possible
if ( efiPartition->devicePath() == selectedDevice()->deviceNode() &&
efiPartition->number() == 1 )
m_efiComboBox->setCurrentIndex( i );
}
setNextEnabled( true );
}
}
// Also handle selection behavior on beforeFrame. // Also handle selection behavior on beforeFrame.
QAbstractItemView::SelectionMode previewSelectionMode; QAbstractItemView::SelectionMode previewSelectionMode;
switch ( m_choice ) switch ( m_choice )

View File

@ -64,7 +64,7 @@ public:
Choice currentChoice() const; Choice currentChoice() const;
void doAlongsideApply(); void onLeave();
signals: signals:
void nextStatusChanged( bool ); void nextStatusChanged( bool );
@ -87,6 +87,7 @@ private:
void updateActionChoicePreview( ChoicePage::Choice choice ); void updateActionChoicePreview( ChoicePage::Choice choice );
void setupActions(); void setupActions();
OsproberEntryList getOsproberEntriesForDevice( Device* device ) const; OsproberEntryList getOsproberEntriesForDevice( Device* device ) const;
void doAlongsideApply();
bool m_nextEnabled; bool m_nextEnabled;
PartitionCoreModule* m_core; PartitionCoreModule* m_core;
@ -112,6 +113,8 @@ private:
QPointer< PartitionLabelsView > m_afterPartitionLabelsView; QPointer< PartitionLabelsView > m_afterPartitionLabelsView;
QPointer< PartitionSplitterWidget > m_afterPartitionSplitterWidget; QPointer< PartitionSplitterWidget > m_afterPartitionSplitterWidget;
QPointer< QComboBox > m_bootloaderComboBox; QPointer< QComboBox > m_bootloaderComboBox;
QPointer< QLabel > m_efiLabel;
QPointer< QComboBox > m_efiComboBox;
int m_lastSelectedDeviceIndex; int m_lastSelectedDeviceIndex;

View File

@ -363,9 +363,8 @@ PartitionViewStep::onActivate()
void void
PartitionViewStep::onLeave() PartitionViewStep::onLeave()
{ {
if ( m_widget->currentWidget() == m_choicePage && if ( m_widget->currentWidget() == m_choicePage )
m_choicePage->currentChoice() == ChoicePage::Alongside ) m_choicePage->onLeave();
m_choicePage->doAlongsideApply();
} }