mirror of https://github.com/cutefishos/calamares
[partition] Initial implementation of VolumeGroupBaseDialog.
parent
f72f7bd8fe
commit
d15ce56c97
@ -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;
|
||||||
|
}
|
@ -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
|
@ -0,0 +1,42 @@
|
|||||||
|
/* === 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"
|
||||||
|
|
||||||
|
VolumeGroupBaseDialog::VolumeGroupBaseDialog( QString& vgName,
|
||||||
|
QList< const Partition* > pvList,
|
||||||
|
qint32& peSize,
|
||||||
|
QWidget *parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
, ui(new Ui::VolumeGroupBaseDialog)
|
||||||
|
, m_vgName(vgName)
|
||||||
|
, m_peSize(peSize)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
for ( const Partition* p : pvList )
|
||||||
|
ui->pvList->addItem( new ListPhysicalVolumeWidgetItem(p, false) );
|
||||||
|
}
|
||||||
|
|
||||||
|
VolumeGroupBaseDialog::~VolumeGroupBaseDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/* === 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 VolumeGroupBaseDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit VolumeGroupBaseDialog(QString& vgName,
|
||||||
|
QList< const Partition* > pvList,
|
||||||
|
qint32& peSize,
|
||||||
|
QWidget* parent = 0);
|
||||||
|
~VolumeGroupBaseDialog();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::VolumeGroupBaseDialog *ui;
|
||||||
|
|
||||||
|
QString &m_vgName;
|
||||||
|
qint32 &m_peSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VOLUMEGROUPBASEDIALOG_H
|
@ -0,0 +1,193 @@
|
|||||||
|
<?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="label_2">
|
||||||
|
<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="lineEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<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="comboBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<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="spinBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<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="label_9">
|
||||||
|
<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="label_6">
|
||||||
|
<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="label_10">
|
||||||
|
<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="label_7">
|
||||||
|
<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="label_11">
|
||||||
|
<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="label_8">
|
||||||
|
<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="label_12">
|
||||||
|
<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>
|
@ -0,0 +1,88 @@
|
|||||||
|
/* === 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 "CreateVolumeGroupJob.h"
|
||||||
|
|
||||||
|
// KPMcore
|
||||||
|
#include <kpmcore/core/lvmdevice.h>
|
||||||
|
#include <kpmcore/core/partition.h>
|
||||||
|
#include <kpmcore/ops/createvolumegroupoperation.h>
|
||||||
|
#include <kpmcore/util/report.h>
|
||||||
|
|
||||||
|
CreateVolumeGroupJob::CreateVolumeGroupJob( QString& vgName, QVector< const Partition* > pvList, const qint32 peSize )
|
||||||
|
: m_vgName(vgName)
|
||||||
|
, m_pvList(pvList)
|
||||||
|
, m_peSize(peSize)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
CreateVolumeGroupJob::prettyName() const
|
||||||
|
{
|
||||||
|
return tr( "Create new volume group named %1." )
|
||||||
|
.arg( m_vgName );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
CreateVolumeGroupJob::prettyDescription() const
|
||||||
|
{
|
||||||
|
return tr( "Create new volume group named <strong>%1</strong>." )
|
||||||
|
.arg( m_vgName );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
CreateVolumeGroupJob::prettyStatusMessage() const
|
||||||
|
{
|
||||||
|
return tr( "Creating new volume group named %1." )
|
||||||
|
.arg( m_vgName );
|
||||||
|
}
|
||||||
|
|
||||||
|
Calamares::JobResult
|
||||||
|
CreateVolumeGroupJob::exec()
|
||||||
|
{
|
||||||
|
Report report( nullptr );
|
||||||
|
|
||||||
|
QVector< const Partition* > pvList;
|
||||||
|
|
||||||
|
pvList << m_pvList;
|
||||||
|
|
||||||
|
CreateVolumeGroupOperation op( m_vgName, m_pvList, m_peSize );
|
||||||
|
|
||||||
|
op.setStatus( Operation::StatusRunning );
|
||||||
|
|
||||||
|
QString message = tr( "The installer failed to create a volume group named '%1'.").arg( m_vgName );
|
||||||
|
if (op.execute(report))
|
||||||
|
return Calamares::JobResult::ok();
|
||||||
|
|
||||||
|
return Calamares::JobResult::error(message, report.toText());
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CreateVolumeGroupJob::updatePreview()
|
||||||
|
{
|
||||||
|
LvmDevice::s_DirtyPVs << m_pvList;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CreateVolumeGroupJob::undoPreview()
|
||||||
|
{
|
||||||
|
for ( const auto& pv : m_pvList )
|
||||||
|
if ( LvmDevice::s_DirtyPVs.contains( pv ))
|
||||||
|
LvmDevice::s_DirtyPVs.removeAll( pv );
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/* === 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 CREATEVOLUMEGROUPJOB_H
|
||||||
|
#define CREATEVOLUMEGROUPJOB_H
|
||||||
|
|
||||||
|
#include <Job.h>
|
||||||
|
|
||||||
|
#include <kpmcore/core/partition.h>
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
class CreateVolumeGroupJob : public Calamares::Job
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CreateVolumeGroupJob( QString& vgName, QVector< const Partition* > pvList, const qint32 peSize );
|
||||||
|
|
||||||
|
QString prettyName() const override;
|
||||||
|
QString prettyDescription() const override;
|
||||||
|
QString prettyStatusMessage() const override;
|
||||||
|
Calamares::JobResult exec() override;
|
||||||
|
|
||||||
|
void updatePreview();
|
||||||
|
void undoPreview();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString m_vgName;
|
||||||
|
QVector< const Partition* > m_pvList;
|
||||||
|
qint32 m_peSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CREATEVOLUMEGROUPJOB_H
|
Loading…
Reference in New Issue