2016-06-30 00:17:05 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program 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. *
|
|
|
|
* *
|
|
|
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2016-06-30 18:39:47 +01:00
|
|
|
#include "gui/volumewidget.h"
|
|
|
|
#include "gui/volumedialog.h"
|
2016-06-30 00:17:05 +01:00
|
|
|
#include "gui/createvolumedialog.h"
|
|
|
|
|
|
|
|
#include <core/lvmdevice.h>
|
2016-07-03 23:23:54 +01:00
|
|
|
#include <fs/lvm2_pv.h>
|
2016-06-30 00:17:05 +01:00
|
|
|
|
|
|
|
#include <util/capacity.h>
|
|
|
|
#include <util/helpers.h>
|
|
|
|
|
|
|
|
#include <KLocalizedString>
|
|
|
|
#include <KSharedConfig>
|
|
|
|
#include <KConfigGroup>
|
|
|
|
#include <KIconLoader>
|
|
|
|
|
|
|
|
#include <QPointer>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
2016-07-18 01:07:53 +01:00
|
|
|
CreateVolumeDialog::CreateVolumeDialog(QWidget* parent, QString& vgname, QStringList& pvlist, qint32& pesize) :
|
|
|
|
VolumeDialog(parent, vgname, pvlist),
|
2016-08-08 04:49:41 +01:00
|
|
|
m_PESize(pesize),
|
|
|
|
m_SystemVGList(LvmDevice::getVGs())
|
2016-06-30 00:17:05 +01:00
|
|
|
{
|
2016-07-25 16:48:54 +01:00
|
|
|
setWindowTitle(xi18nc("@title:window", "Create new Volume Group"));
|
2016-06-30 00:17:05 +01:00
|
|
|
|
|
|
|
setupDialog();
|
2016-07-03 23:23:54 +01:00
|
|
|
setupConstraints();
|
2016-06-30 00:17:05 +01:00
|
|
|
setupConnections();
|
2016-07-15 22:39:12 +01:00
|
|
|
|
|
|
|
// disable volume type and PE size for now, until the features are implemented.
|
|
|
|
dialogWidget().volumeType().setEnabled(false);
|
2016-06-30 00:17:05 +01:00
|
|
|
|
|
|
|
KConfigGroup kcg(KSharedConfig::openConfig(), "createVolumeDialog");
|
|
|
|
restoreGeometry(kcg.readEntry<QByteArray>("Geometry", QByteArray()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateVolumeDialog::setupDialog()
|
|
|
|
{
|
2016-08-08 19:39:20 +01:00
|
|
|
for (const auto &pvpath : FS::lvm2_pv::getFreePV()) {
|
2016-08-08 08:04:55 +01:00
|
|
|
if (!LvmDevice::s_DirtyPVs.contains(pvpath)) {
|
|
|
|
dialogWidget().listPV().addPartition(pvpath, false);
|
|
|
|
}
|
|
|
|
}
|
2016-06-30 00:17:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CreateVolumeDialog::setupConnections()
|
|
|
|
{
|
2016-07-02 09:27:20 +01:00
|
|
|
connect(&dialogWidget().vgName(), &QLineEdit::textChanged, this, &CreateVolumeDialog::onVGNameChanged);
|
|
|
|
connect(&dialogWidget().spinPESize(), static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &CreateVolumeDialog::onSpinPESizeChanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateVolumeDialog::accept()
|
|
|
|
{
|
2016-07-03 18:15:50 +01:00
|
|
|
QString& tname = targetName();
|
|
|
|
tname = dialogWidget().vgName().text();
|
|
|
|
|
2016-07-03 23:23:54 +01:00
|
|
|
targetPVList() << dialogWidget().listPV().checkedItems();
|
2016-07-03 18:15:50 +01:00
|
|
|
|
2016-07-18 01:07:53 +01:00
|
|
|
qint32& pesize = peSize();
|
|
|
|
pesize = dialogWidget().spinPESize().value();
|
|
|
|
|
2016-07-02 09:27:20 +01:00
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateVolumeDialog::onVGNameChanged(const QString& vgname)
|
|
|
|
{
|
2016-08-08 04:49:41 +01:00
|
|
|
if (m_SystemVGList.contains(vgname)) {
|
|
|
|
m_IsValidName = false;
|
|
|
|
} else {
|
|
|
|
m_IsValidName = true;
|
|
|
|
}
|
2016-07-02 09:27:20 +01:00
|
|
|
updateOkButtonStatus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreateVolumeDialog::onSpinPESizeChanged(int newsize)
|
|
|
|
{
|
|
|
|
Q_UNUSED(newsize);
|
|
|
|
updateOkButtonStatus();
|
2016-08-01 16:19:19 +01:00
|
|
|
updateSectorInfos();
|
2016-06-30 00:17:05 +01:00
|
|
|
}
|