Skip to content

Commit

Permalink
Implement Disband Volume Group
Browse files Browse the repository at this point in the history
  • Loading branch information
vicr123 committed Aug 15, 2023
1 parent ff59e24 commit df1bf52
Show file tree
Hide file tree
Showing 17 changed files with 417 additions and 9 deletions.
2 changes: 1 addition & 1 deletion application/diskPanes/lvmdiskpane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void LvmDiskPane::updateDetails() {

this->setVisible(true);
auto pv = d->disk->interface<PhysicalVolumeInterface>();
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);
Expand Down
11 changes: 11 additions & 0 deletions application/lvm/volumegrouppage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <DriveObjects/diskobject.h>
#include <DriveObjects/logicalvolume.h>
#include <DriveObjects/volumegroup.h>
#include <operations/disbandvgpopover.h>
#include <tpopover.h>
#include <volumegrouplvmodel.h>
#include <volumegrouppvmodel.h>

Expand Down Expand Up @@ -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());
}
1 change: 1 addition & 0 deletions libthefrisbee/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions libthefrisbee/DriveObjects/volumegroup.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
#include "volumegroup.h"
#include "logicalvolume.h"

#include <QCoroDBusPendingCall>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingCall>

#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();
Expand Down Expand Up @@ -46,3 +54,11 @@ tRange<DiskObject*> 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());
}
3 changes: 3 additions & 0 deletions libthefrisbee/DriveObjects/volumegroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define VOLUMEGROUP_H

#include "udisksinterface.h"
#include <QCoroTask>
#include <ranges/trange.h>

struct VolumeGroupPrivate;
Expand All @@ -19,6 +20,8 @@ class VolumeGroup : public UdisksInterface {

QString name();

QCoro::Task<> deleteVg(bool wipe, QVariantMap options);

signals:
void lvsChanged();
void pvsChanged();
Expand Down
35 changes: 35 additions & 0 deletions libthefrisbee/operations/disbandvgpopover.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "disbandvgpopover.h"
#include "ui_disbandvgpopover.h"

#include "DriveObjects/volumegroup.h"
#include <tcontentsizer.h>

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();
}
33 changes: 33 additions & 0 deletions libthefrisbee/operations/disbandvgpopover.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef DISBANDVGPOPOVER_H
#define DISBANDVGPOPOVER_H

#include <QWidget>

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
105 changes: 105 additions & 0 deletions libthefrisbee/operations/disbandvgpopover.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DisbandVgPopover</class>
<widget class="QWidget" name="DisbandVgPopover">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>692</width>
<height>523</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="tTitleLabel" name="titleLabel">
<property name="text">
<string>Disband Volume Group</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QWidget" name="disbandConfirmWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>THIS IS IT</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>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.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="disbandButton">
<property name="text">
<string>Disband Volume Group</string>
</property>
<property name="icon">
<iconset theme="edit-delete">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>tTitleLabel</class>
<extends>QLabel</extends>
<header location="global">ttitlelabel.h</header>
<slots>
<signal>backButtonClicked()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
16 changes: 8 additions & 8 deletions libthefrisbee/operations/eraseopticalpopover.ui
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,6 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>tTitleLabel</class>
<extends>QLabel</extends>
<header location="global">ttitlelabel.h</header>
<slots>
<signal>backButtonClicked()</signal>
</slots>
</customwidget>
<customwidget>
<class>tStackedWidget</class>
<extends>QStackedWidget</extends>
Expand All @@ -226,6 +218,14 @@
<signal>switchingFrame(int)</signal>
</slots>
</customwidget>
<customwidget>
<class>tTitleLabel</class>
<extends>QLabel</extends>
<header location="global">ttitlelabel.h</header>
<slots>
<signal>backButtonClicked()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections/>
Expand Down
24 changes: 24 additions & 0 deletions libthefrisbee/translations/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,30 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DisbandVgPopover</name>
<message>
<location filename="../operations/disbandvgpopover.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../operations/disbandvgpopover.ui" line="35"/>
<location filename="../operations/disbandvgpopover.ui" line="67"/>
<source>Disband Volume Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../operations/disbandvgpopover.ui" line="50"/>
<source>THIS IS IT</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../operations/disbandvgpopover.ui" line="57"/>
<source>There&apos;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.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskObject</name>
<message>
Expand Down
24 changes: 24 additions & 0 deletions libthefrisbee/translations/cs_CZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,30 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DisbandVgPopover</name>
<message>
<location filename="../operations/disbandvgpopover.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../operations/disbandvgpopover.ui" line="35"/>
<location filename="../operations/disbandvgpopover.ui" line="67"/>
<source>Disband Volume Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../operations/disbandvgpopover.ui" line="50"/>
<source>THIS IS IT</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../operations/disbandvgpopover.ui" line="57"/>
<source>There&apos;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.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DiskObject</name>
<message>
Expand Down
28 changes: 28 additions & 0 deletions libthefrisbee/translations/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DisbandVgPopover</name>
<message>
<location filename="../operations/disbandvgpopover.ui" line="14"/>
<source>Form</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../operations/disbandvgpopover.ui" line="35"/>
<location filename="../operations/disbandvgpopover.ui" line="67"/>
<source>Disband Volume Group</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../operations/disbandvgpopover.ui" line="50"/>
<source>THIS IS IT</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../operations/disbandvgpopover.ui" line="57"/>
<source>There&apos;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.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>There&apos;s no going back after this. Once the disc in the drive is erased, all the data on it will be gone forever.</source>
<translation type="obsolete">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.</translation>
</message>
</context>
<context>
<name>DiskObject</name>
<message>
Expand Down
Loading

0 comments on commit df1bf52

Please sign in to comment.