X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/046ddcf5607e597cd6290147bf7ee10c08e526dd..5ce6886c60a53afb9f1465aa8a242abf0eaef5f0:/src/dolphinviewcontainer.cpp diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index e55519d04..f2df638f6 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -33,6 +33,9 @@ #include #include +#ifndef QT_NO_ACCESSIBILITY +#include +#endif #include #include #include @@ -300,12 +303,15 @@ void DolphinViewContainer::connectUrlNavigator(DolphinUrlNavigator *urlNavigator // 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()); @@ -322,6 +328,7 @@ void DolphinViewContainer::disconnectUrlNavigator() 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; @@ -436,6 +443,14 @@ void DolphinViewContainer::showMessage(const QString &message, KMessageWidget::M 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() @@ -482,7 +497,9 @@ void DolphinViewContainer::setSearchModeEnabled(bool enabled) if (url.isEmpty() || !url.isValid() || isSearchUrl(url)) { url = Dolphin::homeUrl(); } - m_urlNavigatorConnected->setLocationUrl(url); + if (m_urlNavigatorConnected) { + m_urlNavigatorConnected->setLocationUrl(url); + } } m_searchModeEnabled = enabled; @@ -879,6 +896,9 @@ void DolphinViewContainer::redirect(const QUrl &oldUrl, const QUrl &newUrl) // 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); @@ -975,10 +995,13 @@ void DolphinViewContainer::slotCurrentDirectoryRemoved() const QString dirPath = url().toLocalFile(); const QString newPath = getNearestExistingAncestorOfPath(dirPath); const QUrl newUrl = QUrl::fromLocalFile(newPath); - setUrl(newUrl); - } - - showMessage(xi18n("Current location changed, %1 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, %1 is no longer accessible.", location), KMessageWidget::Warning); + }); + } else + showMessage(xi18n("Current location changed, %1 is no longer accessible.", location), KMessageWidget::Warning); } void DolphinViewContainer::slotOpenUrlFinished(KJob *job)