Commit 7494996c authored by David Faure's avatar David Faure
Browse files

Akregator: fix URL/path confusion which led to KIO warnings and possibly missing icons

Summary:
The faviconUrl stored in ~/.local/share/akregator/data was a path rather
than a URL.

It's also pretty pointless to then do a download job on that local file...

Test Plan:
I've been having some trouble finding RSS sites with icons...
Please double-check.

Reviewers: mlaurent

Differential Revision: https://phabricator.kde.org/D28581
parent a7d36991
...@@ -376,14 +376,18 @@ void Feed::loadFavicon(const QString &url, bool downloadFavicon) ...@@ -376,14 +376,18 @@ void Feed::loadFavicon(const QString &url, bool downloadFavicon)
if (u.scheme().isEmpty()) { if (u.scheme().isEmpty()) {
qCWarning(AKREGATOR_LOG) << "Invalid url" << url; qCWarning(AKREGATOR_LOG) << "Invalid url" << url;
} }
Akregator::DownloadFeedIconJob *job = new Akregator::DownloadFeedIconJob(this); if (u.isLocalFile()) {
job->setFeedIconUrl(u); setFaviconLocalPath(u.toLocalFile());
job->setDownloadFavicon(downloadFavicon); } else {
connect(job, &DownloadFeedIconJob::result, this, [this](const QString &result) { Akregator::DownloadFeedIconJob *job = new Akregator::DownloadFeedIconJob(this);
setFaviconUrl(result); job->setFeedIconUrl(u);
}); job->setDownloadFavicon(downloadFavicon);
if (!job->start()) { connect(job, &DownloadFeedIconJob::result, this, [this](const QString &fileName) {
qCWarning(AKREGATOR_LOG) << "Impossible to start DownloadFeedIconJob for url: " << url; setFaviconLocalPath(fileName);
});
if (!job->start()) {
qCWarning(AKREGATOR_LOG) << "Impossible to start DownloadFeedIconJob for url: " << url;
}
} }
} }
...@@ -505,16 +509,19 @@ Feed::ImageInfo Feed::faviconInfo() const ...@@ -505,16 +509,19 @@ Feed::ImageInfo Feed::faviconInfo() const
return d->m_faviconInfo; return d->m_faviconInfo;
} }
void Feed::setFaviconUrl(const QString &url) void Feed::setFaviconLocalPath(const QString &localPath)
{ {
d->m_faviconInfo.imageUrl = url; d->m_faviconInfo.imageUrl = QUrl::fromLocalFile(localPath).toString();
setFavicon(QIcon(d->m_faviconInfo.imageUrl)); setFavicon(QIcon(localPath));
} }
void Feed::setFaviconInfo(const Feed::ImageInfo &info) void Feed::setFaviconInfo(const Feed::ImageInfo &info)
{ {
d->m_faviconInfo = info; d->m_faviconInfo = info;
setFavicon(QIcon(info.imageUrl)); QUrl u(info.imageUrl);
if (u.isLocalFile()) {
setFavicon(QIcon(u.toLocalFile()));
}
} }
QString Feed::description() const QString Feed::description() const
......
...@@ -230,7 +230,7 @@ public: ...@@ -230,7 +230,7 @@ public:
Q_REQUIRED_RESULT QString comment() const; Q_REQUIRED_RESULT QString comment() const;
void setComment(const QString &comment); void setComment(const QString &comment);
void setFaviconUrl(const QString &url); void setFaviconLocalPath(const QString &file);
void setCopyright(const QString &copyright); void setCopyright(const QString &copyright);
Q_REQUIRED_RESULT QString copyright() const; Q_REQUIRED_RESULT QString copyright() const;
public Q_SLOTS: public Q_SLOTS:
......
Markdown is supported
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