From 637d22fe95379e188ae7d71c21e1d4a45673887f Mon Sep 17 00:00:00 2001 From: Victor Tran Date: Tue, 15 Aug 2023 22:24:24 +1000 Subject: [PATCH] Add option to attach VG --- application/diskPanes/lvmdiskpane.cpp | 46 +++++++++++++++++++++++---- application/diskPanes/lvmdiskpane.h | 4 +++ application/diskPanes/lvmdiskpane.ui | 13 +++++++- application/translations/ar_SA.ts | 16 ++++++++-- application/translations/da.ts | 16 ++++++++-- application/translations/en_US.ts | 16 ++++++++-- application/translations/he_IL.ts | 16 ++++++++-- application/translations/ja.ts | 16 ++++++++-- application/translations/pt_BR.ts | 16 ++++++++-- application/translations/tr.ts | 16 ++++++++-- application/translations/vi.ts | 16 ++++++++-- 11 files changed, 159 insertions(+), 32 deletions(-) diff --git a/application/diskPanes/lvmdiskpane.cpp b/application/diskPanes/lvmdiskpane.cpp index 41648aa..bc1a9d3 100644 --- a/application/diskPanes/lvmdiskpane.cpp +++ b/application/diskPanes/lvmdiskpane.cpp @@ -2,8 +2,11 @@ #include "ui_lvmdiskpane.h" #include +#include +#include #include #include +#include struct LvmDiskPanePrivate { DiskObject* disk; @@ -14,16 +17,14 @@ LvmDiskPane::LvmDiskPane(DiskObject* disk, QWidget* parent) : ui(new Ui::LvmDiskPane) { ui->setupUi(this); d = new LvmDiskPanePrivate(); + d->disk = disk; - auto pv = disk->interface(); - if (!pv) { - this->setVisible(false); - return; - } + connect(disk, &DiskObject::interfaceAdded, this, &LvmDiskPane::updateDetails); + connect(disk, &DiskObject::interfaceRemoved, this, &LvmDiskPane::updateDetails); - // connect(pv->volumeGroup(), &VolumeGroup::) - ui->lvmDescription->setText(tr("This block is part of the %1 volume group").arg(QLocale().quoteString(pv->volumeGroup()->name()))); ui->evictDataButton->setProperty("type", "destructive"); + + this->updateDetails(); } LvmDiskPane::~LvmDiskPane() { @@ -31,6 +32,37 @@ LvmDiskPane::~LvmDiskPane() { delete d; } +void LvmDiskPane::updateDetails() { + auto partition = d->disk->interface(); + if (!partition) { + this->setVisible(false); + return; + } + + auto partitionTable = partition->parentTable()->interface(); + if (partition->type() != PartitionInformation::partitionType("lvmpv", partitionTable->type())) { + this->setVisible(false); + return; + } + + this->setVisible(true); + auto pv = d->disk->interface(); + if (pv) { + 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); + ui->attachVgButton->setVisible(false); + } else { + ui->lvmDescription->setText(tr("This block is not part of a volume group.")); + ui->evictDataButton->setVisible(false); + ui->viewVgButton->setVisible(false); + ui->attachVgButton->setVisible(true); + } +} + int LvmDiskPane::order() const { return 20; } + +void LvmDiskPane::on_attachVgButton_clicked() { +} diff --git a/application/diskPanes/lvmdiskpane.h b/application/diskPanes/lvmdiskpane.h index 7df58e6..f532f98 100644 --- a/application/diskPanes/lvmdiskpane.h +++ b/application/diskPanes/lvmdiskpane.h @@ -20,9 +20,13 @@ class LvmDiskPane : public DiskPaneComponent { Ui::LvmDiskPane* ui; LvmDiskPanePrivate* d; + void updateDetails(); + // DiskPaneComponent interface public: int order() const; + private slots: + void on_attachVgButton_clicked(); }; #endif // LVMDISKPANE_H diff --git a/application/diskPanes/lvmdiskpane.ui b/application/diskPanes/lvmdiskpane.ui index eed9c36..e6b3227 100644 --- a/application/diskPanes/lvmdiskpane.ui +++ b/application/diskPanes/lvmdiskpane.ui @@ -84,7 +84,8 @@ Relocate Data - + + .. @@ -95,6 +96,16 @@ + + + + Attach to Volume Group + + + + + + diff --git a/application/translations/ar_SA.ts b/application/translations/ar_SA.ts index 337a8d8..9f55713 100644 --- a/application/translations/ar_SA.ts +++ b/application/translations/ar_SA.ts @@ -133,13 +133,23 @@ - + View Volume Group - - This block is part of the %1 volume group + + Attach to Volume Group + + + + + This block is part of the %1 volume group. + + + + + This block is not part of a volume group. diff --git a/application/translations/da.ts b/application/translations/da.ts index 1be60e8..51fb16e 100644 --- a/application/translations/da.ts +++ b/application/translations/da.ts @@ -133,13 +133,23 @@ - + View Volume Group - - This block is part of the %1 volume group + + Attach to Volume Group + + + + + This block is part of the %1 volume group. + + + + + This block is not part of a volume group. diff --git a/application/translations/en_US.ts b/application/translations/en_US.ts index f2fecac..4fe23b2 100644 --- a/application/translations/en_US.ts +++ b/application/translations/en_US.ts @@ -133,13 +133,23 @@ - + View Volume Group - - This block is part of the %1 volume group + + Attach to Volume Group + + + + + This block is part of the %1 volume group. + + + + + This block is not part of a volume group. diff --git a/application/translations/he_IL.ts b/application/translations/he_IL.ts index 2ed1cc4..9a977fa 100644 --- a/application/translations/he_IL.ts +++ b/application/translations/he_IL.ts @@ -133,13 +133,23 @@ - + View Volume Group - - This block is part of the %1 volume group + + Attach to Volume Group + + + + + This block is part of the %1 volume group. + + + + + This block is not part of a volume group. diff --git a/application/translations/ja.ts b/application/translations/ja.ts index 47eda8b..1a3a6fc 100644 --- a/application/translations/ja.ts +++ b/application/translations/ja.ts @@ -133,13 +133,23 @@ - + View Volume Group - - This block is part of the %1 volume group + + Attach to Volume Group + + + + + This block is part of the %1 volume group. + + + + + This block is not part of a volume group. diff --git a/application/translations/pt_BR.ts b/application/translations/pt_BR.ts index 5572837..4d1bdc7 100644 --- a/application/translations/pt_BR.ts +++ b/application/translations/pt_BR.ts @@ -133,13 +133,23 @@ - + View Volume Group - - This block is part of the %1 volume group + + Attach to Volume Group + + + + + This block is part of the %1 volume group. + + + + + This block is not part of a volume group. diff --git a/application/translations/tr.ts b/application/translations/tr.ts index f12f633..7fcd9bf 100644 --- a/application/translations/tr.ts +++ b/application/translations/tr.ts @@ -133,13 +133,23 @@ - + View Volume Group - - This block is part of the %1 volume group + + Attach to Volume Group + + + + + This block is part of the %1 volume group. + + + + + This block is not part of a volume group. diff --git a/application/translations/vi.ts b/application/translations/vi.ts index 76799a2..03d0c37 100644 --- a/application/translations/vi.ts +++ b/application/translations/vi.ts @@ -133,13 +133,23 @@ - + View Volume Group - - This block is part of the %1 volume group + + Attach to Volume Group + + + + + This block is part of the %1 volume group. + + + + + This block is not part of a volume group.