From cc8a62ff160c0619b09fe7827c6fd6f38e023866 Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Tue, 5 May 2009 21:49:03 +0000 Subject: [PATCH] Don't show an empty window caption when browsing "/", "trash:", etc. BUG: 190783 svn path=/trunk/KDE/kdebase/apps/; revision=964061 --- src/dolphinmainwindow.cpp | 21 ++++++++++++++++++--- src/dolphinmainwindow.h | 6 ++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 64aba63a55..3ce1e9f2d8 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -236,7 +236,7 @@ void DolphinMainWindow::changeUrl(const KUrl& url) updateEditActions(); updateViewActions(); updateGoActions(); - setCaption(url.fileName()); + setUrlAsCaption(url); if (m_viewTab.count() > 1) { m_tabBar->setTabText(m_tabIndex, tabName(url)); } @@ -987,7 +987,7 @@ void DolphinMainWindow::init() setupActions(); const KUrl& homeUrl = generalSettings->homeUrl(); - setCaption(homeUrl.fileName()); + setUrlAsCaption(homeUrl); m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar())); connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory())); @@ -1096,7 +1096,7 @@ void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContain updateGoActions(); const KUrl& url = m_activeViewContainer->url(); - setCaption(url.fileName()); + setUrlAsCaption(url); if (m_viewTab.count() > 1 && m_viewTab[m_tabIndex].secondaryView != 0) { m_tabBar->setTabText(m_tabIndex, tabName(url)); m_tabBar->setTabIcon(m_tabIndex, KIcon(KMimeType::iconNameForUrl(url))); @@ -1555,6 +1555,21 @@ QString DolphinMainWindow::tabProperty(const QString& property, int tabIndex) co return "Tab " + QString::number(tabIndex) + ' ' + property; } +void DolphinMainWindow::setUrlAsCaption(const KUrl& url) +{ + QString caption; + if (url.equals(KUrl("file:///"))) { + caption = '/'; + } else { + caption = url.fileName(); + if (caption.isEmpty()) { + caption = url.protocol(); + } + } + + setCaption(caption); +} + DolphinMainWindow::UndoUiInterface::UndoUiInterface() : KIO::FileUndoManager::UiInterface() { diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 5e1d27476b..c1e0ffcbdc 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -435,6 +435,12 @@ private: */ QString tabProperty(const QString& property, int tabIndex) const; + /** + * Sets the window caption to url.fileName() if this is non-empty, + * "/" if the URL is "file:///", and url.protocol() otherwise. + */ + void setUrlAsCaption(const KUrl& url); + private: /** * Implements a custom error handling for the undo manager. This