┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dolphinmainwindow.cpp19
-rw-r--r--src/dolphinmainwindow.h10
-rw-r--r--src/panels/places/placesitemmodel.cpp3
-rw-r--r--src/panels/places/placesitemmodel.h1
-rw-r--r--src/panels/places/placespanel.cpp2
-rw-r--r--src/panels/places/placespanel.h1
6 files changed, 35 insertions, 1 deletions
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 8d4f50270..2c91cd07a 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -1271,6 +1271,10 @@ void DolphinMainWindow::updateWindowTitle()
void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
{
+ connect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, this, [this, mountPath]() {
+ setViewsToHomeIfMountPathOpen(mountPath);
+ });
+
if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = true;
m_terminalPanel->goHome();
@@ -1282,12 +1286,27 @@ void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mo
void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString& mountPath)
{
+ connect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, this, [this, mountPath]() {
+ setViewsToHomeIfMountPathOpen(mountPath);
+ });
+
if (m_terminalPanel && m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = false;
m_terminalPanel->goHome();
}
}
+void DolphinMainWindow::setViewsToHomeIfMountPathOpen(const QString& mountPath)
+{
+ const QVector<DolphinViewContainer*> theViewContainers = viewContainers();
+ for (DolphinViewContainer *viewContainer : theViewContainers) {
+ if (viewContainer && viewContainer->url().toLocalFile().startsWith(mountPath)) {
+ viewContainer->setUrl(QUrl::fromLocalFile(QDir::homePath()));
+ }
+ }
+ disconnect(m_placesPanel, &PlacesPanel::storageTearDownSuccessful, nullptr, nullptr);
+}
+
void DolphinMainWindow::setupActions()
{
// setup 'File' menu
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index c03eb1be0..80d0f891a 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -92,7 +92,15 @@ public:
*/
KNewFileMenu* newFileMenu() const;
- void setTabsToHomeIfMountPathOpen(const QString& mountPath);
+ /**
+ * Switch the window's view containers' locations to display the home path
+ * for any which are currently displaying a location corresponding to or
+ * within mountPath.
+ *
+ * This typically done after unmounting a disk at mountPath to ensure that
+ * the window is not displaying an invalid location.
+ */
+ void setViewsToHomeIfMountPathOpen(const QString& mountPath);
public slots:
/**
diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp
index de858389b..c9f1c8365 100644
--- a/src/panels/places/placesitemmodel.cpp
+++ b/src/panels/places/placesitemmodel.cpp
@@ -473,6 +473,9 @@ void PlacesItemModel::slotStorageTearDownDone(Solid::ErrorType error, const QVar
} else {
emit errorMessage(errorData.toString());
}
+ } else {
+ // No error; it must have been unmounted successfully
+ emit storageTearDownSuccessful();
}
disconnect(m_deviceToTearDown, &Solid::StorageAccess::teardownDone,
this, &PlacesItemModel::slotStorageTearDownDone);
diff --git a/src/panels/places/placesitemmodel.h b/src/panels/places/placesitemmodel.h
index 91f017cec..2b1f3bc14 100644
--- a/src/panels/places/placesitemmodel.h
+++ b/src/panels/places/placesitemmodel.h
@@ -130,6 +130,7 @@ signals:
void storageSetupDone(int index, bool success);
void storageTearDownRequested(const QString& mountPath);
void storageTearDownExternallyRequested(const QString& mountPath);
+ void storageTearDownSuccessful();
protected:
void onItemInserted(int index) override;
diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp
index 413d346b6..2e1d09e6b 100644
--- a/src/panels/places/placespanel.cpp
+++ b/src/panels/places/placespanel.cpp
@@ -104,6 +104,8 @@ void PlacesPanel::showEvent(QShowEvent* event)
this, &PlacesPanel::storageTearDownRequested);
connect(m_model, &PlacesItemModel::storageTearDownExternallyRequested,
this, &PlacesPanel::storageTearDownExternallyRequested);
+ connect(m_model, &PlacesItemModel::storageTearDownSuccessful,
+ this, &PlacesPanel::storageTearDownSuccessful);
m_view = new PlacesView();
m_view->setWidgetCreator(new KItemListWidgetCreator<PlacesItemListWidget>());
diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h
index 8ea4d0831..38bfa4c53 100644
--- a/src/panels/places/placespanel.h
+++ b/src/panels/places/placespanel.h
@@ -37,6 +37,7 @@ signals:
void storageTearDownRequested(const QString& mountPath);
void storageTearDownExternallyRequested(const QString& mountPath);
void showHiddenEntriesChanged(bool shown);
+ void storageTearDownSuccessful();
protected:
bool urlChanged() override;