Merge branch 'master' into requirements-checking

This commit is contained in:
Adriaan de Groot 2018-08-10 12:02:57 -04:00
commit bf40f3bd23
462 changed files with 28533 additions and 17939 deletions

View file

@ -1,7 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -2,6 +2,9 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Andrius Štikonas <andrius@stikonas.eu>
* Copyright 2018, Caio Carvalho <caiojcarvalho@gmail.com>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,6 +26,7 @@
#include "core/PartitionInfo.h"
#include "core/PartUtils.h"
#include "core/KPMHelpers.h"
#include "gui/PartitionDialogHelpers.h"
#include "gui/PartitionSizeController.h"
#include "ui_CreatePartitionDialog.h"
@ -56,7 +60,7 @@ static QSet< FileSystem::Type > s_unmountableFS(
FileSystem::Lvm2_PV
} );
CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* parentPartition, const QStringList& usedMountPoints, QWidget* parentWidget )
CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* parentPartition, Partition* partition, const QStringList& usedMountPoints, QWidget* parentWidget )
: QDialog( parentWidget )
, m_ui( new Ui_CreatePartitionDialog )
, m_partitionSizeController( new PartitionSizeController( this ) )
@ -68,11 +72,11 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
m_ui->encryptWidget->setText( tr( "En&crypt" ) );
m_ui->encryptWidget->hide();
if (m_device->type() == Device::Disk_Device) {
if (m_device->type() == Device::Type::Disk_Device) {
m_ui->lvNameLabel->hide();
m_ui->lvNameLineEdit->hide();
}
if (m_device->type() == Device::LVM_Device) {
if (m_device->type() == Device::Type::LVM_Device) {
/* LVM logical volume name can consist of: letters numbers _ . - +
* It cannot start with underscore _ and must not be equal to . or .. or any entry in /dev/
* QLineEdit accepts QValidator::Intermediate, so we just disable . at the beginning */
@ -81,12 +85,7 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
m_ui->lvNameLineEdit->setValidator(validator);
}
QStringList mountPoints = { "/", "/boot", "/home", "/opt", "/usr", "/var" };
if ( PartUtils::isEfiSystem() )
mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString();
mountPoints.removeDuplicates();
mountPoints.sort();
m_ui->mountPointComboBox->addItems( mountPoints );
standardMountPoints( *(m_ui->mountPointComboBox), partition ? PartitionInfo::mountPoint( partition ) : QString() );
if ( device->partitionTable()->type() == PartitionTable::msdos ||
device->partitionTable()->type() == PartitionTable::msdos_sectorbased )
@ -125,7 +124,8 @@ CreatePartitionDialog::CreatePartitionDialog( Device* device, PartitionNode* par
m_ui->fsComboBox->setCurrentIndex( defaultFsIndex );
updateMountPointUi();
setupFlagsList();
setFlagList( *(m_ui->m_listFlags), static_cast< PartitionTable::Flags >( ~PartitionTable::Flags::Int(0) ), partition ? PartitionInfo::flags( partition ) : PartitionTable::Flags() );
// Checks the initial selection.
checkMountPointSelection();
}
@ -137,35 +137,9 @@ CreatePartitionDialog::~CreatePartitionDialog()
PartitionTable::Flags
CreatePartitionDialog::newFlags() const
{
PartitionTable::Flags flags;
for ( int i = 0; i < m_ui->m_listFlags->count(); i++ )
if ( m_ui->m_listFlags->item( i )->checkState() == Qt::Checked )
flags |= static_cast< PartitionTable::Flag >(
m_ui->m_listFlags->item( i )->data( Qt::UserRole ).toInt() );
return flags;
return flagsFromList( *(m_ui->m_listFlags) );
}
void
CreatePartitionDialog::setupFlagsList()
{
int f = 1;
QString s;
while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() )
{
QListWidgetItem* item = new QListWidgetItem( s );
m_ui->m_listFlags->addItem( item );
item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
item->setData( Qt::UserRole, f );
item->setCheckState( Qt::Unchecked );
f <<= 1;
}
}
void
CreatePartitionDialog::initMbrPartitionTypeUi()
{
@ -242,11 +216,11 @@ CreatePartitionDialog::createPartition()
);
}
if (m_device->type() == Device::LVM_Device) {
if (m_device->type() == Device::Type::LVM_Device) {
partition->setPartitionPath(m_device->deviceNode() + QStringLiteral("/") + m_ui->lvNameLineEdit->text().trimmed());
}
PartitionInfo::setMountPoint( partition, m_ui->mountPointComboBox->currentText() );
PartitionInfo::setMountPoint( partition, selectedMountPoint( m_ui->mountPointComboBox ) );
PartitionInfo::setFormat( partition, true );
return partition;
@ -261,7 +235,9 @@ CreatePartitionDialog::updateMountPointUi()
FileSystem::Type type = FileSystem::typeForName( m_ui->fsComboBox->currentText() );
enabled = !s_unmountableFS.contains( type );
if ( FS::luks::canEncryptType( type ) )
if ( FileSystemFactory::map()[FileSystem::Type::Luks]->supportCreate() &&
FS::luks::canEncryptType( type ) &&
!m_role.has( PartitionRole::Extended ) )
{
m_ui->encryptWidget->show();
m_ui->encryptWidget->reset();
@ -281,9 +257,7 @@ CreatePartitionDialog::updateMountPointUi()
void
CreatePartitionDialog::checkMountPointSelection()
{
const QString& selection = m_ui->mountPointComboBox->currentText();
if ( m_usedMountPoints.contains( selection ) )
if ( m_usedMountPoints.contains( selectedMountPoint( m_ui->mountPointComboBox ) ) )
{
m_ui->labelMountPoint->setText( tr( "Mountpoint already in use. Please select another one." ) );
m_ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
@ -332,7 +306,7 @@ CreatePartitionDialog::initFromPartitionToCreate( Partition* partition )
m_ui->fsComboBox->setCurrentText( FileSystem::nameForType( fsType ) );
// Mount point
m_ui->mountPointComboBox->setCurrentText( PartitionInfo::mountPoint( partition ) );
setSelectedMountPoint( m_ui->mountPointComboBox, PartitionInfo::mountPoint( partition ) );
updateMountPointUi();
}

View file

@ -2,6 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -42,7 +43,13 @@ class CreatePartitionDialog : public QDialog
{
Q_OBJECT
public:
CreatePartitionDialog( Device* device, PartitionNode* parentPartition, const QStringList& usedMountPoints, QWidget* parentWidget = nullptr );
/**
* @brief Dialog for editing a new partition.
*
* For the (unlikely) case that a newly created partition is being re-edited,
* pass a pointer to that @p partition, otherwise pass nullptr.
*/
CreatePartitionDialog( Device* device, PartitionNode* parentPartition, Partition* partition, const QStringList& usedMountPoints, QWidget* parentWidget = nullptr );
~CreatePartitionDialog();
/**
@ -64,7 +71,6 @@ private Q_SLOTS:
void checkMountPointSelection();
private:
void setupFlagsList();
QScopedPointer< Ui_CreatePartitionDialog > m_ui;
PartitionSizeController* m_partitionSizeController;
Device* m_device;

View file

@ -0,0 +1,56 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "CreateVolumeGroupDialog.h"
#include <kpmcore/core/device.h>
#include <kpmcore/core/lvmdevice.h>
#include <QComboBox>
#include <QLineEdit>
#include <QSpinBox>
CreateVolumeGroupDialog::CreateVolumeGroupDialog( QString& vgName,
QVector< const Partition* >& selectedPVs,
QVector< const Partition* > pvList,
qint64& pSize,
QWidget* parent )
: VolumeGroupBaseDialog( vgName, pvList, parent )
, m_selectedPVs( selectedPVs )
, m_peSize( pSize )
{
setWindowTitle( "Create Volume Group" );
peSize()->setValue( pSize );
vgType()->setEnabled( false );
}
void
CreateVolumeGroupDialog::accept()
{
QString& name = vgNameValue();
name = vgName()->text();
m_selectedPVs << checkedItems();
qint64& pe = m_peSize;
pe = peSize()->value();
QDialog::accept();
}

View file

@ -0,0 +1,41 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CREATEVOLUMEGROUPDIALOG_H
#define CREATEVOLUMEGROUPDIALOG_H
#include "gui/VolumeGroupBaseDialog.h"
class CreateVolumeGroupDialog : public VolumeGroupBaseDialog
{
public:
CreateVolumeGroupDialog( QString& vgName,
QVector< const Partition* >& selectedPVs,
QVector< const Partition* > pvList,
qint64& pSize,
QWidget* parent );
void accept() override;
private:
QVector< const Partition* >& m_selectedPVs;
qint64& m_peSize;
};
#endif // CREATEVOLUMEGROUPDIALOG_H

View file

@ -2,6 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Flags handling originally from KDE Partition Manager,
* Copyright 2008-2009, Volker Lanz <vl@fidra.de>
@ -28,6 +29,7 @@
#include <core/PartitionInfo.h>
#include "core/PartUtils.h"
#include <core/KPMHelpers.h>
#include "gui/PartitionDialogHelpers.h"
#include <gui/PartitionSizeController.h>
#include <ui_EditExistingPartitionDialog.h>
@ -55,19 +57,12 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
, m_usedMountPoints( usedMountPoints )
{
m_ui->setupUi( this );
QStringList mountPoints = { "/", "/boot", "/home", "/opt", "/usr", "/var" };
if ( PartUtils::isEfiSystem() )
mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString();
mountPoints.removeDuplicates();
mountPoints.sort();
m_ui->mountPointComboBox->addItems( mountPoints );
standardMountPoints( *(m_ui->mountPointComboBox), PartitionInfo::mountPoint( partition ) );
QColor color = ColorUtils::colorForPartition( m_partition );
m_partitionSizeController->init( m_device, m_partition, color );
m_partitionSizeController->setSpinBox( m_ui->sizeSpinBox );
m_ui->mountPointComboBox->setCurrentText( PartitionInfo::mountPoint( partition ) );
connect( m_ui->mountPointComboBox, &QComboBox::currentTextChanged,
this, &EditExistingPartitionDialog::checkMountPointSelection );
@ -112,7 +107,7 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
m_ui->fileSystemLabel->setEnabled( m_ui->formatRadioButton->isChecked() );
m_ui->fileSystemComboBox->setEnabled( m_ui->formatRadioButton->isChecked() );
setupFlagsList();
setFlagList( *(m_ui->m_listFlags), m_partition->availableFlags(), PartitionInfo::flags( m_partition ) );
}
@ -123,44 +118,13 @@ EditExistingPartitionDialog::~EditExistingPartitionDialog()
PartitionTable::Flags
EditExistingPartitionDialog::newFlags() const
{
PartitionTable::Flags flags;
for ( int i = 0; i < m_ui->m_listFlags->count(); i++ )
if ( m_ui->m_listFlags->item( i )->checkState() == Qt::Checked )
flags |= static_cast< PartitionTable::Flag >(
m_ui->m_listFlags->item( i )->data( Qt::UserRole ).toInt() );
return flags;
return flagsFromList( *(m_ui->m_listFlags) );
}
void
EditExistingPartitionDialog::setupFlagsList()
{
int f = 1;
QString s;
while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() )
{
if ( m_partition->availableFlags() & f )
{
QListWidgetItem* item = new QListWidgetItem( s );
m_ui->m_listFlags->addItem( item );
item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
item->setData( Qt::UserRole, f );
item->setCheckState( ( m_partition->activeFlags() & f ) ?
Qt::Checked :
Qt::Unchecked );
}
f <<= 1;
}
}
void
EditExistingPartitionDialog::applyChanges( PartitionCoreModule* core )
{
PartitionInfo::setMountPoint( m_partition, m_ui->mountPointComboBox->currentText() );
PartitionInfo::setMountPoint( m_partition, selectedMountPoint(m_ui->mountPointComboBox) );
qint64 newFirstSector = m_partitionSizeController->firstSector();
qint64 newLastSector = m_partitionSizeController->lastSector();
@ -294,15 +258,13 @@ EditExistingPartitionDialog::updateMountPointPicker()
m_ui->mountPointLabel->setEnabled( canMount );
m_ui->mountPointComboBox->setEnabled( canMount );
if ( !canMount )
m_ui->mountPointComboBox->setCurrentText( QString() );
setSelectedMountPoint( m_ui->mountPointComboBox, QString() );
}
void
EditExistingPartitionDialog::checkMountPointSelection()
{
const QString& selection = m_ui->mountPointComboBox->currentText();
if ( m_usedMountPoints.contains( selection ) )
if ( m_usedMountPoints.contains( selectedMountPoint( m_ui->mountPointComboBox ) ) )
{
m_ui->labelMountPoint->setText( tr( "Mountpoint already in use. Please select another one." ) );
m_ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false );

View file

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -56,7 +57,6 @@ private:
QStringList m_usedMountPoints;
PartitionTable::Flags newFlags() const;
void setupFlagsList();
void replacePartResizerWidget();
void updateMountPointPicker();
};

View file

@ -0,0 +1,36 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ListPhysicalVolumeWidgetItem.h"
#include <kpmcore/util/capacity.h>
ListPhysicalVolumeWidgetItem::ListPhysicalVolumeWidgetItem( const Partition* partition, bool checked )
: QListWidgetItem(QString("%1 | %2").arg( partition->deviceNode(), Capacity::formatByteSize( partition->capacity() )))
, m_partition(partition)
{
setToolTip( partition->deviceNode() );
setSizeHint( QSize(0, 32) );
setCheckState( checked ? Qt::Checked : Qt::Unchecked );
}
const Partition*
ListPhysicalVolumeWidgetItem::partition() const
{
return m_partition;
}

View file

@ -0,0 +1,37 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LISTPHYSICALVOLUMEWIDGETITEM_H
#define LISTPHYSICALVOLUMEWIDGETITEM_H
#include <kpmcore/core/partition.h>
#include <QListWidgetItem>
class ListPhysicalVolumeWidgetItem : public QListWidgetItem
{
public:
ListPhysicalVolumeWidgetItem( const Partition* partition, bool checked );
const Partition* partition() const;
private:
const Partition* m_partition;
};
#endif // LISTPHYSICALVOLUMEWIDGETITEM_H

View file

@ -0,0 +1,118 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PartitionDialogHelpers.h"
#include "core/PartUtils.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/Logger.h"
#include <QComboBox>
#include <QListWidget>
QStringList
standardMountPoints()
{
QStringList mountPoints{ "/", "/boot", "/home", "/opt", "/srv", "/usr", "/var" };
if ( PartUtils::isEfiSystem() )
mountPoints << Calamares::JobQueue::instance()->globalStorage()->value( "efiSystemPartition" ).toString();
mountPoints.removeDuplicates();
mountPoints.sort();
return mountPoints;
}
void
standardMountPoints(QComboBox& combo)
{
combo.clear();
combo.addItem( combo.tr( "(no mount point)" ) );
combo.addItems( standardMountPoints() );
}
void
standardMountPoints(QComboBox& combo, const QString& selected)
{
standardMountPoints( combo );
setSelectedMountPoint( combo, selected );
}
QString
selectedMountPoint(QComboBox& combo)
{
if ( combo.currentIndex() == 0 )
return QString();
return combo.currentText();
}
void
setSelectedMountPoint(QComboBox& combo, const QString& selected)
{
if ( selected.isEmpty() )
combo.setCurrentIndex( 0 ); // (no mount point)
else
{
for ( int i = 0; i < combo.count(); ++i )
if ( selected == combo.itemText( i ) )
{
combo.setCurrentIndex( i );
return;
}
combo.addItem( selected );
combo.setCurrentIndex( combo.count() - 1);
}
}
PartitionTable::Flags
flagsFromList( const QListWidget& list )
{
PartitionTable::Flags flags;
for ( int i = 0; i < list.count(); i++ )
if ( list.item( i )->checkState() == Qt::Checked )
flags |= static_cast< PartitionTable::Flag >(
list.item( i )->data( Qt::UserRole ).toInt() );
return flags;
}
void
setFlagList( QListWidget& list, PartitionTable::Flags available, PartitionTable::Flags checked )
{
int f = 1;
QString s;
while ( !( s = PartitionTable::flagName( static_cast< PartitionTable::Flag >( f ) ) ).isEmpty() )
{
if ( available & f )
{
QListWidgetItem* item = new QListWidgetItem( s );
list.addItem( item );
item->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled );
item->setData( Qt::UserRole, f );
item->setCheckState( ( checked & f ) ?
Qt::Checked :
Qt::Unchecked );
}
f <<= 1;
}
}

View file

@ -0,0 +1,68 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PARTITION_GUI_PARTITIONDIALOGHELPERS
#define PARTITION_GUI_PARTITIONDIALOGHELPERS
#include <kpmcore/core/partitiontable.h>
#include <QStringList>
class QComboBox;
class QListWidget;
/**
* Returns a list of standard mount points (e.g. /, /usr, ...).
* This also includes the EFI mount point if that is necessary
* on the target system.
*/
QStringList standardMountPoints();
/**
* Clears the combobox and fills it with "(no mount point)"
* and the elements of standardMountPoints(), above.
*/
void standardMountPoints( QComboBox& );
/**
* As above, but also sets the displayed mount point to @p selected,
* unless it is empty, in which case "(no mount point)" is chosen.
*/
void standardMountPoints( QComboBox&, const QString& selected );
/**
* Get the mount point selected in the combo box (which should
* have been set up with standardMountPoints(), above); this
* will map the topmost item (i.e. "(no mount point)") back
* to blank, to allow easy detection of no-mount-selected.
*/
QString selectedMountPoint( QComboBox& combo );
static inline QString selectedMountPoint(QComboBox* combo) { return selectedMountPoint(*combo); }
void setSelectedMountPoint( QComboBox& combo, const QString& selected );
static inline void setSelectedMountPoint(QComboBox* combo, const QString& selected) { setSelectedMountPoint( *combo, selected); }
/**
* Get the flags that have been checked in the list widget.
*/
PartitionTable::Flags flagsFromList( const QListWidget& list );
void setFlagList( QListWidget& list, PartitionTable::Flags available, PartitionTable::Flags checked );
#endif

View file

@ -2,6 +2,8 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2015-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
* Copyright 2018, Andrius Štikonas <andrius@stikonas.eu>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -28,12 +30,15 @@
#include "core/PartUtils.h"
#include "core/KPMHelpers.h"
#include "gui/CreatePartitionDialog.h"
#include "gui/CreateVolumeGroupDialog.h"
#include "gui/EditExistingPartitionDialog.h"
#include "gui/ResizeVolumeGroupDialog.h"
#include "gui/ScanningDialog.h"
#include "ui_PartitionPage.h"
#include "ui_CreatePartitionTableDialog.h"
#include "utils/Logger.h"
#include "utils/Retranslator.h"
#include "Branding.h"
#include "JobQueue.h"
@ -42,6 +47,8 @@
// KPMcore
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/ops/deactivatevolumegroupoperation.h>
#include <kpmcore/ops/removevolumegroupoperation.h>
// Qt
#include <QDebug>
@ -99,6 +106,10 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
connect( m_ui->partitionTreeView, &QAbstractItemView::doubleClicked, this, &PartitionPage::onPartitionViewActivated );
connect( m_ui->revertButton, &QAbstractButton::clicked, this, &PartitionPage::onRevertClicked );
connect( m_ui->newVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onNewVolumeGroupClicked );
connect( m_ui->resizeVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onResizeVolumeGroupClicked );
connect( m_ui->deactivateVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onDeactivateVolumeGroupClicked );
connect( m_ui->removeVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onRemoveVolumeGroupClicked );
connect( m_ui->newPartitionTableButton, &QAbstractButton::clicked, this, &PartitionPage::onNewPartitionTableClicked );
connect( m_ui->createButton, &QAbstractButton::clicked, this, &PartitionPage::onCreateClicked );
connect( m_ui->editButton, &QAbstractButton::clicked, this, &PartitionPage::onEditClicked );
@ -119,7 +130,8 @@ PartitionPage::~PartitionPage()
void
PartitionPage::updateButtons()
{
bool create = false, createTable = false, edit = false, del = false;
bool create = false, createTable = false, edit = false, del = false, currentDeviceIsVG = false, isDeactivable = false;
bool isRemovable = false, isVGdeactivated = false;
QModelIndex index = m_ui->partitionTreeView->currentIndex();
if ( index.isValid() )
@ -131,6 +143,8 @@ PartitionPage::updateButtons()
bool isFree = KPMHelpers::isPartitionFreeSpace( partition );
bool isExtended = partition->roles().has( PartitionRole::Extended );
bool isInVG = m_core->isInVG( partition );
create = isFree;
// Keep it simple for now: do not support editing extended partitions as
// it does not work with our current edit implementation which is
@ -138,21 +152,39 @@ PartitionPage::updateButtons()
// because they need to be created *before* creating logical partitions
// inside them, so an edit must be applied without altering the job
// order.
// TODO: See if LVM PVs can be edited in Calamares
edit = !isFree && !isExtended;
del = !isFree;
del = !isFree && !isInVG;
}
if ( m_ui->deviceComboBox->currentIndex() >= 0 )
{
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
if ( m_core->deviceModel()->deviceForIndex( deviceIndex )->type() != Device::LVM_Device )
if ( m_core->deviceModel()->deviceForIndex( deviceIndex )->type() != Device::Type::LVM_Device )
createTable = true;
else
{
currentDeviceIsVG = true;
LvmDevice* lvmDevice = dynamic_cast<LvmDevice*>(m_core->deviceModel()->deviceForIndex( deviceIndex ));
isDeactivable = DeactivateVolumeGroupOperation::isDeactivatable( lvmDevice );
isRemovable = RemoveVolumeGroupOperation::isRemovable( lvmDevice );
isVGdeactivated = m_core->isVGdeactivated( lvmDevice );
if ( isVGdeactivated )
m_ui->revertButton->setEnabled( true );
}
}
m_ui->createButton->setEnabled( create );
m_ui->editButton->setEnabled( edit );
m_ui->deleteButton->setEnabled( del );
m_ui->newPartitionTableButton->setEnabled( createTable );
m_ui->resizeVolumeGroupButton->setEnabled( currentDeviceIsVG && !isVGdeactivated );
m_ui->deactivateVolumeGroupButton->setEnabled( currentDeviceIsVG && isDeactivable && !isVGdeactivated );
m_ui->removeVolumeGroupButton->setEnabled( currentDeviceIsVG && isRemovable );
}
void
@ -178,6 +210,137 @@ PartitionPage::onNewPartitionTableClicked()
updateBootLoaderIndex();
}
bool
PartitionPage::checkCanCreate( Device* device )
{
auto table = device->partitionTable();
if ( table->type() == PartitionTable::msdos ||table->type() == PartitionTable::msdos_sectorbased )
{
cDebug() << "Checking MSDOS partition" << table->numPrimaries() << "primaries, max" << table->maxPrimaries();
if ( ( table->numPrimaries() >= table->maxPrimaries() ) && !table->hasExtended() )
{
QMessageBox::warning( this, tr( "Can not create new partition" ),
tr( "The partition table on %1 already has %2 primary partitions, and no more can be added. "
"Please remove one primary partition and add an extended partition, instead." ).arg( device->name() ).arg( table->numPrimaries() )
);
return false;
}
return true;
}
else
return true; // GPT is fine
}
void
PartitionPage::onNewVolumeGroupClicked()
{
QString vgName;
QVector< const Partition* > selectedPVs;
qint64 peSize = 4;
QVector< const Partition* > availablePVs;
for ( const Partition* p : m_core->lvmPVs() )
if ( !m_core->isInVG( p ) )
availablePVs << p;
QPointer< CreateVolumeGroupDialog > dlg = new CreateVolumeGroupDialog( vgName,
selectedPVs,
availablePVs,
peSize,
this );
if ( dlg->exec() == QDialog::Accepted )
{
QModelIndex partitionIndex = m_ui->partitionTreeView->currentIndex();
if ( partitionIndex.isValid() )
{
const PartitionModel* model = static_cast< const PartitionModel* >( partitionIndex.model() );
Q_ASSERT( model );
Partition* partition = model->partitionForIndex( partitionIndex );
Q_ASSERT( partition );
// Disable delete button if current partition was selected to be in VG
// TODO: Should Calamares edit LVM PVs which are in VGs?
if ( selectedPVs.contains( partition ) )
m_ui->deleteButton->setEnabled( false );
}
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
Q_ASSERT( deviceIndex.isValid() );
QVariant previousIndexDeviceData = m_core->deviceModel()->data( deviceIndex, Qt::ToolTipRole );
// Creating new VG
m_core->createVolumeGroup( vgName, selectedPVs, peSize );
// As createVolumeGroup method call resets deviceModel,
// is needed to set the current index in deviceComboBox as the previous one
int previousIndex = m_ui->deviceComboBox->findData( previousIndexDeviceData, Qt::ToolTipRole );
m_ui->deviceComboBox->setCurrentIndex( ( previousIndex < 0 ) ? 0 : previousIndex );
updateFromCurrentDevice();
}
delete dlg;
}
void
PartitionPage::onResizeVolumeGroupClicked()
{
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
LvmDevice* device = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );
Q_ASSERT( device && device->type() == Device::Type::LVM_Device );
QVector< const Partition* > availablePVs;
QVector< const Partition* > selectedPVs;
for ( const Partition* p : m_core->lvmPVs() )
if ( !m_core->isInVG( p ) )
availablePVs << p;
QPointer< ResizeVolumeGroupDialog > dlg = new ResizeVolumeGroupDialog( device,
availablePVs,
selectedPVs,
this );
if ( dlg->exec() == QDialog::Accepted )
m_core->resizeVolumeGroup( device, selectedPVs );
delete dlg;
}
void
PartitionPage::onDeactivateVolumeGroupClicked()
{
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
LvmDevice* device = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );
Q_ASSERT( device && device->type() == Device::Type::LVM_Device );
m_core->deactivateVolumeGroup( device );
updateFromCurrentDevice();
PartitionModel* model = m_core->partitionModelForDevice( device );
model->update();
}
void
PartitionPage::onRemoveVolumeGroupClicked()
{
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
LvmDevice* device = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );
Q_ASSERT( device && device->type() == Device::Type::LVM_Device );
m_core->removeVolumeGroup( device );
}
void
PartitionPage::onCreateClicked()
{
@ -188,8 +351,12 @@ PartitionPage::onCreateClicked()
Partition* partition = model->partitionForIndex( index );
Q_ASSERT( partition );
if ( !checkCanCreate( model->device() ) )
return;
QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( model->device(),
partition->parent(),
nullptr,
getCurrentUsedMountpoints(),
this );
dlg->initFromFreeSpace( partition );
@ -242,7 +409,7 @@ PartitionPage::onRevertClicked()
int oldIndex = m_ui->deviceComboBox->currentIndex();
m_core->revertAllDevices();
m_ui->deviceComboBox->setCurrentIndex( oldIndex );
m_ui->deviceComboBox->setCurrentIndex( ( oldIndex < 0 ) ? 0 : oldIndex );
updateFromCurrentDevice();
} ),
[ this ]{
@ -285,6 +452,7 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition )
QPointer< CreatePartitionDialog > dlg = new CreatePartitionDialog( device,
partition->parent(),
partition,
mountPoints,
this );
dlg->initFromPartitionToCreate( partition );

View file

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -50,6 +51,10 @@ private:
PartitionCoreModule* m_core;
void updateButtons();
void onNewPartitionTableClicked();
void onNewVolumeGroupClicked();
void onResizeVolumeGroupClicked();
void onDeactivateVolumeGroupClicked();
void onRemoveVolumeGroupClicked();
void onCreateClicked();
void onEditClicked();
void onDeleteClicked();
@ -62,6 +67,14 @@ private:
void updateFromCurrentDevice();
void updateBootLoaderIndex();
/**
* @brief Check if a new partition can be created (as primary) on the device.
*
* Returns true if a new partition can be created on the device. Provides
* a warning popup and returns false if it cannot.
*/
bool checkCanCreate( Device* );
QStringList getCurrentUsedMountpoints();
QMutex m_revertMutex;

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>655</width>
<width>684</width>
<height>304</height>
</rect>
</property>
@ -104,7 +104,7 @@
<item>
<widget class="QPushButton" name="createButton">
<property name="text">
<string>&amp;Create</string>
<string>Cre&amp;ate</string>
</property>
</widget>
</item>
@ -124,6 +124,38 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="newVolumeGroupButton">
<property name="text">
<string>New Volume Group</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resizeVolumeGroupButton">
<property name="text">
<string>Resize Volume Group</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deactivateVolumeGroupButton">
<property name="text">
<string>Deactivate Volume Group</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeVolumeGroupButton">
<property name="text">
<string>Remove Volume Group</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@ -145,7 +177,7 @@
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Install boot &amp;loader on:</string>
<string>I&amp;nstall boot loader on:</string>
</property>
<property name="buddy">
<cstring>bootLoaderComboBox</cstring>

View file

@ -2,6 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -2,6 +2,7 @@
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2018, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -0,0 +1,62 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ResizeVolumeGroupDialog.h"
#include "gui/ListPhysicalVolumeWidgetItem.h"
#include <kpmcore/core/lvmdevice.h>
#include <kpmcore/util/capacity.h>
#include <QComboBox>
#include <QLineEdit>
#include <QListWidgetItem>
#include <QSpinBox>
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog( LvmDevice *device,
QVector< const Partition* > availablePVs,
QVector< const Partition* >& selectedPVs,
QWidget* parent )
: VolumeGroupBaseDialog( device->name(), device->physicalVolumes(), parent )
, m_selectedPVs( selectedPVs )
{
setWindowTitle( "Resize Volume Group" );
for ( int i = 0; i < pvList()->count(); i++ )
pvList()->item(i)->setCheckState( Qt::Checked );
for ( const Partition* p : availablePVs )
pvList()->addItem( new ListPhysicalVolumeWidgetItem( p, false ) );
peSize()->setValue( device->peSize() / Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB) );
vgName()->setEnabled( false );
peSize()->setEnabled( false );
vgType()->setEnabled( false );
setUsedSizeValue( device->allocatedPE() * device->peSize() );
setLVQuantity( device->partitionTable()->children().count() );
}
void
ResizeVolumeGroupDialog::accept()
{
m_selectedPVs << checkedItems();
QDialog::accept();
}

View file

@ -0,0 +1,40 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RESIZEVOLUMEGROUPDIALOG_H
#define RESIZEVOLUMEGROUPDIALOG_H
#include "gui/VolumeGroupBaseDialog.h"
class LvmDevice;
class ResizeVolumeGroupDialog : public VolumeGroupBaseDialog
{
public:
ResizeVolumeGroupDialog( LvmDevice *device,
QVector< const Partition* > availablePVs,
QVector< const Partition* >& selectedPVs,
QWidget* parent );
void accept() override;
private:
QVector< const Partition* >& m_selectedPVs;
};
#endif // RESIZEVOLUMEGROUPDIALOG_H

View file

@ -0,0 +1,184 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "VolumeGroupBaseDialog.h"
#include "ui_VolumeGroupBaseDialog.h"
#include "gui/ListPhysicalVolumeWidgetItem.h"
#include <kpmcore/util/capacity.h>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QSpinBox>
VolumeGroupBaseDialog::VolumeGroupBaseDialog( QString& vgName,
QVector< const Partition* > pvList,
QWidget *parent )
: QDialog(parent)
, ui(new Ui::VolumeGroupBaseDialog)
, m_vgNameValue(vgName)
, m_totalSizeValue(0)
, m_usedSizeValue(0)
{
ui->setupUi(this);
for ( const Partition* p : pvList )
ui->pvList->addItem( new ListPhysicalVolumeWidgetItem( p, false ) );
ui->vgType->addItems( QStringList() << "LVM" << "RAID" );
ui->vgType->setCurrentIndex(0);
QRegularExpression re(R"(^(?!_|\.)[\w\-.+]+)");
ui->vgName->setValidator( new QRegularExpressionValidator( re, this ) );
ui->vgName->setText( m_vgNameValue );
updateOkButton();
updateTotalSize();
connect( ui->pvList, &QListWidget::itemChanged, this,
[&](QListWidgetItem*) {
updateTotalSize();
updateOkButton();
} );
connect( ui->peSize, qOverload<int>(&QSpinBox::valueChanged), this,
[&](int) {
updateTotalSectors();
updateOkButton();
});
connect( ui->vgName, &QLineEdit::textChanged, this,
[&](const QString&) {
updateOkButton();
});
}
VolumeGroupBaseDialog::~VolumeGroupBaseDialog()
{
delete ui;
}
QVector< const Partition* >
VolumeGroupBaseDialog::checkedItems() const
{
QVector< const Partition* > items;
for ( int i = 0; i < ui->pvList->count(); i++) {
ListPhysicalVolumeWidgetItem* item = dynamic_cast< ListPhysicalVolumeWidgetItem* >( ui->pvList->item(i) );
if ( item && item->checkState() == Qt::Checked )
items << item->partition();
}
return items;
}
bool
VolumeGroupBaseDialog::isSizeValid() const
{
return m_totalSizeValue >= m_usedSizeValue;
}
void
VolumeGroupBaseDialog::updateOkButton()
{
okButton()->setEnabled(isSizeValid() &&
!checkedItems().empty() &&
!ui->vgName->text().isEmpty() &&
ui->peSize->value() > 0);
}
void
VolumeGroupBaseDialog::setUsedSizeValue( qint64 usedSize )
{
m_usedSizeValue = usedSize;
ui->usedSize->setText( Capacity::formatByteSize(m_usedSizeValue) );
}
void
VolumeGroupBaseDialog::setLVQuantity( qint32 lvQuantity )
{
ui->lvQuantity->setText( QString::number( lvQuantity ) );
}
void
VolumeGroupBaseDialog::updateTotalSize()
{
m_totalSizeValue = 0;
for ( const Partition *p : checkedItems())
m_totalSizeValue += p->capacity() - p->capacity() % (ui->peSize->value() * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB));
ui->totalSize->setText(Capacity::formatByteSize(m_totalSizeValue));
updateTotalSectors();
}
void
VolumeGroupBaseDialog::updateTotalSectors()
{
qint32 totalSectors = 0;
qint32 extentSize = ui->peSize->value() * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
if ( extentSize > 0 )
totalSectors = m_totalSizeValue / extentSize;
ui->totalSectors->setText( QString::number( totalSectors ) );
}
QString&
VolumeGroupBaseDialog::vgNameValue() const
{
return m_vgNameValue;
}
QLineEdit*
VolumeGroupBaseDialog::vgName() const
{
return ui->vgName;
}
QComboBox*
VolumeGroupBaseDialog::vgType() const
{
return ui->vgType;
}
QSpinBox*
VolumeGroupBaseDialog::peSize() const
{
return ui->peSize;
}
QListWidget*
VolumeGroupBaseDialog::pvList() const
{
return ui->pvList;
}
QPushButton*
VolumeGroupBaseDialog::okButton() const
{
return ui->buttonBox->button( QDialogButtonBox::StandardButton::Ok );
}

View file

@ -0,0 +1,81 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VOLUMEGROUPBASEDIALOG_H
#define VOLUMEGROUPBASEDIALOG_H
#include <kpmcore/core/partition.h>
#include <QDialog>
namespace Ui {
class VolumeGroupBaseDialog;
}
class QComboBox;
class QLineEdit;
class QListWidget;
class QSpinBox;
class VolumeGroupBaseDialog : public QDialog
{
Q_OBJECT
public:
explicit VolumeGroupBaseDialog( QString& vgName,
QVector< const Partition* > pvList,
QWidget* parent = nullptr );
~VolumeGroupBaseDialog();
protected:
virtual void updateOkButton();
void setUsedSizeValue( qint64 usedSize );
void setLVQuantity( qint32 lvQuantity );
void updateTotalSize();
void updateTotalSectors();
QVector< const Partition* > checkedItems() const;
bool isSizeValid() const;
QString& vgNameValue() const;
QLineEdit* vgName() const;
QComboBox* vgType() const;
QSpinBox* peSize() const;
QListWidget* pvList() const;
QPushButton* okButton() const;
private:
Ui::VolumeGroupBaseDialog* ui;
QString& m_vgNameValue;
qint64 m_totalSizeValue;
qint64 m_usedSizeValue;
};
#endif // VOLUMEGROUPBASEDIALOG_H

View file

@ -0,0 +1,206 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VolumeGroupBaseDialog</class>
<widget class="QDialog" name="VolumeGroupBaseDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<height>367</height>
</rect>
</property>
<property name="windowTitle">
<string>VolumeGroupDialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="pvListLabel">
<property name="text">
<string>List of Physical Volumes</string>
</property>
</widget>
</item>
<item row="1" column="0" rowspan="7">
<widget class="QListWidget" name="pvList"/>
</item>
<item row="1" column="1">
<widget class="QLabel" name="vgNameLabel">
<property name="text">
<string>Volume Group Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="vgName"/>
</item>
<item row="2" column="1">
<widget class="QLabel" name="vgTypeLabel">
<property name="text">
<string>Volume Group Type:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QComboBox" name="vgType"/>
</item>
<item row="3" column="1">
<widget class="QLabel" name="peSizeLabel">
<property name="text">
<string>Physical Extent Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="peSize">
<property name="suffix">
<string> MiB</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>4</number>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="totalSizeLabel">
<property name="text">
<string>Total Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="totalSize">
<property name="text">
<string>---</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="usedSizeLabel">
<property name="text">
<string>Used Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="usedSize">
<property name="text">
<string>---</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="totalSectorsLabel">
<property name="text">
<string>Total Sectors:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="totalSectors">
<property name="text">
<string>---</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="lvQuantityLabel">
<property name="text">
<string>Quantity of LVs:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="lvQuantity">
<property name="text">
<string>---</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="8" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>VolumeGroupBaseDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>VolumeGroupBaseDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>