]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Disable unmount option for / or /home
authorThomas Surrel <thomas.surrel@protonmail.com>
Sat, 6 Oct 2018 20:09:08 +0000 (22:09 +0200)
committerThomas Surrel <thomas.surrel@protonmail.com>
Thu, 11 Oct 2018 21:34:17 +0000 (23:34 +0200)
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

src/panels/places/placespanel.cpp

index 983f3f392fc74004155d3ecf2214bba71e042a50..8a8fa8a7da5bbf3463b2e43add1b215bfdf1a854 100644 (file)
@@ -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);
         }