X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/47a5071fc9eace09cdc9e4e89eacda06fb893194..ae1d441dacef7e52984201abdc9a918ce060021c:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 8bc890f04..2c91cd07a 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -204,9 +204,14 @@ DolphinMainWindow::~DolphinMainWindow() QVector DolphinMainWindow::viewContainers() const { QVector viewContainers; - viewContainers.reserve(m_tabWidget->count()); + for (int i = 0; i < m_tabWidget->count(); ++i) { - viewContainers << m_tabWidget->tabPageAt(i)->activeViewContainer(); + DolphinTabPage *tabPage = m_tabWidget->tabPageAt(i); + + viewContainers << tabPage->primaryViewContainer(); + if (tabPage->splitViewEnabled()) { + viewContainers << tabPage->secondaryViewContainer(); + } } return viewContainers; } @@ -1266,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(); @@ -1277,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 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