mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Try to download favicon.png when the download of favicon.ico fails
This was done only when favicon.ico couldn't be decoded, but not when favicon.ico could not be downloaded at all.
This commit is contained in:
parent
247ba02bb8
commit
3889b4c101
@ -467,9 +467,7 @@ void TrackerFiltersList::addItem(const QString &tracker, const QString &hash)
|
|||||||
trackerItem = new QListWidgetItem();
|
trackerItem = new QListWidgetItem();
|
||||||
trackerItem->setData(Qt::DecorationRole, GuiIconProvider::instance()->getIcon("network-server"));
|
trackerItem->setData(Qt::DecorationRole, GuiIconProvider::instance()->getIcon("network-server"));
|
||||||
|
|
||||||
Net::DownloadHandler *h = Net::DownloadManager::instance()->downloadUrl(QString("http://%1/favicon.ico").arg(host), true);
|
downloadFavicon(QString("http://%1/favicon.ico").arg(host));
|
||||||
connect(h, SIGNAL(downloadFinished(QString, QString)), this, SLOT(handleFavicoDownload(QString, QString)));
|
|
||||||
connect(h, SIGNAL(downloadFailed(QString, QString)), this, SLOT(handleFavicoFailure(QString, QString)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp.append(hash);
|
tmp.append(hash);
|
||||||
@ -610,6 +608,13 @@ void TrackerFiltersList::trackerWarning(const QString &hash, const QString &trac
|
|||||||
applyFilter(3);
|
applyFilter(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TrackerFiltersList::downloadFavicon(const QString& url)
|
||||||
|
{
|
||||||
|
Net::DownloadHandler *h = Net::DownloadManager::instance()->downloadUrl(url, true);
|
||||||
|
connect(h, SIGNAL(downloadFinished(QString, QString)), this, SLOT(handleFavicoDownload(QString, QString)));
|
||||||
|
connect(h, SIGNAL(downloadFailed(QString, QString)), this, SLOT(handleFavicoFailure(QString, QString)));
|
||||||
|
}
|
||||||
|
|
||||||
void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& filePath)
|
void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString& filePath)
|
||||||
{
|
{
|
||||||
QString host = getHost(url);
|
QString host = getHost(url);
|
||||||
@ -627,9 +632,7 @@ void TrackerFiltersList::handleFavicoDownload(const QString& url, const QString&
|
|||||||
if (url.endsWith(".ico", Qt::CaseInsensitive)) {
|
if (url.endsWith(".ico", Qt::CaseInsensitive)) {
|
||||||
Logger::instance()->addMessage(tr("Couldn't decode favicon for URL `%1`. Trying to download favicon in PNG format.").arg(url),
|
Logger::instance()->addMessage(tr("Couldn't decode favicon for URL `%1`. Trying to download favicon in PNG format.").arg(url),
|
||||||
Log::WARNING);
|
Log::WARNING);
|
||||||
Net::DownloadHandler *h = Net::DownloadManager::instance()->downloadUrl(url.left(url.size() - 4) + ".png", true);
|
downloadFavicon(url.left(url.size() - 4) + ".png");
|
||||||
connect(h, SIGNAL(downloadFinished(QString, QString)), this, SLOT(handleFavicoDownload(QString, QString)));
|
|
||||||
connect(h, SIGNAL(downloadFailed(QString, QString)), this, SLOT(handleFavicoFailure(QString, QString)));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logger::instance()->addMessage(tr("Couldn't decode favicon for URL `%1`.").arg(url), Log::WARNING);
|
Logger::instance()->addMessage(tr("Couldn't decode favicon for URL `%1`.").arg(url), Log::WARNING);
|
||||||
@ -648,6 +651,8 @@ void TrackerFiltersList::handleFavicoFailure(const QString& url, const QString&
|
|||||||
// that.
|
// that.
|
||||||
Logger::instance()->addMessage(tr("Couldn't download favicon for URL `%1`. Reason: `%2`").arg(url).arg(error),
|
Logger::instance()->addMessage(tr("Couldn't download favicon for URL `%1`. Reason: `%2`").arg(url).arg(error),
|
||||||
Log::WARNING);
|
Log::WARNING);
|
||||||
|
if (url.endsWith(".ico", Qt::CaseInsensitive))
|
||||||
|
downloadFavicon(url.left(url.size() - 4) + ".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrackerFiltersList::showMenu(QPoint)
|
void TrackerFiltersList::showMenu(QPoint)
|
||||||
|
@ -157,6 +157,7 @@ private:
|
|||||||
int rowFromTracker(const QString &tracker) const;
|
int rowFromTracker(const QString &tracker) const;
|
||||||
QString getHost(const QString &trakcer) const;
|
QString getHost(const QString &trakcer) const;
|
||||||
QStringList getHashes(int row);
|
QStringList getHashes(int row);
|
||||||
|
void downloadFavicon(const QString &url);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QString, QStringList> m_trackers;
|
QHash<QString, QStringList> m_trackers;
|
||||||
|
Loading…
Reference in New Issue
Block a user