Skip to content
Snippets Groups Projects
Commit 70ddfa25 authored by Teo Mrnjavac's avatar Teo Mrnjavac
Browse files

Disable Alongside if primary partition limit reached on all devices.

parent eabe0c68
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,8 @@
#include "core/DeviceModel.h"
#include "core/PartitionModel.h"
#include "OsproberEntry.h"
#include "core/partitiontable.h"
#include "core/device.h"
#include "PrettyRadioButton.h"
......@@ -111,6 +113,24 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
m_itemsLayout->addWidget( eraseButton );
m_itemsLayout->setSpacing( CalamaresUtils::defaultFontHeight() / 2 );
// TODO 2.0: move this to a Utils namespace.
// Iterate over devices in devicemodel, foreach device, if it's DOS MBR and limit is
// reached and we have an osprober entry inside it, then disable alongside.
QStringList pathsOfDevicesWithPrimariesLimitReached;
for ( int row = 0; row < m_core->deviceModel()->rowCount(); ++row )
{
const QModelIndex& deviceIndex = m_core->deviceModel()->index( row );
Device* dev = m_core->deviceModel()->deviceForIndex( deviceIndex );
if ( ( dev->partitionTable()->type() == PartitionTable::msdos ||
dev->partitionTable()->type() == PartitionTable::msdos_sectorbased ) &&
dev->partitionTable()->numPrimaries() == dev->partitionTable()->maxPrimaries() )
{
// Primaries limit reached!
pathsOfDevicesWithPrimariesLimitReached.append( dev->deviceNode() );
}
}
if ( osproberEntries.count() == 0 )
{
CALAMARES_RETRANSLATE(
......@@ -137,6 +157,18 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
{
QString osName = osproberEntries.first().prettyName;
// Find out if our osprober entry (which is the shrink candidate) is on a
// device that can accommodate more partitions.
bool cantCreatePartitions = false;
foreach ( const QString& devicePath, pathsOfDevicesWithPrimariesLimitReached )
{
if ( osproberEntries.first().path.startsWith( devicePath ) )
{
cantCreatePartitions = true;
break;
}
}
if ( !osName.isEmpty() )
{
CALAMARES_RETRANSLATE(
......@@ -207,6 +239,8 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
}
if ( !osproberEntries.first().canBeResized )
alongsideButton->hide();
if ( cantCreatePartitions )
alongsideButton->hide();
}
else
{
......@@ -223,6 +257,27 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
}
}
// Find out if at least one of our osprober entries is on a
// device that can accommodate more partitions.
bool atLeastOneCanCreatePartitions = false;
foreach ( const OsproberEntry& entry, osproberEntries )
{
bool cantCreatePartitions = false;
foreach ( const QString& devicePath, pathsOfDevicesWithPrimariesLimitReached )
{
if ( entry.path.startsWith( devicePath ) )
{
cantCreatePartitions = true;
break;
}
}
if ( !cantCreatePartitions )
{
atLeastOneCanCreatePartitions = true;
break;
}
}
CALAMARES_RETRANSLATE(
m_messageLabel->setText( tr( "This computer currently has multiple operating systems on it. "
"What would you like to do?" ) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment