Revert "Revert "Merge branch 'issue-1098'""
This reverts commit ce4d0e6aea
.
This commit is contained in:
parent
ce4d0e6aea
commit
4b96a4ab24
@ -43,6 +43,25 @@
|
|||||||
namespace PartUtils
|
namespace PartUtils
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static QString
|
||||||
|
convenienceName( const Partition* const candidate )
|
||||||
|
{
|
||||||
|
if ( !candidate->mountPoint().isEmpty() )
|
||||||
|
return candidate->mountPoint();
|
||||||
|
if ( !candidate->partitionPath().isEmpty() )
|
||||||
|
return candidate->partitionPath();
|
||||||
|
if ( !candidate->devicePath().isEmpty() )
|
||||||
|
return candidate->devicePath();
|
||||||
|
if ( !candidate->deviceNode().isEmpty() )
|
||||||
|
return candidate->devicePath();
|
||||||
|
|
||||||
|
QString p;
|
||||||
|
QTextStream s( &p );
|
||||||
|
s << (void *)candidate;
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
canBeReplaced( Partition* candidate )
|
canBeReplaced( Partition* candidate )
|
||||||
{
|
{
|
||||||
@ -64,12 +83,12 @@ canBeReplaced( Partition* candidate )
|
|||||||
<< QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 );
|
<< QString( "(%1GB)" ).arg( requiredStorageB / 1024 / 1024 / 1024 );
|
||||||
cDebug() << "Storage capacity B:" << availableStorageB
|
cDebug() << "Storage capacity B:" << availableStorageB
|
||||||
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
||||||
<< "for" << candidate->partitionPath() << " length:" << candidate->length();
|
<< "for" << convenienceName( candidate ) << " length:" << candidate->length();
|
||||||
|
|
||||||
if ( ok &&
|
if ( ok &&
|
||||||
availableStorageB > requiredStorageB )
|
availableStorageB > requiredStorageB )
|
||||||
{
|
{
|
||||||
cDebug() << "Partition" << candidate->partitionPath() << "authorized for replace install.";
|
cDebug() << "Partition" << convenienceName( candidate ) << "authorized for replace install.";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -86,7 +105,7 @@ canBeResized( Partition* candidate )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cDebug() << "Checking if" << candidate->partitionPath() << "can be resized.";
|
cDebug() << "Checking if" << convenienceName( candidate ) << "can be resized.";
|
||||||
if ( !candidate->fileSystem().supportGrow() ||
|
if ( !candidate->fileSystem().supportGrow() ||
|
||||||
!candidate->fileSystem().supportShrink() )
|
!candidate->fileSystem().supportShrink() )
|
||||||
{
|
{
|
||||||
@ -140,13 +159,13 @@ canBeResized( Partition* candidate )
|
|||||||
<< QString( "(%1GB)" ).arg( advisedStorageGB );
|
<< QString( "(%1GB)" ).arg( advisedStorageGB );
|
||||||
cDebug() << "Available storage B:" << availableStorageB
|
cDebug() << "Available storage B:" << availableStorageB
|
||||||
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
<< QString( "(%1GB)" ).arg( availableStorageB / 1024 / 1024 / 1024 )
|
||||||
<< "for" << candidate->partitionPath() << " length:" << candidate->length()
|
<< "for" << convenienceName( candidate ) << " length:" << candidate->length()
|
||||||
<< " sectorsUsed:" << candidate->sectorsUsed() << " fsType:" << candidate->fileSystem().name();
|
<< " sectorsUsed:" << candidate->sectorsUsed() << " fsType:" << candidate->fileSystem().name();
|
||||||
|
|
||||||
if ( ok &&
|
if ( ok &&
|
||||||
availableStorageB > advisedStorageB )
|
availableStorageB > advisedStorageB )
|
||||||
{
|
{
|
||||||
cDebug() << "Partition" << candidate->partitionPath() << "authorized for resize + autopartition install.";
|
cDebug() << "Partition" << convenienceName( candidate ) << "authorized for resize + autopartition install.";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -382,7 +401,7 @@ isEfiSystem()
|
|||||||
bool
|
bool
|
||||||
isEfiBootable( const Partition* candidate )
|
isEfiBootable( const Partition* candidate )
|
||||||
{
|
{
|
||||||
cDebug() << "Check EFI bootable" << candidate->partitionPath() << candidate->devicePath();
|
cDebug() << "Check EFI bootable" << convenienceName( candidate ) << candidate->devicePath();
|
||||||
cDebug() << " .. flags" << candidate->activeFlags();
|
cDebug() << " .. flags" << candidate->activeFlags();
|
||||||
|
|
||||||
auto flags = PartitionInfo::flags( candidate );
|
auto flags = PartitionInfo::flags( candidate );
|
||||||
|
@ -154,6 +154,9 @@ public:
|
|||||||
|
|
||||||
void setPartitionFlags( Device* device, Partition* partition, PartitionTable::Flags flags );
|
void setPartitionFlags( Device* device, Partition* partition, PartitionTable::Flags flags );
|
||||||
|
|
||||||
|
/// @brief Retrieve the path where the bootloader will be installed
|
||||||
|
QString bootLoaderInstallPath() const { return m_bootLoaderInstallPath; }
|
||||||
|
/// @brief Set the path where the bootloader will be installed
|
||||||
void setBootLoaderInstallPath( const QString& path );
|
void setBootLoaderInstallPath( const QString& path );
|
||||||
|
|
||||||
void initLayout();
|
void initLayout();
|
||||||
|
@ -56,7 +56,6 @@
|
|||||||
#include <kpmcore/ops/removevolumegroupoperation.h>
|
#include <kpmcore/ops/removevolumegroupoperation.h>
|
||||||
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QDebug>
|
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QItemSelectionModel>
|
#include <QItemSelectionModel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -90,22 +89,9 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
|||||||
|
|
||||||
updateFromCurrentDevice();
|
updateFromCurrentDevice();
|
||||||
|
|
||||||
connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged,
|
connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged, this, &PartitionPage::updateFromCurrentDevice );
|
||||||
[ this ]( const QString& /* text */ )
|
connect( m_ui->bootLoaderComboBox, QOverload<int>::of(&QComboBox::activated), this, &PartitionPage::updateSelectedBootLoaderIndex );
|
||||||
{
|
connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged, this, &PartitionPage::updateBootLoaderInstallPath );
|
||||||
updateFromCurrentDevice();
|
|
||||||
} );
|
|
||||||
connect( m_ui->bootLoaderComboBox, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::activated),
|
|
||||||
[ this ]( const QString& /* text */ )
|
|
||||||
{
|
|
||||||
m_lastSelectedBootLoaderIndex = m_ui->bootLoaderComboBox->currentIndex();
|
|
||||||
} );
|
|
||||||
|
|
||||||
connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged,
|
|
||||||
[ this ]( const QString& /* text */ )
|
|
||||||
{
|
|
||||||
updateBootLoaderInstallPath();
|
|
||||||
} );
|
|
||||||
|
|
||||||
connect( m_core, &PartitionCoreModule::isDirtyChanged, m_ui->revertButton, &QWidget::setEnabled );
|
connect( m_core, &PartitionCoreModule::isDirtyChanged, m_ui->revertButton, &QWidget::setEnabled );
|
||||||
|
|
||||||
@ -376,18 +362,18 @@ PartitionPage::onCreateClicked()
|
|||||||
if ( !checkCanCreate( model->device() ) )
|
if ( !checkCanCreate( model->device() ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( model->device(),
|
CreatePartitionDialog dlg(
|
||||||
partition->parent(),
|
model->device(),
|
||||||
nullptr,
|
partition->parent(),
|
||||||
getCurrentUsedMountpoints(),
|
nullptr,
|
||||||
this );
|
getCurrentUsedMountpoints(),
|
||||||
dlg->initFromFreeSpace( partition );
|
this );
|
||||||
if ( dlg->exec() == QDialog::Accepted )
|
dlg.initFromFreeSpace( partition );
|
||||||
|
if ( dlg.exec() == QDialog::Accepted )
|
||||||
{
|
{
|
||||||
Partition* newPart = dlg->createPartition();
|
Partition* newPart = dlg.createPartition();
|
||||||
m_core->createPartition( model->device(), newPart, dlg->newFlags() );
|
m_core->createPartition( model->device(), newPart, dlg.newFlags() );
|
||||||
}
|
}
|
||||||
delete dlg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -508,10 +494,17 @@ PartitionPage::updateBootLoaderInstallPath()
|
|||||||
QVariant var = m_ui->bootLoaderComboBox->currentData( BootLoaderModel::BootLoaderPathRole );
|
QVariant var = m_ui->bootLoaderComboBox->currentData( BootLoaderModel::BootLoaderPathRole );
|
||||||
if ( !var.isValid() )
|
if ( !var.isValid() )
|
||||||
return;
|
return;
|
||||||
qDebug() << "PartitionPage::updateBootLoaderInstallPath" << var.toString();
|
cDebug() << "PartitionPage::updateBootLoaderInstallPath" << var.toString();
|
||||||
m_core->setBootLoaderInstallPath( var.toString() );
|
m_core->setBootLoaderInstallPath( var.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PartitionPage::updateSelectedBootLoaderIndex()
|
||||||
|
{
|
||||||
|
m_lastSelectedBootLoaderIndex = m_ui->bootLoaderComboBox->currentIndex();
|
||||||
|
cDebug() << "Selected bootloader index" << m_lastSelectedBootLoaderIndex;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionPage::updateFromCurrentDevice()
|
PartitionPage::updateFromCurrentDevice()
|
||||||
{
|
{
|
||||||
|
@ -50,6 +50,14 @@ public:
|
|||||||
int selectedDeviceIndex();
|
int selectedDeviceIndex();
|
||||||
void selectDeviceByIndex( int index );
|
void selectDeviceByIndex( int index );
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
/// @brief Update everything when the base device changes
|
||||||
|
void updateFromCurrentDevice();
|
||||||
|
/// @brief Update when the selected device for boot loader changes
|
||||||
|
void updateBootLoaderInstallPath();
|
||||||
|
/// @brief Explicitly selected boot loader path
|
||||||
|
void updateSelectedBootLoaderIndex();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer< Ui_PartitionPage > m_ui;
|
QScopedPointer< Ui_PartitionPage > m_ui;
|
||||||
PartitionCoreModule* m_core;
|
PartitionCoreModule* m_core;
|
||||||
@ -67,8 +75,6 @@ private:
|
|||||||
|
|
||||||
void updatePartitionToCreate( Device*, Partition* );
|
void updatePartitionToCreate( Device*, Partition* );
|
||||||
void editExistingPartition( Device*, Partition* );
|
void editExistingPartition( Device*, Partition* );
|
||||||
void updateBootLoaderInstallPath();
|
|
||||||
void updateFromCurrentDevice();
|
|
||||||
void updateBootLoaderIndex();
|
void updateBootLoaderIndex();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user