#include <KShell>
#include <kio_version.h>
+#ifndef QT_NO_ACCESSIBILITY
+#include <QAccessible>
+#endif
#include <QApplication>
#include <QDesktopServices>
#include <QDropEvent>
// Url changes are still done via m_urlNavigator.
connect(urlNavigator, &DolphinUrlNavigator::urlChanged, m_urlNavigator.get(), &DolphinUrlNavigator::setLocationUrl);
- connect(urlNavigator, &DolphinUrlNavigator::urlsDropped, this, [=](const QUrl &destination, QDropEvent *event) {
+ connect(urlNavigator, &DolphinUrlNavigator::urlsDropped, this, [=, this](const QUrl &destination, QDropEvent *event) {
m_view->dropUrls(destination, event, urlNavigator->dropWidget());
});
// Aside from these, only visual things need to be connected.
connect(m_view, &DolphinView::urlChanged, urlNavigator, &DolphinUrlNavigator::setLocationUrl);
connect(urlNavigator, &DolphinUrlNavigator::activated, this, &DolphinViewContainer::activate);
+ connect(urlNavigator, &DolphinUrlNavigator::requestToLoseFocus, m_view, [this]() {
+ m_view->setFocus();
+ });
urlNavigator->setReadOnlyBadgeVisible(rootItem().isLocalFile() && !rootItem().isWritable());
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::urlsDropped, this, nullptr);
disconnect(m_view, &DolphinView::urlChanged, m_urlNavigatorConnected, &DolphinUrlNavigator::setLocationUrl);
disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::activated, this, &DolphinViewContainer::activate);
+ disconnect(m_urlNavigatorConnected, &DolphinUrlNavigator::requestToLoseFocus, m_view, nullptr);
m_urlNavigatorVisualState = m_urlNavigatorConnected->visualState();
m_urlNavigatorConnected = nullptr;
m_messageWidget->hide();
}
m_messageWidget->animatedShow();
+
+#ifndef QT_NO_ACCESSIBILITY
+ if (QAccessible::isActive() && isActive()) {
+ // To announce the new message keyboard focus must be moved to the message label. However, we do not have direct access to the label that is internal
+ // to the KMessageWidget. Instead we setFocus() on the KMessageWidget and trust that it has set correct focus handling.
+ m_messageWidget->setFocus();
+ }
+#endif
}
void DolphinViewContainer::readSettings()
if (url.isEmpty() || !url.isValid() || isSearchUrl(url)) {
url = Dolphin::homeUrl();
}
- m_urlNavigatorConnected->setLocationUrl(url);
+ if (m_urlNavigatorConnected) {
+ m_urlNavigatorConnected->setLocationUrl(url);
+ }
}
m_searchModeEnabled = enabled;
}
KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel();
- const QString pattern = url().adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/?");
- const auto &matchedPlaces =
- placesModel->match(placesModel->index(0, 0), KFilePlacesModel::UrlRole, QRegularExpression::anchoredPattern(pattern), 1, Qt::MatchRegularExpression);
- if (!matchedPlaces.isEmpty()) {
- return placesModel->text(matchedPlaces.first());
+ QModelIndex url_index = placesModel->closestItem(url());
+
+ if (url_index.isValid() && placesModel->url(url_index).matches(url(), QUrl::StripTrailingSlash)) {
+ return placesModel->text(url_index);
}
if (!url().isLocalFile()) {
// URL history.
m_urlNavigator->saveLocationState(QByteArray());
m_urlNavigator->setLocationUrl(newUrl);
+ if (m_searchBox->isActive()) {
+ m_searchBox->setSearchPath(newUrl);
+ }
setSearchModeEnabled(isSearchUrl(newUrl));
m_urlNavigator->blockSignals(block);
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), KMessageWidget::Warning);
+ // #473377: Delay changing the url to avoid modifying KCoreDirLister before KCoreDirListerCache::deleteDir() returns.
+ QTimer::singleShot(0, this, [&, newUrl, location] {
+ setUrl(newUrl);
+ showMessage(xi18n("Current location changed, <filename>%1</filename> is no longer accessible.", location), KMessageWidget::Warning);
+ });
+ } else
+ showMessage(xi18n("Current location changed, <filename>%1</filename> is no longer accessible.", location), KMessageWidget::Warning);
}
void DolphinViewContainer::slotOpenUrlFinished(KJob *job)