Commit 78f86dfb authored by Stefano Crocco's avatar Stefano Crocco Committed by David Faure
Browse files

Only use favicons for http(s) bookmarks

parent 3fa0a699
......@@ -175,9 +175,9 @@ void KBookmarkBar::fillBookmarkBar(const KBookmarkGroup &parent)
m_toolBar->addAction(action);
}
d->m_actions.append(action);
connect(KonqPixmapProvider::self(), &KonqPixmapProvider::changed, action, [host, action]() {
action->setIcon(KonqPixmapProvider::self()->iconForUrl(host));
});
connect(KonqPixmapProvider::self(), &KonqPixmapProvider::changed, action, [host, action]() {
action->setIcon(KonqPixmapProvider::self()->iconForUrl(host));
});
KonqPixmapProvider::self()->downloadHostIcon(host);
}
} else {
......
......@@ -249,11 +249,11 @@ QAction *KonqBookmarkMenu::actionForBookmark(const KBookmark &_bm)
} else {
// qCDebug(KBOOKMARKS_LOG) << "Creating Konq bookmark action named " << bm.text();
QUrl host = bm.url().adjusted(QUrl::RemovePath | QUrl::RemoveQuery);
bm.setIcon(KonqPixmapProvider::self()->iconNameFor(host));
bm.setIcon(KonqPixmapProvider::self()->iconNameFor(host));
KBookmarkAction *action = new KBookmarkAction(bm, owner(), this);
connect(KonqPixmapProvider::self(), &KonqPixmapProvider::changed, action, [host, action]() {
action->setIcon(KonqPixmapProvider::self()->iconForUrl(host));
});
connect(KonqPixmapProvider::self(), &KonqPixmapProvider::changed, action, [host, action]() {
action->setIcon(KonqPixmapProvider::self()->iconForUrl(host));
});
KonqPixmapProvider::self()->downloadHostIcon(host);
m_actionCollection->addAction(action->objectName(), action);
m_actions.append(action);
......
......@@ -40,6 +40,10 @@ KonqPixmapProvider::~KonqPixmapProvider()
void KonqPixmapProvider::downloadHostIcon(const QUrl &hostUrl)
{
//Only attempt to download icon for http(s) URLs
if (!hostUrl.scheme().startsWith(QLatin1String("http"))) {
return;
}
KIO::FavIconRequestJob *job = new KIO::FavIconRequestJob(hostUrl);
connect(job, &KIO::FavIconRequestJob::result, this, [job, this](KJob *) {
bool modified = false;
......
......@@ -584,8 +584,8 @@ void KonqView::slotCompleted(bool hasPending)
if (!m_bGotIconURL && !m_bAborted) {
if (KonqSettings::enableFavicon() == true) {
// Try to get /favicon.ico
if (supportsMimeType(QStringLiteral("text/html")) && url().scheme().startsWith(QLatin1String("http"))) {
// Try to get /favicon.ico. KonqPixmapProvider::downloadHostIcon does nothing if the URL is not http(s)
if (supportsMimeType(QStringLiteral("text/html"))) {
KonqPixmapProvider::self()->downloadHostIcon(url());
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment