diff --git a/src/gui/editmountpointdialog.cpp b/src/gui/editmountpointdialog.cpp index 02b4f36..c6d07d2 100644 --- a/src/gui/editmountpointdialog.cpp +++ b/src/gui/editmountpointdialog.cpp @@ -1,89 +1,89 @@ /************************************************************************* * Copyright (C) 2009, 2010 by Volker Lanz * * Copyright (C) 2015 by Teo Mrnjavac * * Copyright (C) 2016 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 3 of * * the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see .* *************************************************************************/ #include "gui/editmountpointdialog.h" #include "gui/editmountpointdialogwidget.h" #include #include #include #include #include #include #include #include EditMountPointDialog::EditMountPointDialog(QWidget* parent, Partition& p) : QDialog(parent), m_Partition(p), m_DialogWidget(new EditMountPointDialogWidget(this, partition())) { QVBoxLayout *mainLayout = new QVBoxLayout(this); setLayout(mainLayout); mainLayout->addWidget(&widget()); setWindowTitle(xi18nc("@title:window", "Edit mount point for %1", p.deviceNode())); KConfigGroup kcg(KSharedConfig::openConfig(), "editMountPointDialog"); restoreGeometry(kcg.readEntry("Geometry", QByteArray())); QDialogButtonBox* dbb = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this ); mainLayout->addWidget(dbb); connect(dbb, &QDialogButtonBox::accepted, - this, [=] () {accept_(Edit);} ); + this, [=] () {accept_(MountPointAction::Edit);} ); connect(dbb, &QDialogButtonBox::rejected, this, &EditMountPointDialog::reject); - connect(widget().m_ButtonRemove, &QPushButton::clicked, this, [=] () {accept_(Remove);} ); + connect(widget().m_ButtonRemove, &QPushButton::clicked, this, [=] () {accept_(MountPointAction::Remove);} ); } /** Destroys an EditMountOptionsDialog instance */ EditMountPointDialog::~EditMountPointDialog() { KConfigGroup kcg(KSharedConfig::openConfig(), "editMountPointDialog"); kcg.writeEntry("Geometry", saveGeometry()); } void EditMountPointDialog::accept_(MountPointAction action) { if (KMessageBox::warningContinueCancel(this, xi18nc("@info", "Are you sure you want to save the changes you made to the system table file /etc/fstab?" "This will overwrite the existing file on your hard drive now. This can not be undone."), xi18nc("@title:window", "Really save changes?"), KGuiItem(xi18nc("@action:button", "Save changes"), QStringLiteral("arrow-right")), KStandardGuiItem::cancel(), QStringLiteral("reallyWriteMountPoints")) == KMessageBox::Cancel) return; - if(action == Remove) + if(action == MountPointAction::Remove) widget().removeMountPoint(); - else if (action == Edit) + else if (action == MountPointAction::Edit) widget().acceptChanges(); if (writeMountpoints(widget().fstabEntries())) { - if (action == Edit) + if (action == MountPointAction::Edit) partition().setMountPoint(widget().editPath().currentText()); } else KMessageBox::sorry(this, xi18nc("@info", "Could not save mount points to file /etc/fstab."), xi18nc("@title:window", "Error While Saving Mount Points")); QDialog::accept(); } diff --git a/src/gui/editmountpointdialog.h b/src/gui/editmountpointdialog.h index fcdc7cc..e1905ad 100644 --- a/src/gui/editmountpointdialog.h +++ b/src/gui/editmountpointdialog.h @@ -1,61 +1,61 @@ /************************************************************************* * Copyright (C) 2009, 2010 by Volker Lanz * * Copyright (C) 2016 by Andrius Štikonas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * * published by the Free Software Foundation; either version 3 of * * the License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see .* *************************************************************************/ #if !defined(EDITMOUNTPOINTDIALOG_H) #define EDITMOUNTPOINTDIALOG_H #include class EditMountPointDialogWidget; class Partition; class QWidget; class QString; -enum MountPointAction +enum class MountPointAction { Remove, Edit }; class EditMountPointDialog : public QDialog { public: EditMountPointDialog(QWidget* parent, Partition& p); ~EditMountPointDialog(); protected: EditMountPointDialogWidget& widget() { return *m_DialogWidget; } void accept_(MountPointAction action); private: Partition& partition() { return m_Partition; } private: Partition& m_Partition; EditMountPointDialogWidget* m_DialogWidget; }; #endif