From: Peter Penz Date: Wed, 24 Nov 2010 16:03:10 +0000 (+0000) Subject: Assure that the "From Here (...)" button contains always a useful content also for... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/cbbadab33a25c9748eb61710fd161b1eb4bfb3c1?ds=inline Assure that the "From Here (...)" button contains always a useful content also for non-local URLs svn path=/trunk/KDE/kdebase/apps/; revision=1200307 --- diff --git a/src/search/dolphinsearchbox.cpp b/src/search/dolphinsearchbox.cpp index 7c2d15264..b265ea99a 100644 --- a/src/search/dolphinsearchbox.cpp +++ b/src/search/dolphinsearchbox.cpp @@ -82,8 +82,18 @@ void DolphinSearchBox::setSearchPath(const KUrl& url) QFontMetrics metrics(m_fromHereButton->font()); const int maxWidth = metrics.averageCharWidth() * 15; - const QString fileName = metrics.elidedText(url.fileName(), Qt::ElideMiddle, maxWidth); - m_fromHereButton->setText(i18nc("action:button", "From Here (%1)", fileName)); + + QString location = url.fileName(); + if (location.isEmpty()) { + if (url.isLocalFile()) { + location = QLatin1String("/"); + } else { + location = url.protocol() + QLatin1String(" - ") + url.host(); + } + } + + const QString elidedLocation = metrics.elidedText(location, Qt::ElideMiddle, maxWidth); + m_fromHereButton->setText(i18nc("action:button", "From Here (%1)", elidedLocation)); } KUrl DolphinSearchBox::searchPath() const