Add possibility to remove an existing mount point
User is able to remove an existing Mount point via Partition -> Edit Mount Point -> Remove. Differential Revision: https://phabricator.kde.org/D10514
This commit is contained in:
parent
7dd9e17a8c
commit
be07085500
|
@ -49,19 +49,20 @@ EditMountPointDialog::EditMountPointDialog(QWidget* parent, Partition& p) :
|
|||
this );
|
||||
mainLayout->addWidget(dbb);
|
||||
connect(dbb, &QDialogButtonBox::accepted,
|
||||
this, &EditMountPointDialog::accept);
|
||||
this, [=] () {accept_(Edit);} );
|
||||
connect(dbb, &QDialogButtonBox::rejected,
|
||||
this, &EditMountPointDialog::reject);
|
||||
connect(widget().m_ButtonRemove, &QPushButton::clicked, this, [=] () {accept_(Remove);} );
|
||||
}
|
||||
|
||||
/** Destroys an EditMOuntOptionsDialog instance */
|
||||
/** Destroys an EditMountOptionsDialog instance */
|
||||
EditMountPointDialog::~EditMountPointDialog()
|
||||
{
|
||||
KConfigGroup kcg(KSharedConfig::openConfig(), "editMountPointDialog");
|
||||
kcg.writeEntry("Geometry", saveGeometry());
|
||||
}
|
||||
|
||||
void EditMountPointDialog::accept()
|
||||
void EditMountPointDialog::accept_(MountPointAction action)
|
||||
{
|
||||
if (KMessageBox::warningContinueCancel(this,
|
||||
xi18nc("@info", "<para>Are you sure you want to save the changes you made to the system table file <filename>/etc/fstab</filename>?</para>"
|
||||
|
@ -71,10 +72,14 @@ void EditMountPointDialog::accept()
|
|||
KStandardGuiItem::cancel(),
|
||||
QStringLiteral("reallyWriteMountPoints")) == KMessageBox::Cancel)
|
||||
return;
|
||||
|
||||
widget().acceptChanges();
|
||||
if (writeMountpoints(widget().fstabEntries()))
|
||||
partition().setMountPoint(widget().editPath().text());
|
||||
if(action == Remove)
|
||||
widget().removeMountPoint();
|
||||
else if (action == Edit)
|
||||
widget().acceptChanges();
|
||||
if (writeMountpoints(widget().fstabEntries())) {
|
||||
if (action == Edit)
|
||||
partition().setMountPoint(widget().editPath().text());
|
||||
}
|
||||
else
|
||||
KMessageBox::sorry(this,
|
||||
xi18nc("@info", "Could not save mount points to file <filename>/etc/fstab</filename>."),
|
||||
|
|
|
@ -28,6 +28,12 @@ class Partition;
|
|||
class QWidget;
|
||||
class QString;
|
||||
|
||||
enum MountPointAction
|
||||
{
|
||||
Remove = 1,
|
||||
Edit = 2
|
||||
};
|
||||
|
||||
class EditMountPointDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
|
@ -39,7 +45,7 @@ protected:
|
|||
return *m_DialogWidget;
|
||||
}
|
||||
|
||||
void accept() override;
|
||||
void accept_(MountPointAction action);
|
||||
|
||||
private:
|
||||
Partition& partition() {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <QPointer>
|
||||
#include <QString>
|
||||
|
||||
EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, const Partition& p) :
|
||||
EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partition& p) :
|
||||
QWidget(parent),
|
||||
m_Partition(p)
|
||||
{
|
||||
|
@ -159,6 +159,22 @@ void EditMountPointDialogWidget::buttonSelectClicked(bool)
|
|||
editPath().setText(s);
|
||||
}
|
||||
|
||||
void EditMountPointDialogWidget::removeMountPoint()
|
||||
{
|
||||
int i=0;
|
||||
for (const auto &e : fstabEntries()) {
|
||||
if(e.fsSpec().contains(partition().deviceNode()) || e.fsSpec().contains(partition().fileSystem().uuid()) ||
|
||||
e.fsSpec().contains(partition().fileSystem().label()) || e.fsSpec().contains(partition().label()) || e.fsSpec().contains(partition().uuid()) )
|
||||
{
|
||||
fstabEntries().removeAt(i);
|
||||
partition().setMountPoint(QString());
|
||||
i--;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void EditMountPointDialogWidget::buttonMoreClicked(bool)
|
||||
{
|
||||
QPointer<EditMountOptionsDialog> dlg = new EditMountOptionsDialog(this, m_Options.split(QLatin1Char(',')));
|
||||
|
|
|
@ -39,7 +39,7 @@ class QStringList;
|
|||
class EditMountPointDialogWidget : public QWidget, public Ui::EditMountPointDialogWidgetBase
|
||||
{
|
||||
public:
|
||||
EditMountPointDialogWidget(QWidget* parent, const Partition& p);
|
||||
EditMountPointDialogWidget(QWidget* parent, Partition& p);
|
||||
~EditMountPointDialogWidget();
|
||||
|
||||
QPushButton& buttonMore() {
|
||||
|
@ -75,6 +75,7 @@ public:
|
|||
}
|
||||
|
||||
void acceptChanges();
|
||||
void removeMountPoint();
|
||||
bool writeMountpoints(const QString& filename);
|
||||
|
||||
protected:
|
||||
|
@ -90,6 +91,10 @@ private:
|
|||
return m_BoxOptions;
|
||||
}
|
||||
|
||||
Partition& partition() {
|
||||
return m_Partition;
|
||||
}
|
||||
|
||||
const Partition& partition() const {
|
||||
return m_Partition;
|
||||
}
|
||||
|
@ -98,7 +103,7 @@ private:
|
|||
FstabEntryList m_fstabEntries;
|
||||
FstabEntry *entry;
|
||||
|
||||
const Partition& m_Partition;
|
||||
Partition& m_Partition;
|
||||
QString m_Options;
|
||||
QString m_deviceNode;
|
||||
std::map<QString, QCheckBox*> m_BoxOptions;
|
||||
|
|
|
@ -6,11 +6,21 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>534</width>
|
||||
<height>353</height>
|
||||
<width>600</width>
|
||||
<height>374</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="5" column="1" colspan="3">
|
||||
<widget class="QLineEdit" name="m_EditPath">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="m_LabelPath">
|
||||
<property name="text">
|
||||
|
@ -24,29 +34,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="5">
|
||||
<widget class="QLineEdit" name="m_EditPath">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="6">
|
||||
<widget class="QPushButton" name="m_ButtonSelect">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="m_LabelType">
|
||||
<property name="text">
|
||||
|
@ -146,7 +133,7 @@
|
|||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="m_LabelDumpFreq">
|
||||
<property name="text">
|
||||
<string>Dump Frequency:</string>
|
||||
<string>Dump &Frequency:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -175,7 +162,7 @@
|
|||
<item row="12" column="3">
|
||||
<widget class="QLabel" name="m_LabelPassNumber">
|
||||
<property name="text">
|
||||
<string>Pass Number:</string>
|
||||
<string>Pass &Number:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
|
@ -188,19 +175,6 @@
|
|||
<item row="12" column="4">
|
||||
<widget class="QSpinBox" name="m_SpinPassNumber"/>
|
||||
</item>
|
||||
<item row="12" column="5" colspan="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>135</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="7">
|
||||
<widget class="QLabel" name="m_LabelNameValue">
|
||||
<property name="font">
|
||||
|
@ -282,7 +256,7 @@
|
|||
<item row="4" column="1">
|
||||
<widget class="QRadioButton" name="m_RadioDeviceNode">
|
||||
<property name="text">
|
||||
<string>Device Node</string>
|
||||
<string>De&vice Node</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
|
@ -292,14 +266,14 @@
|
|||
<item row="4" column="2">
|
||||
<widget class="QRadioButton" name="m_RadioUUID">
|
||||
<property name="text">
|
||||
<string>UUID</string>
|
||||
<string>UU&ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="3">
|
||||
<widget class="QRadioButton" name="m_RadioLabel">
|
||||
<property name="text">
|
||||
<string>Label</string>
|
||||
<string>&Label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -313,6 +287,45 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="5" colspan="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>135</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="QPushButton" name="m_ButtonSelect">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="6">
|
||||
<widget class="QPushButton" name="m_ButtonRemove">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -177,11 +177,7 @@ Partition* PartitionManagerWidget::selectedPartition()
|
|||
if (selectedDevice() == nullptr || selectedDevice()->partitionTable() == nullptr || partTableWidget().activeWidget() == nullptr)
|
||||
return nullptr;
|
||||
|
||||
// The active partition we get from the part table widget is const; we need non-const.
|
||||
// So take the first sector and find the partition in the selected device's
|
||||
// partition table.
|
||||
const Partition* activePartition = partTableWidget().activeWidget()->partition();
|
||||
return selectedDevice()->partitionTable()->findPartitionBySector(activePartition->firstSector(), PartitionRole(PartitionRole::Any));
|
||||
return partTableWidget().activeWidget()->partition();
|
||||
}
|
||||
|
||||
void PartitionManagerWidget::setSelectedDevice(const QString& deviceNode)
|
||||
|
|
Loading…
Reference in New Issue