Commit 8a5ef4d0 authored by David Faure's avatar David Faure

Add support again for man:, info: and other slaves which output HTML.

using the newly added support for streaming data into WebEnginePart.

BUG: 377084
parent a1691b2f
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <kjobuidelegate.h> #include <kjobuidelegate.h>
#include <KUrlMimeData> #include <KUrlMimeData>
#include <KComponentData> #include <KComponentData>
#include <KProtocolManager>
#include <QApplication> #include <QApplication>
#include <QtCore/QArgument> #include <QtCore/QArgument>
...@@ -839,6 +840,15 @@ void KonqView::doOpenUrl(const QUrl &url) ...@@ -839,6 +840,15 @@ void KonqView::doOpenUrl(const QUrl &url)
} else { } else {
qWarning() << m_pPart->metaObject()->className() << "doesn't support openStream()!"; qWarning() << m_pPart->metaObject()->className() << "doesn't support openStream()!";
} }
} else if (KProtocolManager::defaultMimetype(url) == "text/html") { // man:, info:, etc.
if (m_pPart->openStream("text/html", url)) {
KIO::TransferJob *job = KIO::get(url, KIO::NoReload, KIO::HideProgressInfo);
connect(job, &KIO::TransferJob::data, this, [this](KIO::Job *, const QByteArray &data) {
m_pPart->writeStream(data);
});
connect(job, &KIO::Job::result, this, [this]() { m_pPart->closeStream(); });
connect(m_pPart, &KParts::ReadOnlyPart::canceled, job, [job]() { job->kill(); });
}
} else { } else {
m_pPart->openUrl(url); m_pPart->openUrl(url);
} }
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <KIO/AccessManager> #include <KIO/AccessManager>
#include <KIO/Scheduler> #include <KIO/Scheduler>
#include <KParts/HtmlExtension> #include <KParts/HtmlExtension>
#include <KProtocolManager>
#include <KUserTimestamp> #include <KUserTimestamp>
#include <kio_version.h> #include <kio_version.h>
#if KIO_VERSION >= QT_VERSION_CHECK(5, 30, 0) #if KIO_VERSION >= QT_VERSION_CHECK(5, 30, 0)
...@@ -64,7 +65,6 @@ ...@@ -64,7 +65,6 @@
//#include <QWebSecurityOrigin> //#include <QWebSecurityOrigin>
#include "utils.h" #include "utils.h"
WebEnginePage::WebEnginePage(WebEnginePart *part, QWidget *parent) WebEnginePage::WebEnginePage(WebEnginePart *part, QWidget *parent)
: QWebEnginePage(parent), : QWebEnginePage(parent),
m_kioErrorCode(0), m_kioErrorCode(0),
...@@ -188,6 +188,11 @@ bool WebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType type ...@@ -188,6 +188,11 @@ bool WebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType type
if (handleMailToUrl(reqUrl, type)) if (handleMailToUrl(reqUrl, type))
return false; return false;
if (KProtocolManager::defaultMimetype(url) == "text/html") { // man:, info:, etc.
emit m_part->browserExtension()->openUrlRequest(url, KParts::OpenUrlArguments(), KParts::BrowserArguments());
return false;
}
const bool isTypedUrl = property("NavigationTypeUrlEntered").toBool(); const bool isTypedUrl = property("NavigationTypeUrlEntered").toBool();
/* /*
...@@ -257,8 +262,8 @@ bool WebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType type ...@@ -257,8 +262,8 @@ bool WebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType type
// Honor the enabling/disabling of plugins per host. // Honor the enabling/disabling of plugins per host.
settings()->setAttribute(QWebEngineSettings::PluginsEnabled, WebEngineSettings::self()->isPluginsEnabled(reqUrl.host())); settings()->setAttribute(QWebEngineSettings::PluginsEnabled, WebEngineSettings::self()->isPluginsEnabled(reqUrl.host()));
// Insert the request into the queue...
return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame); return true;
} }
#if 0 #if 0
......
...@@ -326,9 +326,12 @@ void WebEnginePart::connectWebEnginePageSignals(WebEnginePage* page) ...@@ -326,9 +326,12 @@ void WebEnginePart::connectWebEnginePageSignals(WebEnginePage* page)
bool WebEnginePart::openUrl(const QUrl &_u) bool WebEnginePart::openUrl(const QUrl &_u)
{ {
QUrl u (_u); QUrl u(_u);
qDebug() << u; if (u.scheme() == QL1S("data"))
qDebug() << "data:[...]";
else
qDebug() << u;
// Ignore empty requests... // Ignore empty requests...
if (u.isEmpty()) if (u.isEmpty())
......
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