Add combo box to pick boot loader installation destination
This commit is contained in:
parent
3e3329d4f2
commit
906019facc
@ -45,9 +45,9 @@ QString
|
||||
CreatePartitionJob::prettyName() const
|
||||
{
|
||||
return tr( "Create partition (file system: %1, size: %2 MB) on %3." )
|
||||
.arg( m_partition->fileSystem().name() )
|
||||
.arg( m_partition->capacity() / 1024 / 1024 )
|
||||
.arg( m_device->name() );
|
||||
.arg( m_partition->fileSystem().name() )
|
||||
.arg( m_partition->capacity() / 1024 / 1024 )
|
||||
.arg( m_device->name() );
|
||||
}
|
||||
|
||||
Calamares::JobResult
|
||||
|
@ -36,6 +36,9 @@
|
||||
#include <backend/corebackend.h>
|
||||
#include <backend/corebackendmanager.h>
|
||||
|
||||
// Qt
|
||||
#include <QStandardItemModel>
|
||||
|
||||
class PartitionIterator
|
||||
{
|
||||
public:
|
||||
@ -149,6 +152,7 @@ PartitionCoreModule::DeviceInfo::forgetChanges()
|
||||
PartitionCoreModule::PartitionCoreModule( QObject* parent )
|
||||
: QObject( parent )
|
||||
, m_deviceModel( new DeviceModel( this ) )
|
||||
, m_bootLoaderModel( new QStandardItemModel( this ) )
|
||||
{
|
||||
// FIXME: Should be done at startup
|
||||
if ( !CalaPM::init() )
|
||||
@ -178,6 +182,12 @@ PartitionCoreModule::deviceModel() const
|
||||
return m_deviceModel;
|
||||
}
|
||||
|
||||
QAbstractItemModel*
|
||||
PartitionCoreModule::bootLoaderModel() const
|
||||
{
|
||||
return m_bootLoaderModel;
|
||||
}
|
||||
|
||||
PartitionModel*
|
||||
PartitionCoreModule::partitionModelForDevice( Device* device ) const
|
||||
{
|
||||
@ -322,6 +332,7 @@ PartitionCoreModule::refresh( Device* device )
|
||||
Q_ASSERT( model );
|
||||
model->reload();
|
||||
updateHasRootMountPoint();
|
||||
updateBootLoaderModel();
|
||||
}
|
||||
|
||||
void PartitionCoreModule::updateHasRootMountPoint()
|
||||
@ -352,3 +363,54 @@ PartitionCoreModule::infoForDevice( Device* device ) const
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static QStandardItem*
|
||||
createBootLoaderItem( const QString& description, const QString& path )
|
||||
{
|
||||
QString text = PartitionCoreModule::tr( "%1 (%2)" )
|
||||
.arg( description )
|
||||
.arg( path );
|
||||
QStandardItem* item = new QStandardItem( text );
|
||||
item->setData( path, PartitionCoreModule::BootLoaderPathRole );
|
||||
return item;
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::updateBootLoaderModel()
|
||||
{
|
||||
m_bootLoaderModel->clear();
|
||||
// Can contain up to 2 entries:
|
||||
// - MBR of disk which contains /boot or /
|
||||
// - /boot or / partition
|
||||
QString partitionText;
|
||||
Partition* partition = findPartitionByMountPoint( "/boot" );
|
||||
if ( partition )
|
||||
partitionText = tr( "Boot Partition" );
|
||||
else
|
||||
{
|
||||
partition = findPartitionByMountPoint( "/" );
|
||||
if ( partition )
|
||||
partitionText = tr( "System Partition" );
|
||||
else
|
||||
return;
|
||||
}
|
||||
m_bootLoaderModel->appendRow(
|
||||
createBootLoaderItem( tr( "Master Boot Record" ), partition->devicePath() )
|
||||
);
|
||||
m_bootLoaderModel->appendRow(
|
||||
createBootLoaderItem( partitionText, partition->partitionPath() )
|
||||
);
|
||||
}
|
||||
|
||||
Partition*
|
||||
PartitionCoreModule::findPartitionByMountPoint( const QString& mountPoint ) const
|
||||
{
|
||||
for ( auto deviceInfo : m_deviceInfos )
|
||||
{
|
||||
Device* device = deviceInfo->device.data();
|
||||
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
||||
if ( PartitionInfo::mountPoint( *it ) == mountPoint )
|
||||
return *it;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ class DeviceModel;
|
||||
class FileSystem;
|
||||
class Partition;
|
||||
|
||||
class QStandardItemModel;
|
||||
|
||||
/**
|
||||
* Owns the Qt models and the PM devices
|
||||
*/
|
||||
@ -42,6 +44,11 @@ class PartitionCoreModule : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum
|
||||
{
|
||||
BootLoaderPathRole = Qt::UserRole + 1
|
||||
};
|
||||
|
||||
PartitionCoreModule( QObject* parent = nullptr );
|
||||
~PartitionCoreModule();
|
||||
|
||||
@ -49,6 +56,8 @@ public:
|
||||
|
||||
PartitionModel* partitionModelForDevice( Device* device ) const;
|
||||
|
||||
QAbstractItemModel* bootLoaderModel() const;
|
||||
|
||||
void createPartitionTable( Device* device, PartitionTable::TableType type );
|
||||
|
||||
void createPartition( Device* device, Partition* partition );
|
||||
@ -88,6 +97,7 @@ private:
|
||||
QList< DeviceInfo* > m_deviceInfos;
|
||||
|
||||
DeviceModel* m_deviceModel;
|
||||
QStandardItemModel* m_bootLoaderModel;
|
||||
bool m_hasRootMountPoint = false;
|
||||
|
||||
void listDevices();
|
||||
@ -96,6 +106,10 @@ private:
|
||||
void dumpQueue() const;
|
||||
|
||||
DeviceInfo* infoForDevice( Device* ) const;
|
||||
|
||||
void updateBootLoaderModel();
|
||||
|
||||
Partition* findPartitionByMountPoint( const QString& mountPoint ) const;
|
||||
};
|
||||
|
||||
#endif /* PARTITIONCOREMODULE_H */
|
||||
|
@ -46,6 +46,7 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
||||
{
|
||||
m_ui->setupUi( this );
|
||||
m_ui->deviceComboBox->setModel( m_core->deviceModel() );
|
||||
m_ui->bootLoaderComboBox->setModel( m_core->bootLoaderModel() );
|
||||
updateButtons();
|
||||
|
||||
connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged,
|
||||
|
@ -112,6 +112,56 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Install boot loader on:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>bootLoaderComboBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="bootLoaderComboBox">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
|
Loading…
Reference in New Issue
Block a user