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
#include <KIO/Job>
#include <KIconLoader>
#include <KLocalizedString>
+#include <KMountPoint>
#include <QGraphicsSceneDragDropEvent>
#include <QIcon>
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);
}