Browse Source

Merge pull request #6871 from KingLucius/googlefavicon

Fetch Favicons via google
adaptive-webui-19844
sledgehammer999 8 years ago committed by GitHub
parent
commit
34c7465009
  1. 13
      src/gui/transferlistfilterswidget.cpp

13
src/gui/transferlistfilterswidget.cpp

@ -57,6 +57,8 @@
#include "transferlistdelegate.h" #include "transferlistdelegate.h"
#include "transferlistwidget.h" #include "transferlistwidget.h"
const QLatin1String GOOGLE_FAVICON_URL("https://www.google.com/s2/favicons?domain=");
FiltersBase::FiltersBase(QWidget *parent, TransferListWidget *transferList) FiltersBase::FiltersBase(QWidget *parent, TransferListWidget *transferList)
: QListWidget(parent) : QListWidget(parent)
, transferList(transferList) , transferList(transferList)
@ -393,7 +395,10 @@ void TrackerFiltersList::downloadFavicon(const QString& url)
void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& filePath) void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& filePath)
{ {
QString host = getHost(url); QString host = url.startsWith(GOOGLE_FAVICON_URL)
? url.mid(GOOGLE_FAVICON_URL.size())
: getHost(url);
if (!m_trackers.contains(host)) { if (!m_trackers.contains(host)) {
Utils::Fs::forceRemove(filePath); Utils::Fs::forceRemove(filePath);
return; return;
@ -420,8 +425,12 @@ void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString&
void TrackerFiltersList::handleFavicoFailure(const QString& url, const QString& error) void TrackerFiltersList::handleFavicoFailure(const QString& url, const QString& error)
{ {
Q_UNUSED(error) Q_UNUSED(error)
if (url.endsWith(".ico", Qt::CaseInsensitive)) if (url.endsWith(".ico", Qt::CaseInsensitive)) {
downloadFavicon(url.left(url.size() - 4) + ".png"); downloadFavicon(url.left(url.size() - 4) + ".png");
}
else if (!url.startsWith(GOOGLE_FAVICON_URL)) {
downloadFavicon(GOOGLE_FAVICON_URL + getHost(url));
}
} }
void TrackerFiltersList::showMenu(QPoint) void TrackerFiltersList::showMenu(QPoint)

Loading…
Cancel
Save