diff options
| author | Thomas Surrel <[email protected]> | 2018-10-06 22:09:08 +0200 |
|---|---|---|
| committer | Thomas Surrel <[email protected]> | 2018-10-11 23:34:17 +0200 |
| commit | ddd746675c98d7e10f732271ce55c734fa48a5ca (patch) | |
| tree | 9ef14234844400ff40435d3b5a02f9efa1892d8f | |
| parent | 96f7a25b3d055c90d82cdb085add7d867ddc3df7 (diff) | |
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
| -rw-r--r-- | src/panels/places/placespanel.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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 <KIO/Job> #include <KIconLoader> #include <KLocalizedString> +#include <KMountPoint> #include <QGraphicsSceneDragDropEvent> #include <QIcon> @@ -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); } |
