X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/4d9ea4261a1f24e299595b897ea790eab1748fe9..b6e47b47508ac6c699c2a841175912ea2a2d9d2b:/src/dolphintabwidget.cpp diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp index cfb695e7d..254e654a7 100644 --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -162,10 +162,17 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU this, &DolphinTabWidget::activeViewChanged); connect(tabPage, &DolphinTabPage::activeViewUrlChanged, this, &DolphinTabWidget::tabUrlChanged); + connect(tabPage->activeViewContainer(), &DolphinViewContainer::captionChanged, this, [this, tabPage]() { + const int tabIndex = indexOf(tabPage); + Q_ASSERT(tabIndex >= 0); + tabBar()->setTabText(tabIndex, tabName(tabPage)); + }); + int newTabIndex = -1; if (!GeneralSettings::openNewTabAfterLastTab()) { newTabIndex = currentIndex() + 1; } + insertTab(newTabIndex, tabPage, QIcon() /* loaded in tabInserted */, tabName(tabPage)); if (focusWidget) { @@ -383,7 +390,9 @@ void DolphinTabWidget::tabUrlChanged(const QUrl& url) tabBar()->setTabText(index, tabName(tabPageAt(index))); tabBar()->setTabToolTip(index, url.toDisplayString(QUrl::PreferLocalFile)); if (tabBar()->isVisible()) { - tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url))); + // ensure the path url ends with a slash to have proper folder icon for remote folders + const QUrl pathUrl = QUrl(url.adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/")); + tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(pathUrl))); } else { // Mark as dirty, actually load once the tab bar actually gets shown tabBar()->setTabIcon(index, QIcon()); @@ -427,7 +436,9 @@ void DolphinTabWidget::tabInserted(int index) for (int i = 0; i < count(); ++i) { const QUrl url = tabPageAt(i)->activeViewContainer()->url(); if (tabBar()->tabIcon(i).isNull()) { - tabBar()->setTabIcon(i, QIcon::fromTheme(KIO::iconNameForUrl(url))); + // ensure the path url ends with a slash to have proper folder icon for remote folders + const QUrl pathUrl = QUrl(url.adjusted(QUrl::StripTrailingSlash).toString(QUrl::FullyEncoded).append("/")); + tabBar()->setTabIcon(i, QIcon::fromTheme(KIO::iconNameForUrl(pathUrl))); } if (tabBar()->tabToolTip(i).isEmpty()) { tabBar()->setTabToolTip(index, url.toDisplayString(QUrl::PreferLocalFile));