diff --git a/src/panels/places/placesitemmodel.h b/src/panels/places/placesitemmodel.h --- a/src/panels/places/placesitemmodel.h +++ b/src/panels/places/placesitemmodel.h @@ -98,6 +98,7 @@ QAction* ejectAction(int index) const; QAction* teardownAction(int index) const; + void requestMount(int index); void requestEject(int index); void requestTearDown(int index); diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -205,6 +205,15 @@ KStandardItemModel::onItemChanged(index, changedRoles); } +void PlacesItemModel::requestMount(int index) +{ + const PlacesItem* item = placesItem(index); + if (item) { + Solid::StorageAccess *access = item->device().as(); + access->setup(); + } +} + QAction* PlacesItemModel::ejectAction(int index) const { const PlacesItem* item = placesItem(index); diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -169,6 +169,7 @@ 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 @@ 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 @@ // 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->requestMount(index); } else if (action == teardownAction) { m_model->requestTearDown(index); } else if (action == ejectAction) {