Initial work on createvolume widget and dialog.

This commit is contained in:
Chantara Tith 2016-06-30 06:17:05 +07:00 committed by Andrius Štikonas
parent 0dd81709a1
commit 4f564d52f5
8 changed files with 481 additions and 0 deletions

View File

@ -4,6 +4,8 @@ set(GUI_SRC
gui/applyprogressdialogwidget.cpp
gui/createpartitiontabledialog.cpp
gui/createpartitiontablewidget.cpp
gui/createvolumedialog.cpp
gui/createvolumewidget.cpp
gui/devicepropsdialog.cpp
gui/devicepropswidget.cpp
gui/editmountpointdialog.cpp

View File

@ -0,0 +1,83 @@
/*************************************************************************
* 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/createvolumedialog.h"
#include "gui/createvolumewidget.h"
#include <core/lvmdevice.h>
#include <util/capacity.h>
#include <util/helpers.h>
#include <KLocalizedString>
#include <KSharedConfig>
#include <KConfigGroup>
#include <KIconLoader>
#include <QPointer>
#include <QPushButton>
#include <QTreeWidgetItem>
#include <QDialogButtonBox>
/** Creates a new CreateVolumeDialog
@param parent pointer to the parent widget
@param d the Device to show properties for
*/
CreateVolumeDialog::CreateVolumeDialog(QWidget* parent) :
QDialog(parent),
m_DialogWidget(new CreateVolumeWidget(this))
{
mainLayout = new QVBoxLayout(this);
setLayout(mainLayout);
mainLayout->addWidget(&dialogWidget());
setWindowTitle(xi18nc("@title:window", "Cretae new Volume Group"));
setupDialog();
setupConnections();
KConfigGroup kcg(KSharedConfig::openConfig(), "createVolumeDialog");
restoreGeometry(kcg.readEntry<QByteArray>("Geometry", QByteArray()));
}
/** Destroys a CreateVolumeDialog */
CreateVolumeDialog::~CreateVolumeDialog()
{
KConfigGroup kcg(KSharedConfig::openConfig(), "createVolumeDialog");
kcg.writeEntry("Geometry", saveGeometry());
}
void CreateVolumeDialog::setupDialog()
{
dialogButtonBox = new QDialogButtonBox;
okButton = dialogButtonBox->addButton(QDialogButtonBox::Ok);
cancelButton = dialogButtonBox->addButton(QDialogButtonBox::Cancel);
mainLayout->addWidget(dialogButtonBox);
okButton->setEnabled(false);
cancelButton->setFocus();
cancelButton->setDefault(true);
connect(dialogButtonBox, &QDialogButtonBox::accepted, this, &CreateVolumeDialog::accept);
connect(dialogButtonBox, &QDialogButtonBox::rejected, this, &CreateVolumeDialog::reject);
setMinimumSize(dialogWidget().size());
resize(dialogWidget().size());
}
void CreateVolumeDialog::setupConnections()
{
}

View File

@ -0,0 +1,62 @@
/*************************************************************************
* 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/>.*
*************************************************************************/
#if !defined(CREATEVOLUMEDIALOG__H)
#define CREATEVOLUMEDIALOG__H
#include <QDialog>
class CreateVolumeWidget;
class QDialogButtonBox;
class QPushButton;
class QVBoxLayout;
class QWidget;
class QString;
class CreateVolumeDialog : public QDialog
{
Q_DISABLE_COPY(CreateVolumeDialog)
public:
CreateVolumeDialog(QWidget* parent);
~CreateVolumeDialog();
protected:
void setupDialog();
void setupConnections();
CreateVolumeWidget& dialogWidget() {
Q_ASSERT(m_DialogWidget);
return *m_DialogWidget;
}
const CreateVolumeWidget& dialogWidget() const {
Q_ASSERT(m_DialogWidget);
return *m_DialogWidget;
}
private:
CreateVolumeWidget* m_DialogWidget;
QDialogButtonBox* dialogButtonBox;
QPushButton* okButton;
QPushButton* cancelButton;
QVBoxLayout *mainLayout;
};
#endif

View File

@ -0,0 +1,18 @@
/*************************************************************************
* 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/createvolumewidget.h"

View File

@ -0,0 +1,97 @@
/*************************************************************************
* 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/>.*
*************************************************************************/
#if !defined(CREATEVOLUMEWIDGET__H)
#define CREATEVOLUMEWIDGET__H
#include "ui_createvolumewidgetbase.h"
#include <QWidget>
class CreateVolumeWidget : public QWidget, public Ui::CreateVolumeWidgetBase
{
public:
CreateVolumeWidget(QWidget* parent) : QWidget(parent), Ui::CreateVolumeWidgetBase() {
setupUi(this);
}
public:
PartTableWidget& partTableWidget() {
Q_ASSERT(m_PartTableWidget);
return *m_PartTableWidget;
}
QLineEdit& vgName() {
Q_ASSERT(m_EditVGName);
return *m_EditVGName;
}
QSpinBox& spinPESize() {
Q_ASSERT(m_SpinPESize);
return *m_SpinPESize;
}
QListWidget& listPV() {
Q_ASSERT(m_ListPV);
return *m_ListPV;
}
QLabel& totalSize() {
Q_ASSERT(m_LabelTotalSize);
return *m_LabelTotalSize;
}
QLabel& totalSectors() {
Q_ASSERT(m_LabelTotalSectors);
return *m_LabelTotalSectors;
}
QLabel& totalLV() {
Q_ASSERT(m_LabelTotalLV);
return *m_LabelTotalLV;
}
QLabel& textVGName() {
Q_ASSERT(m_LabelTextVGName);
return *m_LabelTextVGName;
}
QLabel& textTotalSize() {
Q_ASSERT(m_LabelTextTotalSize);
return *m_LabelTextTotalSize;
}
QLabel& textTotalSectors() {
Q_ASSERT(m_LabelTextTotalSectors);
return *m_LabelTextTotalSectors;
}
QLabel& textTotalLV() {
Q_ASSERT(m_LabelTextTotalLV);
return *m_LabelTextTotalLV;
}
QLabel& textTotalPESize() {
Q_ASSERT(m_LabelTextPESize);
return *m_LabelTextPESize;
}
};
#endif

View File

@ -0,0 +1,192 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CreateVolumeWidgetBase</class>
<widget class="QWidget" name="CreateVolumeWidgetBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>831</width>
<height>512</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>652</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLineEdit" name="m_EditVGName"/>
</item>
</layout>
</item>
<item row="5" column="2">
<widget class="QLabel" name="m_LabelTotalSectors">
<property name="text">
<string>TextLabel</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="PartTableWidget" name="m_PartTableWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>74</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="m_LabelTextTotalSectors">
<property name="text">
<string>Total Sectors: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="3" column="0" rowspan="8">
<widget class="QListWidget" name="m_ListPV">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="m_LabelTotalSize">
<property name="text">
<string>TextLabel</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="m_LabelTotalLV">
<property name="text">
<string>TextLabel</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="4" column="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSpinBox" name="m_SpinPESize">
<property name="value">
<number>4</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="1">
<widget class="QLabel" name="m_LabelTextTotalSize">
<property name="text">
<string>Total Size: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="m_LabelTextTotalLV">
<property name="text">
<string>Total LV: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="m_LabelTextVGName">
<property name="text">
<string>Volume Group Name: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="m_LabelTextPESize">
<property name="text">
<string>Physical Extent Size: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>PartTableWidget</class>
<extends>QWidget</extends>
<header>gui/parttablewidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -22,6 +22,7 @@
#include "gui/applyprogressdialog.h"
#include "gui/scanprogressdialog.h"
#include "gui/createpartitiontabledialog.h"
#include "gui/createvolumedialog.h"
#include "gui/filesystemsupportdialog.h"
#include "gui/devicepropsdialog.h"
#include "gui/smartdialog.h"
@ -38,6 +39,7 @@
#include <ops/operation.h>
#include <ops/createpartitiontableoperation.h>
#include <ops/createvolumegroupoperation.h>
#include <ops/resizeoperation.h>
#include <ops/copyoperation.h>
#include <ops/deleteoperation.h>
@ -244,6 +246,15 @@ void MainWindow::setupActions()
importPartitionTable->setStatusTip(xi18nc("@info:status", "Import a partition table from a text file."));
importPartitionTable->setIcon(QIcon::fromTheme(QStringLiteral("document-import")).pixmap(IconSize(KIconLoader::Toolbar)));
QAction* createVolumeGroup = actionCollection()->addAction(QStringLiteral("createVolumeGroup"));
connect(createVolumeGroup, &QAction::triggered, this, &MainWindow::onCreateNewVolumeGroup);
createVolumeGroup->setEnabled(false);
createVolumeGroup->setText(i18nc("@action:inmenu", "New LVM Volume Group"));
createVolumeGroup->setToolTip(i18nc("@info:tooltip", "Create a new LVM Volume Group"));
createVolumeGroup->setStatusTip(i18nc("@info:status", "Create a new LVM Volume Group as a device."));
actionCollection()->setDefaultShortcut(createVolumeGroup, QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_L));
createVolumeGroup->setIcon(QIcon::fromTheme(QStringLiteral("document-new")).pixmap(IconSize(KIconLoader::Toolbar)));
QAction* smartStatusDevice = actionCollection()->addAction(QStringLiteral("smartStatusDevice"));
connect(smartStatusDevice, &QAction::triggered, this, &MainWindow::onSmartStatusDevice);
smartStatusDevice->setEnabled(false);
@ -457,6 +468,9 @@ void MainWindow::enableActions()
actionCollection()->action(QStringLiteral("newPartition"))
->setEnabled(!readOnly && NewOperation::canCreateNew(part));
actionCollection()->action(QStringLiteral("createVolumeGroup"))
->setEnabled(CreateVolumeGroupOperation::canCreate());
const bool canResize = ResizeOperation::canGrow(part) ||
ResizeOperation::canShrink(part) ||
ResizeOperation::canMove(part);
@ -1013,6 +1027,18 @@ void MainWindow::onExportPartitionTable()
job->ui()->showErrorMessage();
}
void MainWindow::onCreateNewVolumeGroup()
{
QPointer<CreateVolumeDialog> dlg = new CreateVolumeDialog(this);
QString vgname;
QList<Partition*> pvlist;
if (dlg->exec() == QDialog::Accepted) {
operationStack().push(new CreateVolumeGroupOperation(vgname, pvlist));
}
delete dlg;
}
void MainWindow::onFileSystemSupport()
{
FileSystemSupportDialog dlg(this);

View File

@ -240,6 +240,7 @@ protected:
void onRefreshDevices();
void onCreateNewPartitionTable();
void onCreateNewVolumeGroup();
void onExportPartitionTable();
void onImportPartitionTable();