2016-07-09 01:12:31 +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/>.*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "gui/volumewidget.h"
|
|
|
|
#include "gui/volumedialog.h"
|
|
|
|
#include "gui/resizevolumedialog.h"
|
|
|
|
|
|
|
|
#include <core/lvmdevice.h>
|
2016-08-08 00:47:05 +01:00
|
|
|
#include <core/volumemanagerdevice.h>
|
|
|
|
#include <core/partitiontable.h>
|
2016-07-09 01:12:31 +01:00
|
|
|
#include <fs/lvm2_pv.h>
|
|
|
|
|
|
|
|
#include <util/capacity.h>
|
|
|
|
#include <util/helpers.h>
|
|
|
|
|
2016-08-23 16:40:16 +01:00
|
|
|
#include <KConfigGroup>
|
2016-07-09 01:12:31 +01:00
|
|
|
#include <KLocalizedString>
|
|
|
|
#include <KSharedConfig>
|
|
|
|
|
|
|
|
/** Creates a new ResizeVolumeDialog
|
|
|
|
@param parent pointer to the parent widget
|
2016-08-08 19:39:20 +01:00
|
|
|
@param dev the Device to show properties for
|
2016-07-09 01:12:31 +01:00
|
|
|
*/
|
2016-08-08 00:47:05 +01:00
|
|
|
ResizeVolumeDialog::ResizeVolumeDialog(QWidget* parent, QString& vgname, QStringList& partlist, VolumeManagerDevice& dev) :
|
|
|
|
VolumeDialog(parent, vgname, partlist),
|
|
|
|
m_Device(dev)
|
2016-07-09 01:12:31 +01:00
|
|
|
{
|
|
|
|
setWindowTitle(xi18nc("@title:window", "Resize Volume Group"));
|
|
|
|
|
|
|
|
setupDialog();
|
|
|
|
setupConstraints();
|
|
|
|
|
|
|
|
KConfigGroup kcg(KSharedConfig::openConfig(), "resizeVolumeDialog");
|
|
|
|
restoreGeometry(kcg.readEntry<QByteArray>("Geometry", QByteArray()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResizeVolumeDialog::setupDialog()
|
|
|
|
{
|
2016-08-08 00:47:05 +01:00
|
|
|
if (dialogWidget().volumeType().currentText() == QStringLiteral("LVM")) {
|
2016-08-10 03:15:51 +01:00
|
|
|
dialogWidget().listPV().addPartitionList(device().deviceNodes(), true);
|
2016-08-09 14:57:33 +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-08-08 00:47:05 +01:00
|
|
|
}
|
2016-07-09 01:12:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResizeVolumeDialog::setupConstraints()
|
|
|
|
{
|
|
|
|
dialogWidget().vgName().setEnabled(false);
|
|
|
|
dialogWidget().spinPESize().setEnabled(false);
|
|
|
|
dialogWidget().volumeType().setEnabled(false);
|
2016-07-09 18:45:32 +01:00
|
|
|
VolumeDialog::setupConstraints();
|
2016-07-09 01:12:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ResizeVolumeDialog::accept()
|
|
|
|
{
|
|
|
|
targetPVList() << dialogWidget().listPV().checkedItems();
|
|
|
|
QDialog::accept();
|
|
|
|
}
|