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 @@
#include <kjobuidelegate.h>
#include <KUrlMimeData>
#include <KComponentData>
#include <KProtocolManager>
#include <QApplication>
#include <QtCore/QArgument>
......@@ -839,6 +840,15 @@ void KonqView::doOpenUrl(const QUrl &url)
} else {
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 {
m_pPart->openUrl(url);
}
......
......@@ -42,6 +42,7 @@
#include <KIO/AccessManager>
#include <KIO/Scheduler>
#include <KParts/HtmlExtension>
#include <KProtocolManager>
#include <KUserTimestamp>
#include <kio_version.h>
#if KIO_VERSION >= QT_VERSION_CHECK(5, 30, 0)
......@@ -64,7 +65,6 @@
//#include <QWebSecurityOrigin>
#include "utils.h"
WebEnginePage::WebEnginePage(WebEnginePart *part, QWidget *parent)
: QWebEnginePage(parent),
m_kioErrorCode(0),
......@@ -188,6 +188,11 @@ bool WebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType type
if (handleMailToUrl(reqUrl, type))
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();
/*
......@@ -257,8 +262,8 @@ bool WebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType type
// Honor the enabling/disabling of plugins per 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
......
......@@ -326,8 +326,11 @@ void WebEnginePart::connectWebEnginePageSignals(WebEnginePage* page)
bool WebEnginePart::openUrl(const QUrl &_u)
{
QUrl u (_u);
QUrl u(_u);
if (u.scheme() == QL1S("data"))
qDebug() << "data:[...]";
else
qDebug() << u;
// Ignore empty requests...
......
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