From ae1d441dacef7e52984201abdc9a918ce060021c Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Tue, 13 Oct 2020 11:51:59 -0600 Subject: Show home folder if needed after unmounting mounted disk Right now, when you unmount a device that any active view containers are displaying, nothing in the view changes. As a result, it's possible to try to navigate to files or folders in that view, which cannot be done because the disk that the files or folders are located on has been unmounted! With this commit, we detect that case and switch the view containers to show the home folder after the disk whose contents they are displaying gets unmounted. BUG: 158934 FIXED-IN: 20.12 --- src/panels/places/placesitemmodel.cpp | 3 +++ src/panels/places/placesitemmodel.h | 1 + src/panels/places/placespanel.cpp | 2 ++ src/panels/places/placespanel.h | 1 + 4 files changed, 7 insertions(+) (limited to 'src/panels') 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()); 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; -- cgit v1.3