// Initialize the main view
m_view = new DolphinView(url, this);
connect(m_view, &DolphinView::urlChanged,
- m_filterBar, &FilterBar::slotUrlChanged);
+ m_filterBar, &FilterBar::clearIfUnlocked);
connect(m_view, &DolphinView::urlChanged,
m_messageWidget, &KMessageWidget::hide);
// m_urlNavigator stays in sync with m_view's location changes and
this, &DolphinViewContainer::slotHiddenFilesShownChanged);
connect(m_view, &DolphinView::sortHiddenLastChanged,
this, &DolphinViewContainer::slotSortHiddenLastChanged);
+ connect(m_view, &DolphinView::currentDirectoryRemoved,
+ this, &DolphinViewContainer::slotCurrentDirectoryRemoved);
// Initialize status bar
m_statusBar = new DolphinStatusBar(this);
Q_EMIT showFilterBarChanged(false);
}
+void DolphinViewContainer::clearFilterBar()
+{
+ m_filterBar->clearIfUnlocked();
+}
+
void DolphinViewContainer::setNameFilter(const QString& nameFilter)
{
m_view->hideToolTip(ToolTipManager::HideBehavior::Instantly);
}
}
+void DolphinViewContainer::slotCurrentDirectoryRemoved()
+{
+ const QString location(url().toDisplayString(QUrl::PreferLocalFile));
+ if (url().isLocalFile()) {
+ const QString dirPath = url().toLocalFile();
+ const QString newPath = getNearestExistingAncestorOfPath(dirPath);
+ const QUrl newUrl = QUrl::fromLocalFile(newPath);
+ setUrl(newUrl);
+ }
+
+ showMessage(xi18n("Current location changed, <filename>%1</filename> is no longer accessible.", location), Warning);
+}
+
void DolphinViewContainer::slotOpenUrlFinished(KJob *job)
{
if (job->error() && job->error() != KIO::ERR_USER_CANCELED) {
m_view->restoreState(stream);
}
}
+
+QString DolphinViewContainer::getNearestExistingAncestorOfPath(const QString& path) const
+{
+ QDir dir(path);
+ do {
+ dir.setPath(QDir::cleanPath(dir.filePath(QStringLiteral(".."))));
+ }
+ while (!dir.exists() && !dir.isRoot());
+
+ return dir.exists() ? dir.path() : QString{};
+}