-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
851 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "sizerangebox.h" | ||
#include "ui_sizerangebox.h" | ||
|
||
struct SizeRangeBoxPrivate { | ||
static constexpr int divisionFactor = 1024 * 1024; | ||
}; | ||
|
||
SizeRangeBox::SizeRangeBox(QWidget* parent) : | ||
QWidget(parent), | ||
ui(new Ui::SizeRangeBox) { | ||
ui->setupUi(this); | ||
d = new SizeRangeBoxPrivate(); | ||
} | ||
|
||
SizeRangeBox::~SizeRangeBox() { | ||
delete ui; | ||
delete d; | ||
} | ||
|
||
void SizeRangeBox::setMaximumSize(quint64 size) { | ||
ui->slider->setMaximum(size / SizeRangeBoxPrivate::divisionFactor); | ||
} | ||
|
||
quint64 SizeRangeBox::size() { | ||
return static_cast<quint64>(ui->slider->value()) * SizeRangeBoxPrivate::divisionFactor; | ||
} | ||
|
||
void SizeRangeBox::setSize(quint64 size) { | ||
ui->slider->setValue(size / SizeRangeBoxPrivate::divisionFactor); | ||
} | ||
|
||
void SizeRangeBox::on_slider_valueChanged(int value) { | ||
ui->sizeBox->setSize(static_cast<quint64>(value) * SizeRangeBoxPrivate::divisionFactor); | ||
} | ||
|
||
void SizeRangeBox::on_sizeBox_editingFinished() { | ||
this->setSize(ui->sizeBox->size()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef SIZERANGEBOX_H | ||
#define SIZERANGEBOX_H | ||
|
||
#include <QWidget> | ||
|
||
namespace Ui { | ||
class SizeRangeBox; | ||
} | ||
|
||
struct SizeRangeBoxPrivate; | ||
class SizeRangeBox : public QWidget { | ||
Q_OBJECT | ||
|
||
public: | ||
explicit SizeRangeBox(QWidget* parent = nullptr); | ||
~SizeRangeBox(); | ||
|
||
void setMaximumSize(quint64 size); | ||
|
||
quint64 size(); | ||
void setSize(quint64 size); | ||
|
||
private slots: | ||
void on_slider_valueChanged(int value); | ||
|
||
void on_sizeBox_editingFinished(); | ||
|
||
private: | ||
Ui::SizeRangeBox* ui; | ||
SizeRangeBoxPrivate* d; | ||
}; | ||
|
||
#endif // SIZERANGEBOX_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>SizeRangeBox</class> | ||
<widget class="QWidget" name="SizeRangeBox"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>49</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QSlider" name="slider"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="SizeEditBox" name="sizeBox"/> | ||
</item> | ||
</layout> | ||
</widget> | ||
<customwidgets> | ||
<customwidget> | ||
<class>SizeEditBox</class> | ||
<extends>QLineEdit</extends> | ||
<header>components/sizeeditbox.h</header> | ||
</customwidget> | ||
</customwidgets> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include "addlvpopover.h" | ||
#include "ui_addlvpopover.h" | ||
|
||
#include "DriveObjects/blockinterface.h" | ||
#include "DriveObjects/diskobject.h" | ||
#include "DriveObjects/logicalvolume.h" | ||
#include "DriveObjects/volumegroup.h" | ||
#include "partitioninformation.h" | ||
#include <frisbeeexception.h> | ||
#include <tcontentsizer.h> | ||
#include <terrorflash.h> | ||
|
||
struct AddLvPopoverPrivate { | ||
VolumeGroup* vg; | ||
}; | ||
|
||
AddLvPopover::AddLvPopover(VolumeGroup* vg, QWidget* parent) : | ||
QWidget(parent), | ||
ui(new Ui::AddLvPopover) { | ||
ui->setupUi(this); | ||
d = new AddLvPopoverPrivate(); | ||
d->vg = vg; | ||
|
||
new tContentSizer(ui->optionsWidget); | ||
|
||
ui->sizeRangeBox->setMaximumSize(d->vg->freeSize()); | ||
ui->sizeRangeBox->setSize(d->vg->freeSize()); | ||
|
||
for (QString type : PartitionInformation::availableFormatTypes()) { | ||
if (type == QStringLiteral("lvmpv")) continue; | ||
ui->formatBox->addItem(PartitionInformation::typeName(type), type); | ||
} | ||
ui->formatBox->addItem(tr("Leave Empty"), "empty"); | ||
} | ||
|
||
AddLvPopover::~AddLvPopover() { | ||
delete ui; | ||
delete d; | ||
} | ||
|
||
QCoro::Task<> AddLvPopover::on_createButton_clicked() { | ||
if (ui->nameBox->text().isEmpty()) { | ||
tErrorFlash::flashError(ui->nameBox); | ||
co_return; | ||
} | ||
|
||
if (ui->sizeRangeBox->size() == 0) { | ||
tErrorFlash::flashError(ui->sizeRangeBox); | ||
co_return; | ||
} | ||
|
||
auto format = ui->formatBox->currentData(Qt::UserRole).toString(); | ||
auto name = ui->nameBox->text(); | ||
auto size = ui->sizeRangeBox->size(); | ||
|
||
emit done(); | ||
|
||
try { | ||
auto lv = co_await d->vg->createPlainVolume(name, size, {}); | ||
if (format != QStringLiteral("empty")) { | ||
QVariantMap formatOptions{ | ||
{"label", name}, | ||
{"no-block", true}, | ||
{"update-partition-type", true}, | ||
{"tear-down", true} | ||
}; | ||
co_await lv->block()->interface<BlockInterface>()->format(format, formatOptions); | ||
} | ||
} catch (FrisbeeException& exception) { | ||
tWarn("AddLvPopover") << exception.response(); | ||
} | ||
} | ||
|
||
void AddLvPopover::on_titleLabel_backButtonClicked() { | ||
emit done(); | ||
} |
Oops, something went wrong.