Commit a1691b2f authored by David Faure's avatar David Faure

Make the "about" protocol configurable to attempt working around QtWebEngine issues.

parent 5af022a8
......@@ -14,6 +14,7 @@ endif (KActivities_FOUND)
########### libkonquerorprivate, shared with unit tests and sidebar modules ###############
set(konquerorprivate_SRCS
konqaboutpage.cpp
konqhistorymanager.cpp # for unit tests
konqpixmapprovider.cpp # needed ?!?
......@@ -47,7 +48,6 @@ generate_export_header(konquerorprivate BASE_NAME konquerorprivate EXPORT_FILE_N
########### konqueror ###############
set(konqueror_KDEINIT_SRCS
konqaboutpage.cpp
konqapplication.cpp
konqguiclients.cpp
konqrun.cpp
......
......@@ -37,15 +37,20 @@ KonqAboutPage::~KonqAboutPage()
{
}
QString KonqAboutPage::pageForUrl(const QString &url) const
QString KonqAboutPage::aboutProtocol()
{
if (url == QLatin1String("about:plugins")) {
return QStringLiteral("about");
}
QString KonqAboutPage::pageContents(const QString &path) const
{
if (path == QLatin1String("plugins")) {
return plugins();
} else if (url == QLatin1String("about:konqueror/intro")) {
} else if (path == QLatin1String("konqueror/intro")) {
return intro();
} else if (url == QLatin1String("about:konqueror/specs")) {
} else if (path == QLatin1String("konqueror/specs")) {
return specs();
} else if (url == QLatin1String("about:konqueror/tips")) {
} else if (path == QLatin1String("konqueror/tips")) {
return tips();
} else {
return launch();
......@@ -222,7 +227,7 @@ QString KonqAboutPage::specs() const
.arg(i18n("Enable Java (globally) <A HREF=\"%1\">here</A>.", QStringLiteral("exec:/kcmshell5 khtml_java_js"))) // TODO Maybe test if Java is enabled ?
.arg(i18n("NPAPI <A HREF=\"%2\">plugins</A> (for viewing <A HREF=\"%1\">Flash<SUP>&reg;</SUP></A>, etc.)",
QStringLiteral("https://get.adobe.com/flashplayer/"),
QStringLiteral("about:plugins")))
aboutProtocol() + QStringLiteral(":plugins")))
.arg(i18n("built-in"))
.arg(i18n("Secure Sockets Layer"))
.arg(i18n("(TLS/SSL v2/3) for secure communications up to 168bit"))
......@@ -245,7 +250,7 @@ QString KonqAboutPage::specs() const
.arg(i18n("Popup"))
.arg(i18n("(Short-) Automatic"))
.arg(QStringLiteral("<img width='16' height='16' src=\"%1\">")).arg(continue_icon_path)
.arg(i18nc("Link that points to the first page of the Konqueror 'about page', Starting Points contains links to Home, Network Folders, Trash, etc.", "<a href=\"%1\">Return to Starting Points</a>", QStringLiteral("about:konqueror")))
.arg(i18nc("Link that points to the first page of the Konqueror 'about page', Starting Points contains links to Home, Network Folders, Trash, etc.", "<a href=\"%1\">Return to Starting Points</a>", aboutProtocol() + QStringLiteral(":konqueror")))
;
return res;
}
......
......@@ -20,17 +20,20 @@
#ifndef KONQ_ABOUTPAGE_H
#define KONQ_ABOUTPAGE_H
#include <konqprivate_export.h>
#include <QString>
class QUrl;
class KonqAboutPage
class KONQUERORPRIVATE_EXPORT KonqAboutPage
{
public:
KonqAboutPage();
~KonqAboutPage();
QString pageForUrl(const QString &url) const;
static QString aboutProtocol();
QString pageContents(const QString &path) const;
private:
QString launch() const;
......
......@@ -20,6 +20,7 @@
#include "konqhistorymanager.h"
#include <kbookmarkmanager.h>
#include "konqaboutpage.h"
#include <QtDBus/QtDBus>
#include <QTimer>
......@@ -156,7 +157,7 @@ void KonqHistoryManager::addToHistory(bool pending, const QUrl &_url,
void KonqHistoryManager::insert(const QString &url)
{
QUrl u(url);
if (!filterOut(u) || u.scheme() == QLatin1String("about")) { // remote URL
if (!filterOut(u) || u.scheme() == KonqAboutPage::aboutProtocol()) { // remote URL
return;
}
// Local URL -> add to history
......
......@@ -49,6 +49,7 @@
#include "konqbookmarkbar.h"
#include "konqundomanager.h"
#include "konqhistorydialog.h"
#include "konqaboutpage.h"
#include <config-konqueror.h>
#include <kstringhandler.h>
......@@ -514,7 +515,7 @@ void KonqMainWindow::openUrl(KonqView *_view, const QUrl &_url,
mimeType = req.args.mimeType();
}
if (url.scheme() != QLatin1String("error") && url.scheme() != QLatin1String("about")) {
if (url.scheme() != QLatin1String("error") && url.scheme() != KonqAboutPage::aboutProtocol()) {
if (!url.isValid()) {
// I think we can't really get here anymore; I tried and didn't succeed.
// URL filtering catches this case before hand, and in cases without filtering
......@@ -526,7 +527,7 @@ void KonqMainWindow::openUrl(KonqView *_view, const QUrl &_url,
}
}
if (url.scheme() == QLatin1String("about") || url.scheme() == QLatin1String("error")) {
if (url.scheme() == KonqAboutPage::aboutProtocol() || url.scheme() == QLatin1String("error")) {
mimeType = QStringLiteral("text/html");
}
......@@ -800,19 +801,18 @@ bool KonqMainWindow::openView(QString mimeType, const QUrl &_url, KonqView *chil
originalURL += req.nameFilter;
}
const QString urlStr = url.url();
if (urlStr == QLatin1String("about:") || urlStr.startsWith(QLatin1String("about:konqueror")) || urlStr == QLatin1String("about:plugins")) {
if (url.toString() == QLatin1String("about:blank") && req.typedUrl.isEmpty()) {
originalURL.clear();
} else if (url.scheme() == KonqAboutPage::aboutProtocol()) {
mimeType = QStringLiteral("text/html");
originalURL = req.typedUrl.isEmpty() ? QString() : req.typedUrl;
} else if (urlStr == QLatin1String("about:blank") && req.typedUrl.isEmpty()) {
originalURL.clear();
}
bool forceAutoEmbed = req.forceAutoEmbed || req.userRequestedReload;
if (!req.typedUrl.isEmpty()) { // the user _typed_ the URL, he wants it in Konq.
forceAutoEmbed = true;
}
if (url.scheme() == QLatin1String("about") || url.scheme() == QLatin1String("error")) {
if (url.scheme() == KonqAboutPage::aboutProtocol() || url.scheme() == QLatin1String("error")) {
forceAutoEmbed = true;
}
// Related to KonqFactory::createView
......@@ -958,7 +958,7 @@ void KonqMainWindow::slotOpenURLRequest(const QUrl &url, const KParts::OpenUrlAr
KParts::ReadOnlyPart *callingPart = static_cast<KParts::ReadOnlyPart *>(sender()->parent());
//qDebug() << url << "from" << callingPart->url() << "frameName=" << browserArgs.frameName;
if (callingPart->url().scheme() == "about" && url.scheme() == "exec") {
if (callingPart->url().scheme() == KonqAboutPage::aboutProtocol() && url.scheme() == "exec") {
QStringList execArgs = url.path().mid(1).split(QChar(' '), QString::SkipEmptyParts);
const QString executable = execArgs.takeFirst();
if (executable == "khelpcenter" || executable.startsWith("kcmshell")) {
......@@ -5017,7 +5017,7 @@ void KonqMainWindow::updateWindowIcon()
void KonqMainWindow::slotIntro()
{
openUrl(0, QUrl(QStringLiteral("about:")));
openUrl(0, QUrl(KonqAboutPage::aboutProtocol() + QChar(':')));
}
void KonqMainWindow::goURL()
......
......@@ -23,6 +23,7 @@
#include "konqviewmanager.h"
#include "konqview.h"
#include "konqmainwindowfactory.h"
#include "konqaboutpage.h"
#include <QDebug>
#include <kurifilter.h>
......@@ -70,7 +71,7 @@ QUrl KonqMisc::konqFilteredURL(KonqMainWindow *parent, const QString &_url, cons
{
Q_UNUSED(parent); // Useful if we want to change the error handling again
if (!_url.startsWith(QLatin1String("about:"))) { // Don't filter "about:" URLs
if (!_url.startsWith(KonqAboutPage::aboutProtocol() + QLatin1Char(':'))) { // Don't filter "about:" URLs
KUriFilterData data(_url);
if (currentDirectory.isLocalFile()) {
......@@ -98,11 +99,7 @@ QUrl KonqMisc::konqFilteredURL(KonqMainWindow *parent, const QString &_url, cons
return KParts::BrowserRun::makeErrorUrl(KIO::ERR_MALFORMED_URL, _url, QUrl(_url));
}
const bool isKnownAbout = (_url == QLatin1String("about:blank")
|| _url == QLatin1String("about:plugins")
|| _url.startsWith(QLatin1String("about:konqueror")));
return isKnownAbout ? QUrl(_url) : QUrl(QStringLiteral("about:"));
return QUrl(_url);
}
QString KonqMisc::encodeFilename(QString filename)
......@@ -114,4 +111,3 @@ QString KonqMisc::decodeFilename(QString filename)
{
return filename.replace('_', ':');
}
......@@ -3,11 +3,12 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<include>konqaboutpage.h</include>
<kcfgfile name="konquerorrc" />
<group name="UserSettings">
<entry key="StartURL" type="Path">
<default>about:konqueror</default>
<default code="true">KonqAboutPage::aboutProtocol() + ":konqueror"</default>
<label>Start Page</label>
<whatsthis>This is the URL of the web page where Konqueror will start from.</whatsthis>
</entry>
......
......@@ -829,9 +829,9 @@ void KonqView::go(int steps)
void KonqView::doOpenUrl(const QUrl &url)
{
qDebug() << url;
if (url.scheme() == QLatin1String("about")) {
if (url.scheme() == KonqAboutPage::aboutProtocol()) {
KonqAboutPage about;
const QByteArray data = about.pageForUrl(url.toString()).toUtf8();
const QByteArray data = about.pageContents(url.path()).toUtf8();
//QFile hack("/tmp/about.html"); hack.open(QIODevice::WriteOnly); hack.write(data); hack.close();
if (m_pPart->openStream("text/html", url)) {
m_pPart->writeStream(data);
......@@ -865,7 +865,7 @@ void KonqView::restoreHistory()
aboutToOpenURL(h.url);
if (h.reload == false && browserExtension() && h.url.scheme() != "about") {
if (h.reload == false && browserExtension() && h.url.scheme() != KonqAboutPage::aboutProtocol()) {
//qDebug() << "Restoring view from stream";
QDataStream stream(h.buffer);
......
......@@ -28,6 +28,7 @@
#include "konqtabs.h"
#include "konqsettingsxt.h"
#include "konqframevisitor.h"
#include "konqaboutpage.h"
#include <konq_events.h>
#include <QtCore/QFileInfo>
......@@ -1133,7 +1134,7 @@ void KonqViewManager::loadItem(const KConfigGroup &cfg, KonqFrameContainerBase *
serviceType = cfg.readEntry(QStringLiteral("ServiceType").prepend(prefix), QStringLiteral("inode/directory"));
serviceName = cfg.readEntry(QStringLiteral("ServiceName").prepend(prefix), QString());
if (serviceName == QLatin1String("konq_aboutpage")) {
if ((!forcedUrl.isEmpty() && forcedUrl.scheme() != QLatin1String("about")) ||
if ((!forcedUrl.isEmpty() && forcedUrl.scheme() != KonqAboutPage::aboutProtocol()) ||
(forcedUrl.isEmpty() && openUrl == false)) { // e.g. window.open
// No point in loading the about page if we're going to replace it with a KHTML part right away
serviceType = QStringLiteral("text/html");
......@@ -1197,7 +1198,7 @@ void KonqViewManager::loadItem(const KConfigGroup &cfg, KonqFrameContainerBase *
//childView->openUrl( url, url.toDisplayString() );
// We need view-follows-view (for the dirtree, for instance)
KonqOpenURLRequest req;
if (url.scheme() != QLatin1String("about")) {
if (url.scheme() != KonqAboutPage::aboutProtocol()) {
req.typedUrl = url.toDisplayString();
}
m_pMainWindow->openView(serviceType, url, childView, req);
......
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