better placeholder icon

This commit is contained in:
Martin Rotter 2022-04-22 20:51:13 +02:00
parent 8adf3061fe
commit 3360ca8d6e
3 changed files with 7 additions and 3 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@ -443,7 +443,9 @@ void TextBrowserViewer::setHtmlPrivate(const QString& html, const QUrl& base_url
emit pageUrlChanged(base_url);
}
TextBrowserDocument::TextBrowserDocument(QObject* parent) : QTextDocument(parent), m_reloadingWithResources(false) {}
TextBrowserDocument::TextBrowserDocument(QObject* parent)
: QTextDocument(parent), m_reloadingWithResources(false),
m_placeholderImage(qApp->icons()->miscPixmap("image-placeholder")) {}
QVariant TextBrowserDocument::loadResource(int type, const QUrl& name) {
if (!m_reloadingWithResources) {
@ -451,12 +453,12 @@ QVariant TextBrowserDocument::loadResource(int type, const QUrl& name) {
m_neededResourcesForHtml.append(name);
}
return {};
return m_placeholderImage;
}
else if (m_loadedResources.contains(name)) {
return QImage::fromData(m_loadedResources.value(name));
}
else {
return {};
return m_placeholderImage;
}
}

View File

@ -9,6 +9,7 @@
#include "network-web/adblock/adblockmanager.h"
#include <QPixmap>
#include <QPointer>
class QContextMenuEvent;
@ -31,6 +32,7 @@ class TextBrowserDocument : public QTextDocument {
bool m_reloadingWithResources;
QList<QUrl> m_neededResourcesForHtml;
QMap<QUrl, QByteArray> m_loadedResources;
QPixmap m_placeholderImage;
};
class TextBrowserViewer : public QTextBrowser, public WebViewer {