Utils: Make remote image loading optional

Change-Id: Ib90c9b8bb54e0c56da322d4034894f2e34d802c9
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-10-16 09:19:28 +02:00
parent 7c23409e2a
commit e78a193513
3 changed files with 12 additions and 0 deletions

View File

@@ -291,6 +291,9 @@ public:
if (m_basePath.isEmpty())
localUrls.clear();
if (!m_loadRemoteImages)
remoteUrls.clear();
const LoopList remoteIterator(remoteUrls);
const LoopList localIterator(localUrls);
@@ -360,11 +363,13 @@ public:
}
void setBasePath(const FilePath &filePath) { m_basePath = filePath; }
void setAllowRemoteImages(bool allow) { m_loadRemoteImages = allow; }
private:
AnimatedImageHandler m_imageHandler;
QList<QUrl> m_urlsToLoad;
bool m_needsToRestartLoading = false;
bool m_loadRemoteImages = false;
Tasking::TaskTreeRunner m_imageLoaderTree;
FilePath m_basePath;
};
@@ -375,6 +380,11 @@ MarkdownBrowser::MarkdownBrowser(QWidget *parent)
setDocument(new AnimatedDocument(this));
}
void MarkdownBrowser::setAllowRemoteImages(bool allow)
{
static_cast<AnimatedDocument *>(document())->setAllowRemoteImages(allow);
}
void MarkdownBrowser::setBasePath(const FilePath &filePath)
{
static_cast<AnimatedDocument *>(document())->setBasePath(filePath);

View File

@@ -20,6 +20,7 @@ public:
void setMarkdown(const QString &markdown);
void setBasePath(const FilePath &filePath);
void setAllowRemoteImages(bool allow);
};
} // namespace Utils

View File

@@ -442,6 +442,7 @@ ExtensionManagerWidget::ExtensionManagerWidget()
m_headingWidget = new HeadingWidget;
m_description = new MarkdownBrowser;
m_description->setAllowRemoteImages(true);
m_description->setFrameStyle(QFrame::NoFrame);
m_description->setOpenExternalLinks(true);
QPalette browserPal = m_description->palette();