diff --git a/plugins/channelrx/demoddrm/drmwebsitebrowser.cpp b/plugins/channelrx/demoddrm/drmwebsitebrowser.cpp index 9f4710ecf..6ad089847 100644 --- a/plugins/channelrx/demoddrm/drmwebsitebrowser.cpp +++ b/plugins/channelrx/demoddrm/drmwebsitebrowser.cpp @@ -157,6 +157,9 @@ void DRMWebsiteBrowser::setWebsite(std::shared_ptr w { const int scroll = verticalScrollBar()->value(); reload(); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + pageShown(); // Qt 5's reload does not reach setSource(const QUrl&) +#endif verticalScrollBar()->setValue(scroll); } } @@ -426,7 +429,19 @@ QVariant DRMWebsiteBrowser::loadResource(int type, const QUrl& name) return QString(QLatin1Char(' ')); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) void DRMWebsiteBrowser::doSetSource(const QUrl& name, QTextDocument::ResourceType type) +{ + showSource(name, type); +} +#else +void DRMWebsiteBrowser::setSource(const QUrl& name) +{ + showSource(name, QTextDocument::UnknownResource); +} +#endif + +void DRMWebsiteBrowser::showSource(const QUrl& name, QTextDocument::ResourceType type) { const QUrl url = resolved(name); @@ -446,7 +461,11 @@ void DRMWebsiteBrowser::doSetSource(const QUrl& name, QTextDocument::ResourceTyp } m_page = page; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QTextBrowser::doSetSource(page, type); +#else + QTextBrowser::setSource(page, type); +#endif pageShown(); } diff --git a/plugins/channelrx/demoddrm/drmwebsitebrowser.h b/plugins/channelrx/demoddrm/drmwebsitebrowser.h index cf0d7447a..104fde581 100644 --- a/plugins/channelrx/demoddrm/drmwebsitebrowser.h +++ b/plugins/channelrx/demoddrm/drmwebsitebrowser.h @@ -68,14 +68,23 @@ public: // Colours written as bare hex digits (bgcolor=0088b8), which web browsers // accept and Qt does not, with their "#"; only within tags. static QByteArray fixColours(const QByteArray& html); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + using QTextBrowser::setSource; +#endif public slots: void backward() override; void forward() override; void home() override; +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + // Qt 5's hook for a new source (its doSetSource is not virtual) + void setSource(const QUrl& name) override; +#endif protected: +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) void doSetSource(const QUrl& name, QTextDocument::ResourceType type) override; +#endif // A title attribute's tooltip would be shown as rich text outside the // browser, where Qt reads images as local files: no tooltips bool event(QEvent *event) override; @@ -102,6 +111,8 @@ private: static QString htmlText(const QByteArray& html); // The image handler on the document's layout, whatever Qt registered void useImageHandler(); + // A new source: the website's own URL for it, shown + void showSource(const QUrl& name, QTextDocument::ResourceType type); // After a page is shown (a link, a reload or the history): its URL, and its // images loaded now (Qt loads them as it paints) so that every file it uses // is known even while the tab is hidden