From 9a4e54fb42d8e126f22de6cc5e412dae3bddc049 Mon Sep 17 00:00:00 2001 From: Chantara Tith Date: Mon, 4 Jul 2016 00:02:16 +0700 Subject: [PATCH] Add remove and resize action to MainWindow. --- src/gui/mainwindow.cpp | 53 ++++++++++++++++++++++++++++++++++++------ src/gui/mainwindow.h | 2 ++ 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index b07f75e..e3f8ac4 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -33,13 +33,13 @@ #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -51,6 +51,7 @@ #include #include #include +#include #include #include "util/guihelpers.h" @@ -249,12 +250,30 @@ void MainWindow::setupActions() 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->setText(i18nc("@action:inmenu", "New Volume")); 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* removeVolumeGroup = actionCollection()->addAction(QStringLiteral("removeVolumeGroup")); + connect(removeVolumeGroup, &QAction::triggered, this, &MainWindow::onRemoveVolumeGroup); + removeVolumeGroup->setEnabled(false); + removeVolumeGroup->setText(i18nc("@action:inmenu", "Remove Volume")); + removeVolumeGroup->setToolTip(i18nc("@info:tooltip", "Remove selected Volume Device")); + removeVolumeGroup->setStatusTip(i18nc("@info:status", "Remove selected Volume Device")); + //actionCollection()->setDefaultShortcut(removeVolumeGroup, QKeySequence(/*SHORTCUT KEY HERE*/)); + removeVolumeGroup->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")).pixmap(IconSize(KIconLoader::Toolbar))); + + QAction* resizeVolumeGroup = actionCollection()->addAction(QStringLiteral("resizeVolumeGroup")); + connect(resizeVolumeGroup, &QAction::triggered, this, &MainWindow::onResizeVolumeGroup); + resizeVolumeGroup->setEnabled(false); + resizeVolumeGroup->setText(i18nc("@action:inmenu", "Resize Volume")); + resizeVolumeGroup->setToolTip(i18nc("@info:tooltip", "Resize selected Volume device")); + resizeVolumeGroup->setStatusTip(i18nc("@info:status", "Resize selected Volume device")); + //actionCollection()->setDefaultShortcut(resizeVolumeGroup, QKeySequence(/*SHORTCUT KEY HERE*/)); + resizeVolumeGroup->setIcon(QIcon::fromTheme(QStringLiteral("arrow-right-double")).pixmap(IconSize(KIconLoader::Toolbar))); + QAction* smartStatusDevice = actionCollection()->addAction(QStringLiteral("smartStatusDevice")); connect(smartStatusDevice, &QAction::triggered, this, &MainWindow::onSmartStatusDevice); smartStatusDevice->setEnabled(false); @@ -471,6 +490,12 @@ void MainWindow::enableActions() actionCollection()->action(QStringLiteral("createVolumeGroup")) ->setEnabled(CreateVolumeGroupOperation::canCreate()); + actionCollection()->action(QStringLiteral("removeVolumeGroup")) + ->setEnabled(RemoveVolumeGroupOperation::canRemove()); + + actionCollection()->action(QStringLiteral("resizeVolumeGroup")) + ->setEnabled(true); + const bool canResize = ResizeOperation::canGrow(part) || ResizeOperation::canShrink(part) || ResizeOperation::canMove(part); @@ -1029,14 +1054,28 @@ void MainWindow::onExportPartitionTable() void MainWindow::onCreateNewVolumeGroup() { - QPointer dlg = new CreateVolumeDialog(this); - QString vgname; - QList pvlist; + QString* vgname = new QString(); + QStringList* pvlist = new QStringList(); + // *NOTE*: vgname & pvlist will be modified and validate by the dialog + QPointer dlg = new CreateVolumeDialog(this, *vgname, *pvlist); if (dlg->exec() == QDialog::Accepted) { - operationStack().push(new CreateVolumeGroupOperation(vgname, pvlist)); + operationStack().push(new CreateVolumeGroupOperation(*vgname, *pvlist)); } - delete dlg; + delete vgname; + delete pvlist; +} + +void MainWindow::onRemoveVolumeGroup() +{ + Device* tmpDev = pmWidget().selectedDevice(); + if (tmpDev->type() == Device::LVM_Device) { + operationStack().push(new RemoveVolumeGroupOperation( *(dynamic_cast(tmpDev)) )); + } +} + +void MainWindow::onResizeVolumeGroup() +{ } void MainWindow::onFileSystemSupport() diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 669f801..2605e9f 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -241,6 +241,8 @@ protected: void onRefreshDevices(); void onCreateNewPartitionTable(); void onCreateNewVolumeGroup(); + void onRemoveVolumeGroup(); + void onResizeVolumeGroup(); void onExportPartitionTable(); void onImportPartitionTable();