Add new LV operation

This commit is contained in:
Chantara Tith 2016-06-25 18:00:16 +07:00 committed by Andrius Štikonas
parent 6c946d7a2c
commit 07bf741c6a
4 changed files with 183 additions and 131 deletions

View File

@ -97,6 +97,17 @@ void NewDialog::setupDialog()
dialogWidget().checkBoxEncrypt().hide();
dialogWidget().editPassphrase().hide();
if (device().type() == Device::Disk_Device) {
dialogWidget().lvName().hide();
dialogWidget().textLVName().hide();
}
if (device().type() == Device::LVM_Device) {
dialogWidget().labelFreeBefore().hide();
dialogWidget().spinFreeBefore().hide();
dialogWidget().labelFreeAfter().hide();
dialogWidget().spinFreeAfter().hide();
}
dialogWidget().editPassphrase().setMinimumPasswordLength(1);
dialogWidget().editPassphrase().setMaximumPasswordLength(512); // cryptsetup does not support longer passwords
@ -104,8 +115,6 @@ void NewDialog::setupDialog()
KColorScheme colorScheme(QPalette::Active, KColorScheme::View);
dialogWidget().editPassphrase().setBackgroundWarningColor(colorScheme.background(KColorScheme::NegativeBackground).color());
// listen to password status updates
connect(&dialogWidget().editPassphrase(), &KNewPasswordWidget::passwordStatusChanged, this, &NewDialog::slotPasswordStatusChanged);
// don't move these above the call to parent's setupDialog, because only after that has
// run there is a valid partition set in the part resizer widget and they will need that.
@ -121,6 +130,9 @@ void NewDialog::setupConnections()
connect(&dialogWidget().checkBoxEncrypt(), &QCheckBox::toggled, this, &NewDialog::onRoleChanged);
connect(&dialogWidget().comboFileSystem(), static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &NewDialog::onFilesystemChanged);
connect(&dialogWidget().label(), &QLineEdit::textChanged, this, &NewDialog::onLabelChanged);
// listen to password status updates
connect(&dialogWidget().editPassphrase(), &KNewPasswordWidget::passwordStatusChanged, this, &NewDialog::slotPasswordStatusChanged);
connect(&dialogWidget().lvName(), &QLineEdit::textChanged, this, &NewDialog::onLVNameChanged);
SizeDialogBase::setupConnections();
}
@ -227,6 +239,12 @@ void NewDialog::slotPasswordStatusChanged()
}
}
void NewDialog::onLVNameChanged(const QString& newName)
{
//TODO: filter lvName
partition().setPartitionPath(device().deviceNode() + QStringLiteral("/") + newName.trimmed());
}
void NewDialog::updateHideAndShow()
{
// this is mostly copy'n'pasted from PartPropsDialog::updateHideAndShow()

View File

@ -44,6 +44,7 @@ protected:
void onRoleChanged(bool);
void onFilesystemChanged(int);
void onLabelChanged(const QString& newLabel);
void onLVNameChanged(const QString& newName);
void setupConnections() override;
void setupDialog() override;

View File

@ -40,10 +40,18 @@ public:
return *m_PartResizerWidget;
}
QLabel& labelFreeBefore() {
Q_ASSERT(m_LabelFreeBefore);
return *m_LabelFreeBefore;
}
QDoubleSpinBox& spinFreeBefore() {
Q_ASSERT(m_SpinFreeBefore);
return *m_SpinFreeBefore;
}
QLabel& labelFreeAfter() {
Q_ASSERT(m_LabelFreeAfter);
return *m_LabelFreeAfter;
}
QDoubleSpinBox& spinFreeAfter() {
Q_ASSERT(m_SpinFreeAfter);
return *m_SpinFreeAfter;
@ -89,6 +97,14 @@ public:
Q_ASSERT(m_EditPassphrase);
return *m_EditPassphrase;
}
QLabel& textLVName() {
Q_ASSERT(m_LabelTextLVName);
return *m_LabelTextLVName;
}
QLineEdit& lvName() {
Q_ASSERT(m_EditLVName);
return *m_EditLVName;
}
QLabel& textLabel() {
Q_ASSERT(m_LabelTextLabel);

View File

@ -7,17 +7,26 @@
<x>0</x>
<y>0</y>
<width>653</width>
<height>693</height>
<height>814</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="10" column="1">
<widget class="FormattedSpinBox" name="m_SpinCapacity">
<property name="minimum">
<double>0.000000000000000</double>
<item row="11" column="0">
<widget class="QLabel" name="m_LabelFreeBefore">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<double>999999999.000000000000000</double>
<property name="text">
<string comment="@label:listbox">F&amp;ree space before:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_SpinFreeBefore</cstring>
</property>
</widget>
</item>
@ -37,24 +46,18 @@
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="PartResizerWidget" name="m_PartResizerWidget" native="true">
<property name="minimumSize">
<size>
<width>400</width>
<height>60</height>
</size>
<item row="12" column="1">
<widget class="FormattedSpinBox" name="m_SpinCapacity">
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
<property name="maximum">
<double>999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="m_LabelRole">
<item row="3" column="0">
<widget class="QLabel" name="m_LabelFileSystem">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -62,13 +65,46 @@
</sizepolicy>
</property>
<property name="text">
<string comment="@label:listbox">Partition &amp;type:</string>
<string comment="@label:listbox">File system:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_RadioPrimary</cstring>
<cstring>m_ComboFileSystem</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="m_CheckBoxEncrypt">
<property name="toolTip">
<string>Set up encryption for this filesystem with LUKS. You will be asked to provide a passphrase.</string>
</property>
<property name="text">
<string>Encrypt with LUKS</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string comment="@label">Maximum size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLabel" name="m_LabelMaxSize">
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
@ -97,56 +133,7 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="m_LabelFileSystem">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string comment="@label:listbox">File system:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_ComboFileSystem</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="m_ComboFileSystem"/>
</item>
</layout>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="m_CheckBoxEncrypt">
<property name="toolTip">
<string>Set up encryption for this filesystem with LUKS. You will be asked to provide a passphrase.</string>
</property>
<property name="text">
<string>Encrypt with LUKS</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="m_LabelTextLabel">
<property name="text">
<string comment="@label">Label:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_EditLabel</cstring>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="8" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLineEdit" name="m_EditLabel"/>
@ -163,7 +150,62 @@
</item>
</layout>
</item>
<item row="7" column="0">
<item row="0" column="0" colspan="2">
<widget class="PartResizerWidget" name="m_PartResizerWidget" native="true">
<property name="minimumSize">
<size>
<width>400</width>
<height>60</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>60</height>
</size>
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QComboBox" name="m_ComboFileSystem"/>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="m_LabelRole">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string comment="@label:listbox">Partition &amp;type:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_RadioPrimary</cstring>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="m_LabelTextLabel">
<property name="text">
<string comment="@label">Label:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_EditLabel</cstring>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
@ -179,56 +221,7 @@
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="m_LabelMinSize">
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string comment="@label">Maximum size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="m_LabelMaxSize">
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string comment="@label:listbox">F&amp;ree space before:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>m_SpinFreeBefore</cstring>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="11" column="1">
<widget class="FormattedSpinBox" name="m_SpinFreeBefore">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@ -244,7 +237,7 @@
</property>
</widget>
</item>
<item row="10" column="0">
<item row="12" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
@ -263,8 +256,8 @@
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_3">
<item row="13" column="0">
<widget class="QLabel" name="m_LabelFreeAfter">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -282,7 +275,7 @@
</property>
</widget>
</item>
<item row="11" column="1">
<item row="13" column="1">
<widget class="FormattedSpinBox" name="m_SpinFreeAfter">
<property name="minimum">
<double>0.000000000000000</double>
@ -292,7 +285,7 @@
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<item row="14" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -311,6 +304,30 @@
<item row="5" column="0" colspan="2">
<widget class="KNewPasswordWidget" name="m_EditPassphrase"/>
</item>
<item row="9" column="1">
<widget class="QLabel" name="m_LabelMinSize">
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="m_LabelTextLVName">
<property name="text">
<string>Logical Volume Name:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="m_EditLVName">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>