diff options
| author | Méven Car <[email protected]> | 2020-11-24 18:07:56 +0100 |
|---|---|---|
| committer | Nate Graham <[email protected]> | 2021-08-30 14:58:08 +0000 |
| commit | 653d5714a7690bd2dca36a39fc92c0ab1926fab5 (patch) | |
| tree | 5d818b129dd6fa9acf39c68d2028f40ebe47ac8a /src/dolphintabwidget.cpp | |
| parent | b712c9fc4631c85c469e3ff64d67f4abc9a8a542 (diff) | |
Tabs: ensure to have folder icons for remote folders
KIO::iconForUrl relies on filename to find the icon for remote files.
Appending / at the end of the filename allows it to interpret it as
a folder.
This causes inconsistent tab icons.
To reproduce:
Open in a tab a url on a smb or sftp folder, i.e sftp:/my-server/photos
Before:
Icon is a cloud.
After:
Icon is a folder
Previously a folder icon could be presented if the tab was first opened
with a url with a trailing /
Diffstat (limited to 'src/dolphintabwidget.cpp')
| -rw-r--r-- | src/dolphintabwidget.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp index cfb695e7d..0e7012d3b 100644 --- a/src/dolphintabwidget.cpp +++ b/src/dolphintabwidget.cpp @@ -383,7 +383,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 +429,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)); |
