]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Add 'Mount' option to context menu of unmounted device in Places
authorThomas Surrel <thomas.surrel@protonmail.com>
Fri, 5 Oct 2018 20:45:50 +0000 (22:45 +0200)
committerThomas Surrel <thomas.surrel@protonmail.com>
Sun, 7 Oct 2018 13:31:49 +0000 (15:31 +0200)
Summary:
This is only a proposal but:
1/ it the sysmetric of the Unmount entry in the context menu of mounted devices
2/ I have to admit it took me a very long time to discover (by accident) that you can just (left-)click on a unmounted device to get it mounted automatically. I might not be the only feeling that you should be able to mount a device from the context menu ...

Twin of D15988 in Kio while dolphin is not based on the kio code for Places.

{F6306516}

Reviewers: #dolphin, #vdg, ngraham, elvisangelaccio

Reviewed By: #dolphin, #vdg, ngraham, elvisangelaccio

Subscribers: ngraham, acrouthamel, kfm-devel

Tags: #dolphin

Differential Revision: https://phabricator.kde.org/D15974

src/panels/places/placespanel.cpp

index 2829083e5a4e3372aac05c3f296837a66cdc7b3c..8d7f29384e76a12cacfb76c02e1440e0ff98e52c 100644 (file)
@@ -169,6 +169,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
     QAction* editAction = nullptr;
     QAction* teardownAction = nullptr;
     QAction* ejectAction = nullptr;
+    QAction* mountAction = nullptr;
 
     const bool isDevice = !item->udi().isEmpty();
     const bool isTrash = (item->url().scheme() == QLatin1String("trash"));
@@ -185,7 +186,11 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
             menu.addAction(teardownAction);
         }
 
-        if (teardownAction || ejectAction) {
+        if (item->storageSetupNeeded()) {
+            mountAction = menu.addAction(QIcon::fromTheme(QStringLiteral("media-mount")), i18nc("@action:inmenu", "Mount"));
+        }
+
+        if (teardownAction || ejectAction || mountAction) {
             menu.addSeparator();
         }
     } else {
@@ -243,6 +248,8 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
                 // TriggerItem does set up the storage first and then it will
                 // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton.
                 triggerItem(index, Qt::MiddleButton);
+            } else if (action == mountAction) {
+                m_model->requestStorageSetup(index);
             } else if (action == teardownAction) {
                 m_model->requestTearDown(index);
             } else if (action == ejectAction) {