From: Thomas Surrel Date: Sat, 6 Oct 2018 20:09:08 +0000 (+0200) Subject: Disable unmount option for / or /home X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/ddd746675c98d7e10f732271ce55c734fa48a5ca Disable unmount option for / or /home Summary: This removes the 'Unmount' context menu in the Places panel for discs corresponding to / and /home. It does not make much sense to offer an option that will always fail. BUG: 399659 Reviewers: #dolphin, #vdg, elvisangelaccio Reviewed By: #dolphin, elvisangelaccio Subscribers: sefaeyeoglu, elvisangelaccio, ngraham, broulik, bruns, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D15989 --- diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index 983f3f392..8a8fa8a7d 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -182,6 +183,16 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos) teardownAction = m_model->teardownAction(index); if (teardownAction) { + // Disable teardown option for root and home partitions + bool teardownEnabled = item->url() != QUrl::fromLocalFile(QDir::rootPath()); + if (teardownEnabled) { + KMountPoint::Ptr mountPoint = KMountPoint::currentMountPoints().findByPath(QDir::homePath()); + if (mountPoint && item->url() == QUrl::fromLocalFile(mountPoint->mountPoint())) { + teardownEnabled = false; + } + } + teardownAction->setEnabled(teardownEnabled); + teardownAction->setParent(&menu); menu.addAction(teardownAction); }