Browse Source

Fix for Qt 5

chirpmodem-v8.0.0
Jon Beniston 1 month ago
parent
commit
67e08ea70c
  1. 19
      plugins/channelrx/demoddrm/drmwebsitebrowser.cpp
  2. 11
      plugins/channelrx/demoddrm/drmwebsitebrowser.h

19
plugins/channelrx/demoddrm/drmwebsitebrowser.cpp

@ -157,6 +157,9 @@ void DRMWebsiteBrowser::setWebsite(std::shared_ptr<const modemdrm::MOTWebsite> w @@ -157,6 +157,9 @@ void DRMWebsiteBrowser::setWebsite(std::shared_ptr<const modemdrm::MOTWebsite> 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) @@ -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 @@ -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();
}

11
plugins/channelrx/demoddrm/drmwebsitebrowser.h

@ -68,14 +68,23 @@ public: @@ -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: @@ -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

Loading…
Cancel
Save