From df1bf52eeab1fe4305a0b0487ff6bb17c2102f2d Mon Sep 17 00:00:00 2001 From: Victor Tran Date: Tue, 15 Aug 2023 23:01:12 +1000 Subject: [PATCH] Implement Disband Volume Group --- application/diskPanes/lvmdiskpane.cpp | 2 +- application/lvm/volumegrouppage.cpp | 11 ++ libthefrisbee/CMakeLists.txt | 1 + libthefrisbee/DriveObjects/volumegroup.cpp | 16 +++ libthefrisbee/DriveObjects/volumegroup.h | 3 + libthefrisbee/operations/disbandvgpopover.cpp | 35 ++++++ libthefrisbee/operations/disbandvgpopover.h | 33 ++++++ libthefrisbee/operations/disbandvgpopover.ui | 105 ++++++++++++++++++ .../operations/eraseopticalpopover.ui | 16 +-- libthefrisbee/translations/cs.ts | 24 ++++ libthefrisbee/translations/cs_CZ.ts | 24 ++++ libthefrisbee/translations/da.ts | 28 +++++ libthefrisbee/translations/de.ts | 24 ++++ libthefrisbee/translations/en_US.ts | 24 ++++ libthefrisbee/translations/he_IL.ts | 28 +++++ libthefrisbee/translations/ru.ts | 24 ++++ libthefrisbee/translations/vi_VN.ts | 28 +++++ 17 files changed, 417 insertions(+), 9 deletions(-) create mode 100644 libthefrisbee/operations/disbandvgpopover.cpp create mode 100644 libthefrisbee/operations/disbandvgpopover.h create mode 100644 libthefrisbee/operations/disbandvgpopover.ui diff --git a/application/diskPanes/lvmdiskpane.cpp b/application/diskPanes/lvmdiskpane.cpp index a1bb1be..dc0520b 100644 --- a/application/diskPanes/lvmdiskpane.cpp +++ b/application/diskPanes/lvmdiskpane.cpp @@ -48,7 +48,7 @@ void LvmDiskPane::updateDetails() { this->setVisible(true); auto pv = d->disk->interface(); - if (pv) { + if (pv && pv->volumeGroup()) { ui->lvmDescription->setText(tr("This block is part of the %1 volume group.").arg(QLocale().quoteString(pv->volumeGroup()->name()))); ui->evictDataButton->setVisible(true); ui->viewVgButton->setVisible(true); diff --git a/application/lvm/volumegrouppage.cpp b/application/lvm/volumegrouppage.cpp index d9da9e5..561a84a 100644 --- a/application/lvm/volumegrouppage.cpp +++ b/application/lvm/volumegrouppage.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include #include #include @@ -77,4 +79,13 @@ void VolumeGroupPage::on_titleLabel_backButtonClicked() { } void VolumeGroupPage::on_disbandButton_clicked() { + auto* jp = new DisbandVgPopover(d->vg); + tPopover* popover = new tPopover(jp); + popover->setPopoverWidth(-200); + popover->setPopoverSide(tPopover::Bottom); + connect(jp, &DisbandVgPopover::done, popover, &tPopover::dismiss); + connect(jp, &DisbandVgPopover::deleted, this, &VolumeGroupPage::done); + connect(popover, &tPopover::dismissed, popover, &tPopover::deleteLater); + connect(popover, &tPopover::dismissed, jp, &DisbandVgPopover::deleteLater); + popover->show(this->window()); } diff --git a/libthefrisbee/CMakeLists.txt b/libthefrisbee/CMakeLists.txt index 2740f07..cd2ce40 100644 --- a/libthefrisbee/CMakeLists.txt +++ b/libthefrisbee/CMakeLists.txt @@ -54,6 +54,7 @@ set(SOURCES volumegrouplvmodel.h volumegrouplvmodel.cpp volumegrouppvmodel.h volumegrouppvmodel.cpp operations/attachpvpopover.h operations/attachpvpopover.cpp operations/attachpvpopover.ui + operations/disbandvgpopover.h operations/disbandvgpopover.cpp operations/disbandvgpopover.ui ) set(STRUCTURES_HEADERS diff --git a/libthefrisbee/DriveObjects/volumegroup.cpp b/libthefrisbee/DriveObjects/volumegroup.cpp index 25b5852..47a56aa 100644 --- a/libthefrisbee/DriveObjects/volumegroup.cpp +++ b/libthefrisbee/DriveObjects/volumegroup.cpp @@ -1,17 +1,25 @@ #include "volumegroup.h" #include "logicalvolume.h" +#include +#include +#include +#include + #include "DriveObjects/diskobject.h" #include "DriveObjects/physicalvolumeinterface.h" #include "driveobjectmanager.h" +#include "frisbeeexception.h" struct VolumeGroupPrivate { + QDBusObjectPath path; QString name; }; VolumeGroup::VolumeGroup(QDBusObjectPath path, QObject* parent) : UdisksInterface{path, interfaceName(), parent} { d = new VolumeGroupPrivate(); + d->path = path; bindPropertyUpdater("Name", [this](QVariant value) { d->name = value.toString(); @@ -46,3 +54,11 @@ tRange VolumeGroup::pvs() { QString VolumeGroup::name() { return d->name; } + +QCoro::Task<> VolumeGroup::deleteVg(bool wipe, QVariantMap options) { + QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.UDisks2", d->path.path(), interfaceName(), "Delete"); + message.setArguments({wipe, options}); + auto call = QDBusConnection::systemBus().asyncCall(message); + auto reply = co_await call; + if (call.isError()) throw FrisbeeException(call.error().message()); +} diff --git a/libthefrisbee/DriveObjects/volumegroup.h b/libthefrisbee/DriveObjects/volumegroup.h index 8bae717..0456dde 100644 --- a/libthefrisbee/DriveObjects/volumegroup.h +++ b/libthefrisbee/DriveObjects/volumegroup.h @@ -2,6 +2,7 @@ #define VOLUMEGROUP_H #include "udisksinterface.h" +#include #include struct VolumeGroupPrivate; @@ -19,6 +20,8 @@ class VolumeGroup : public UdisksInterface { QString name(); + QCoro::Task<> deleteVg(bool wipe, QVariantMap options); + signals: void lvsChanged(); void pvsChanged(); diff --git a/libthefrisbee/operations/disbandvgpopover.cpp b/libthefrisbee/operations/disbandvgpopover.cpp new file mode 100644 index 0000000..a013e2c --- /dev/null +++ b/libthefrisbee/operations/disbandvgpopover.cpp @@ -0,0 +1,35 @@ +#include "disbandvgpopover.h" +#include "ui_disbandvgpopover.h" + +#include "DriveObjects/volumegroup.h" +#include + +struct DisbandVgPopoverPrivate { + VolumeGroup* vg; +}; + +DisbandVgPopover::DisbandVgPopover(VolumeGroup* vg, QWidget* parent) : + QWidget(parent), + ui(new Ui::DisbandVgPopover) { + ui->setupUi(this); + d = new DisbandVgPopoverPrivate(); + d->vg = vg; + + new tContentSizer(ui->disbandConfirmWidget); + ui->disbandButton->setProperty("type", "destructive"); +} + +DisbandVgPopover::~DisbandVgPopover() { + delete d; + delete ui; +} + +void DisbandVgPopover::on_disbandButton_clicked() { + d->vg->deleteVg(false, {}); + emit deleted(); + emit done(); +} + +void DisbandVgPopover::on_titleLabel_backButtonClicked() { + emit done(); +} diff --git a/libthefrisbee/operations/disbandvgpopover.h b/libthefrisbee/operations/disbandvgpopover.h new file mode 100644 index 0000000..ad9c4aa --- /dev/null +++ b/libthefrisbee/operations/disbandvgpopover.h @@ -0,0 +1,33 @@ +#ifndef DISBANDVGPOPOVER_H +#define DISBANDVGPOPOVER_H + +#include + +namespace Ui { + class DisbandVgPopover; +} + +class VolumeGroup; +struct DisbandVgPopoverPrivate; +class DisbandVgPopover : public QWidget { + Q_OBJECT + + public: + explicit DisbandVgPopover(VolumeGroup* vg, QWidget* parent = nullptr); + ~DisbandVgPopover(); + + signals: + void done(); + void deleted(); + + private slots: + void on_disbandButton_clicked(); + + void on_titleLabel_backButtonClicked(); + + private: + Ui::DisbandVgPopover* ui; + DisbandVgPopoverPrivate* d; +}; + +#endif // DISBANDVGPOPOVER_H diff --git a/libthefrisbee/operations/disbandvgpopover.ui b/libthefrisbee/operations/disbandvgpopover.ui new file mode 100644 index 0000000..7ffbfed --- /dev/null +++ b/libthefrisbee/operations/disbandvgpopover.ui @@ -0,0 +1,105 @@ + + + DisbandVgPopover + + + + 0 + 0 + 692 + 523 + + + + Form + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Disband Volume Group + + + + + + + + + + + true + + + + THIS IS IT + + + + + + + There's no going back after this. Once the Volume Group is disbanded, all the logical volumes contained within, and all the data in the logical volumes will be gone forever. + + + true + + + + + + + Disband Volume Group + + + + .. + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + tTitleLabel + QLabel +
ttitlelabel.h
+ + backButtonClicked() + +
+
+ + +
diff --git a/libthefrisbee/operations/eraseopticalpopover.ui b/libthefrisbee/operations/eraseopticalpopover.ui index 8b99aa4..193195d 100644 --- a/libthefrisbee/operations/eraseopticalpopover.ui +++ b/libthefrisbee/operations/eraseopticalpopover.ui @@ -209,14 +209,6 @@ - - tTitleLabel - QLabel -
ttitlelabel.h
- - backButtonClicked() - -
tStackedWidget QStackedWidget @@ -226,6 +218,14 @@ switchingFrame(int) + + tTitleLabel + QLabel +
ttitlelabel.h
+ + backButtonClicked() + +
diff --git a/libthefrisbee/translations/cs.ts b/libthefrisbee/translations/cs.ts index 03e9246..45fee20 100644 --- a/libthefrisbee/translations/cs.ts +++ b/libthefrisbee/translations/cs.ts @@ -40,6 +40,30 @@ + + DisbandVgPopover + + + Form + + + + + + Disband Volume Group + + + + + THIS IS IT + + + + + There's no going back after this. Once the Volume Group is disbanded, all the logical volumes contained within, and all the data in the logical volumes will be gone forever. + + + DiskObject diff --git a/libthefrisbee/translations/cs_CZ.ts b/libthefrisbee/translations/cs_CZ.ts index 03e9246..45fee20 100644 --- a/libthefrisbee/translations/cs_CZ.ts +++ b/libthefrisbee/translations/cs_CZ.ts @@ -40,6 +40,30 @@ + + DisbandVgPopover + + + Form + + + + + + Disband Volume Group + + + + + THIS IS IT + + + + + There's no going back after this. Once the Volume Group is disbanded, all the logical volumes contained within, and all the data in the logical volumes will be gone forever. + + + DiskObject diff --git a/libthefrisbee/translations/da.ts b/libthefrisbee/translations/da.ts index 64f7cec..91382c5 100644 --- a/libthefrisbee/translations/da.ts +++ b/libthefrisbee/translations/da.ts @@ -40,6 +40,34 @@ + + DisbandVgPopover + + + Form + + + + + + Disband Volume Group + + + + + THIS IS IT + + + + + There's no going back after this. Once the Volume Group is disbanded, all the logical volumes contained within, and all the data in the logical volumes will be gone forever. + + + + There's no going back after this. Once the disc in the drive is erased, all the data on it will be gone forever. + Du kan ikke gå tilbage efter dette. Når disken i drevet er formateret, vil alle dataene på den være væk for evigt. + + DiskObject diff --git a/libthefrisbee/translations/de.ts b/libthefrisbee/translations/de.ts index d9d18a1..3952145 100644 --- a/libthefrisbee/translations/de.ts +++ b/libthefrisbee/translations/de.ts @@ -40,6 +40,30 @@ + + DisbandVgPopover + + + Form + + + + + + Disband Volume Group + + + + + THIS IS IT + + + + + There's no going back after this. Once the Volume Group is disbanded, all the logical volumes contained within, and all the data in the logical volumes will be gone forever. + + + DiskObject diff --git a/libthefrisbee/translations/en_US.ts b/libthefrisbee/translations/en_US.ts index 718d9b0..6a258b6 100644 --- a/libthefrisbee/translations/en_US.ts +++ b/libthefrisbee/translations/en_US.ts @@ -40,6 +40,30 @@ + + DisbandVgPopover + + + Form + + + + + + Disband Volume Group + + + + + THIS IS IT + + + + + There's no going back after this. Once the Volume Group is disbanded, all the logical volumes contained within, and all the data in the logical volumes will be gone forever. + + + DiskObject diff --git a/libthefrisbee/translations/he_IL.ts b/libthefrisbee/translations/he_IL.ts index bcdb181..c078329 100644 --- a/libthefrisbee/translations/he_IL.ts +++ b/libthefrisbee/translations/he_IL.ts @@ -40,6 +40,34 @@ + + DisbandVgPopover + + + Form + + + + + + Disband Volume Group + + + + + THIS IS IT + אין דרך חזרה + + + + There's no going back after this. Once the Volume Group is disbanded, all the logical volumes contained within, and all the data in the logical volumes will be gone forever. + + + + There's no going back after this. Once the disc in the drive is erased, all the data on it will be gone forever. + אי אפשר לחזור חזרה מזה. אחרי שהדיסק נמחק, כל המידע בתוכו נעלם לתמיד. + + DiskObject diff --git a/libthefrisbee/translations/ru.ts b/libthefrisbee/translations/ru.ts index bc5e256..6888f96 100644 --- a/libthefrisbee/translations/ru.ts +++ b/libthefrisbee/translations/ru.ts @@ -40,6 +40,30 @@ + + DisbandVgPopover + + + Form + + + + + + Disband Volume Group + + + + + THIS IS IT + + + + + There's no going back after this. Once the Volume Group is disbanded, all the logical volumes contained within, and all the data in the logical volumes will be gone forever. + + + DiskObject diff --git a/libthefrisbee/translations/vi_VN.ts b/libthefrisbee/translations/vi_VN.ts index 988b723..5e71663 100644 --- a/libthefrisbee/translations/vi_VN.ts +++ b/libthefrisbee/translations/vi_VN.ts @@ -40,6 +40,34 @@ + + DisbandVgPopover + + + Form + + + + + + Disband Volume Group + + + + + THIS IS IT + SẴN SÀNG CHƯA? + + + + There's no going back after this. Once the Volume Group is disbanded, all the logical volumes contained within, and all the data in the logical volumes will be gone forever. + + + + There's no going back after this. Once the disc in the drive is erased, all the data on it will be gone forever. + Bạn không thể quay lại sau điểm này. Sau khi đĩa trong ổ bị xóa, các dữ liệu trên nó sẽ bị mất vĩnh viễn. + + DiskObject