┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphintabwidget.cpp
diff options
context:
space:
mode:
authorDavid Hallas <[email protected]>2018-07-28 17:29:00 +0200
committerDavid Hallas <[email protected]>2018-08-24 12:09:26 +0200
commit44a21ea51a055c7429ddee866e35b0a5a21c072b (patch)
tree024226885442cdf341a660482efc29b4365dba3f /src/dolphintabwidget.cpp
parent79c485a66de7444e87708ae25c5f8a661a89dd21 (diff)
Unify window and tab title
Summary: Previously the title of tabs was a prettyfied version of the URL. This is inconsistent with the title of the Window and in some cases for specials URLs kind of misleading. This commit generalizes the code from DolphinMainWindow so that both the DolphinMainWindow title and the tab title uses the same function for the title. This also means that the 'Show Full Path in Title Bar' also applies to the tab title, and also that searches changes the tab title. FEATURE: 387851 Test Plan: Open a new tab from the places panel and navigate around. Reviewers: #dolphin, ngraham, elvisangelaccio, markg Reviewed By: #dolphin, ngraham, markg Subscribers: markg, kfm-devel Tags: #dolphin Differential Revision: https://phabricator.kde.org/D14442
Diffstat (limited to 'src/dolphintabwidget.cpp')
-rw-r--r--src/dolphintabwidget.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp
index a5c2f8c98..600974f56 100644
--- a/src/dolphintabwidget.cpp
+++ b/src/dolphintabwidget.cpp
@@ -116,6 +116,7 @@ void DolphinTabWidget::refreshViews()
{
const int tabCount = count();
for (int i = 0; i < tabCount; ++i) {
+ tabBar()->setTabText(i, tabName());
tabPageAt(i)->refreshViews();
}
}
@@ -160,7 +161,7 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
this, &DolphinTabWidget::activeViewChanged);
connect(tabPage, &DolphinTabPage::activeViewUrlChanged,
this, &DolphinTabWidget::tabUrlChanged);
- addTab(tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(primaryUrl));
+ addTab(tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName());
if (focusWidget) {
// The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
@@ -305,7 +306,7 @@ void DolphinTabWidget::tabUrlChanged(const QUrl& url)
{
const int index = indexOf(qobject_cast<QWidget*>(sender()));
if (index >= 0) {
- tabBar()->setTabText(index, tabName(url));
+ tabBar()->setTabText(index, tabName());
tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url)));
// Emit the currentUrlChanged signal if the url of the current tab has been changed.
@@ -353,20 +354,13 @@ void DolphinTabWidget::tabRemoved(int index)
emit tabCountChanged(count());
}
-QString DolphinTabWidget::tabName(const QUrl& url) const
+QString DolphinTabWidget::tabName() const
{
- QString name;
- if (url == QUrl(QStringLiteral("file:///"))) {
- name = '/';
- } else {
- name = url.adjusted(QUrl::StripTrailingSlash).fileName();
- if (name.isEmpty()) {
- name = url.scheme();
- } else {
- // Make sure that a '&' inside the directory name is displayed correctly
- // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
- name.replace('&', QLatin1String("&&"));
- }
+ if (currentTabPage() == nullptr) {
+ return QString();
}
- return name;
+ QString name = currentTabPage()->activeViewContainer()->getCaption();
+ // Make sure that a '&' inside the directory name is displayed correctly
+ // and not misinterpreted as a keyboard shortcut in QTabBar::setTabText()
+ return name.replace('&', QLatin1String("&&"));
}