X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/6e6fcf8da80b5b6821837054ae51eaa19edc24b8..ef4525e53568385053a638311f6ad751d42f2f4c:/src/dolphinviewcontainer.cpp diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 3fedef6fc..62c29a1fc 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -33,6 +33,9 @@ #include #include +#ifndef QT_NO_ACCESSIBILITY +#include +#endif #include #include #include @@ -41,6 +44,7 @@ #include #include #include +#include // An overview of the widgets contained by this ViewContainer struct LayoutStructure { @@ -435,6 +439,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() @@ -533,6 +545,15 @@ QString DolphinViewContainer::captionWindowTitle() const QString DolphinViewContainer::caption() const { + // see KUrlNavigatorPrivate::firstButtonText(). + if (url().path().isEmpty() || url().path() == QLatin1Char('/')) { + QUrlQuery query(url()); + const QString title = query.queryItemValue(QStringLiteral("title")); + if (!title.isEmpty()) { + return title; + } + } + if (isSearchModeEnabled()) { if (currentSearchText().isEmpty()) { return i18n("Search"); @@ -542,12 +563,11 @@ QString DolphinViewContainer::caption() const } 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()) { @@ -741,6 +761,18 @@ void DolphinViewContainer::slotfileMiddleClickActivated(const KFileItem &item) job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished); job->start(); + } else { + // If no 2nd service available, try to open archives in new tabs, regardless of the "Open archives as folder" setting. + const QUrl &url = DolphinView::openItemAsFolderUrl(item); + const auto modifiers = QGuiApplication::keyboardModifiers(); + if (!url.isEmpty()) { + // keep in sync with KUrlNavigator::slotNavigatorButtonClicked + if (modifiers & Qt::ShiftModifier) { + Q_EMIT activeTabRequested(url); + } else { + Q_EMIT tabRequested(url); + } + } } } @@ -954,10 +986,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)