#include <QRegularExpression>
#include <QTimer>
#include <QUrl>
+#include <QUrlQuery>
// An overview of the widgets contained by this ViewContainer
struct LayoutStructure {
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");
}
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()) {
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);
+ }
+ }
}
}